martok / palefill

Inject Polyfills for various web technologies into pages requiring them
https://martok.github.io/palefill/
Mozilla Public License 2.0
79 stars 9 forks source link

Add support for Notion.Site #4

Closed ghost closed 2 years ago

ghost commented 2 years ago

System Details

Actual Behavior

Notion site is just shown in Pale Moon as blank white page:

Thanks to @Vangelis66 https://github.com/JustOff/github-wc-polyfill/issues/56#issuecomment-1064673764, I found that issue seems like related to the next:

SyntaxError: missing ( after for    app-6eec4a2fbd5acba8d6d3.js:1:550761
martok commented 2 years ago

Is Notion even usable in UXP? When I used it last, it was so incredibly slow that I didn't even try anymore.

The domain name pattern is {username}.notion.site as well as notion.so, right?

ghost commented 2 years ago

The domain name pattern is {username}.notion.site as well as notion.so, right?

Yes.

martok commented 2 years ago

Hrm. Four observations:

  1. The column number has nothing to do with where the error is, there are plenty instances before that...
  2. A 5.5 MB source file (what the hell) breaks Notepad++ :laughing:
  3. The problem is for-await-of, sadly I don't immediately see how this could be fixed/shimmed. I am actually baffled that UXP supports async function* generators but not the iterator you need to do something useful with them.
  4. If it was possible, the fix rule matcher needs to be extended for domain wildcards.
martok commented 2 years ago
  • The problem is for-await-of, sadly I don't immediately see how this could be fixed/shimmed. I am actually baffled that UXP supports async function* generators but not the iterator you need to do something useful with them.

Interesting: according to the changelogs, PM 28.9.0 implemented for-await loops, and now I'm getting error messages that look very different. Looks like an actual bug in UXP :eyes:

From notions app.js, reduced to MWE:

class xx {
  async *mapAsyncIterable(e, t) {
    yield await Promise.race(42);
  }
}
// SyntaxError: await is only valid in async functions

But:

  async function* mapAsyncIterable(e, t) {
    yield await Promise.race(42);
  }
// OK
const foo = {
  mapAsyncIterable: async function* (e, t) {
    yield await Promise.race(42);
  }
}
// OK

Since this is literally the same thing except bound to a prototype in the class declaration, it should work. Seems something in the class parser forgets to apply the async flag.

martok commented 2 years ago

Just verified the above: once UXP#1924 or something to that effect lands, one easy JS fix gets it working :)

Vangelis66 commented 2 years ago

once UXP#1924 or something to that effect lands, one easy JS fix gets it working

... Great news! 🎉 Last Saturday's (25/06/2022) UXP releases by roytam1 have official UXP PR#1924 merged in:

https://github.com/roytam1/UXP/compare/5dc15ae641...e9cc7313ac

I have thus updated to latest Serpent 52.9.0 (32-bit) build (buildID=20220623012013) and I can confirm your PR/code allows the browser to successfully load *notion.* URLs, whereas before it would only yield blank tabs 😞 ... So, many thanks for the platform "fix" you contributed! 🥇

It's worth noting that the *notion.* URLs now load even without palefill, but just to check I installed the latest snapshot of the 4-notion branch, i.e. palefill-v1.14-1-git-20220619-g7a21c47; my most used notion URI (and my test case here) is: https://www.notion.so/34dc4ddf501a4b98b46ea9fb4f3470af?v=878345c5d88f4d21a6520db752b5c29f As said, the URI loads, but in Web Console I still see Syntax Errors:

notion

relating to scripts:

https://www.notion.so/postRender-9a933ef3d3df311053da.js
https://www.notion.so/app-f0bafd74510cb698ce7e.js

So, is the ".so" TLD not supported by the 4-notion palefill branch?

Your overall efforts are being greatly appreciated here... 😄

EDIT:


-*.notion.site/postRender-*.js$script
+*.notion.*/postRender-*.js$script
martok commented 2 years ago

EDIT:

-*.notion.site/postRender-*.js$script
+*.notion.*/postRender-*.js$script

Jup, that. Or rather:

 *.notion.site/postRender-*.js$script
+www.notion.so/postRender-*.js$script

Which is much faster in the rule match engine.

I thought there was some on their own domain, but didn't find it immediately. That will be a thing to keep in mind when I merge this for real.

martok commented 2 years ago

Confirmed working in Pale Moon 31.2.0.1, UXP 5.2.0 :)

Vangelis66 commented 1 year ago

An update on the current state of *.notion.* support:

The previous time I accessed my "notion test-case URL", https://www.notion.so/34dc4ddf501a4b98b46ea9fb4f3470af?v=878345c5d88f4d21a6520db752b5c29f, was mid-December (last year); it loaded fine with the then current palefill version...

Today, with palefill-v1.25-4-git-20221228-g9674444 installed, that URL fails to load (constantly spinning centre circle) on a slightly older UXP platform Serpent 52:

notion1-st52

SyntaxError: invalid identity escape in regular expression

[caused by minified script]
https://www.notion.so/app-3d6ac2f88b3223f5de94.js:1:4978895

... so Notion must've added that incompatible script in the interim 😡 ...

This breakage is UXP-regex-parser related, of course... UXP #1286 hasn't yet made it into an official Pale Moon release, so the Notion breakage should be reproducible in current release PM 31.4.2...

UXP forks by roytam1 have the new UXP regex parser (thanks martok ❤️ ) built-in since 2022-12-24; I have verified that "my" Notion URL loads as expected in the most-up-to-date Serpent 52 (32-bit) build (BuildID=20221230024342) 🎉 ...

I suppose UXP #1286 will also supersede the *.notion.*/postRender-*.js$script fix, if still relevant...