Simple Sponsor Skipper document.body is null error on Pale Moon
Line 137 of the script sets up a setInterval to look for a video element, and the callback body on line 139 is:
const plr = document.body.querySelector(PLR_SELECTOR);
The race is in the script: it schedules setInterval(..., ~250ms?) at document-start, and if the first tick lands before the parser inserts <body>, document.body is still null and .querySelector throws. On a slow connection or a heavy page like YouTube, that race window is wide.
You explicitly avoided optional chaining (?.) for Pale Moon compatibility, but then forgot to guard document.body the same way one line down.
2 things can happen, either:
- change line 139 to
const plr = document.body && document.body.querySelector(PLR_SELECTOR); - Or change
// @run-at document-startto// @run-at document-end. the script only needs to find a<video>element, which doesn't exist until DOM-end anyway, so document-start gains nothing here.
I decided to just make a PR to the first one, but it's completely up to you, at the end of the day - I just decided to make a PR since a lot of Pale Moon users are using this userscript on my userscript manager of Greasemonkey for UXP (Including me, but I wouldn't just be content with making the changes locally, I thought it would be worth giving you a nudge about your userscript)