Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MV3 CSP Blocking Reddit media player #5511

Closed
benmcgarry opened this issue Mar 29, 2024 · 5 comments · Fixed by #5512
Closed

MV3 CSP Blocking Reddit media player #5511

benmcgarry opened this issue Mar 29, 2024 · 5 comments · Fixed by #5512

Comments

@benmcgarry
Copy link
Collaborator

benmcgarry commented Mar 29, 2024

Refused to load the script 'https://www.redditstatic.com/videoplayer.XCrwE8Bi5A4.js' because it violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

https://github.com/honestbleeps/Reddit-Enhancement-Suite/blob/master/lib/utils/pageContextScript.js

Stack trace points here:

module.onInit = () => {
if (isAppType('r2')) {
// We'll probably replace Reddit's video player, so disable the script containing it for now
// This happens on `onInit` since RES' options load slower than the script's
const preventVideoPlayerScriptTasks = [
stopPageContextScript(script => (/^\/?videoplayer\./).test(new URL(script.src, location.origin).pathname), 'head', true),
// Reddit loads scripts which initializes the video player, which will cause a slowdown if not blocked
stopPageContextScript(script => !!script.innerHTML.match('RedditVideoPlayer'), PagePhases.contentStart.then(() => document.querySelector('#siteTable')), false),
];
loadOptions.then(() => {
// We might need to restore the native player
const removeNativePlayer = Modules.isRunning(module) && isSiteModuleEnabled(vreddit) && vreddit.options && vreddit.options.forceReplaceNativeExpando.value;
if (!removeNativePlayer) forEachSeq(preventVideoPlayerScriptTasks, ({ undo }) => undo());
});
}
};

@benmcgarry
Copy link
Collaborator Author

Appears https://github.com/honestbleeps/Reddit-Enhancement-Suite/blob/master/lib/modules/hosts/vreddit.js is pulling in a external script and MV3 doesnt allow that anymore.

@benmcgarry
Copy link
Collaborator Author

@larsjohnsen
Copy link
Collaborator

larsjohnsen commented Mar 29, 2024

No, but it it is added directly via build.js.

The onInit block in showImages had, as far as I can remember, no side effects other than some performance improvements, so I think we might as well remove it.

@benmcgarry
Copy link
Collaborator Author

benmcgarry commented Mar 29, 2024

Removing that onInit block may have fixed it... Not able to repro it anymore and no CSP error. It looks like Reddits advert block might have been messing with it.

@benmcgarry
Copy link
Collaborator Author

Looking at 507c0b2

I think its because theyve started to run ads through the same domain with a different player.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants