Answer the question
In order to leave comments, you need to log in
Content-Security-Policy and manifest v3?
Hey!
I can not deal with the 3rd version of the manifesto in any way.
It seems like version 3 now prohibits injecting scripts into the page, but I have 90% of the plugin built on this to ennoble the site with new features.
on the manifest version 2 - everything works, but changing it to 3 gives the following error:
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-xh//iOp5YsjV4AHCfTPhZ7ybsMYdmYyvqiTjVw3FmHY='), or a nonce ('nonce-...') is required to enable inline execution.
Content-Security-Policy: script-src 'nonce-EDNnf03nceIOfn39fn3e9h3sdfa'
Content-Security-Policy: script-src 'sha256-xh//iOp5YsjV4AHCfTPhZ7ybsMYdmYyvqiTjVw3FmHY='
"content_security_policy": {
"extension_pages": "...",
"sandbox": "..."
}
let PageScriptSpace = document.createElement('script');
InjectFunction = function(PageScriptSpace, func) {
PageScriptSpace.innerHTML += func + ';';
}
InjectFunction(PageScriptSpace, foo);
InjectFunction(PageScriptSpace, bar);
h = document.querySelector('head');
h.appendChild(PageScriptSpace);
Answer the question
In order to leave comments, you need to log in
example:
if I inject to a youtube page,
then I write to the manifest
"web_accessible_resources": [
{
"resources": [ "inner.js", "test.css" ],
"matches": [ "https://www.youtube.com/*", "https://m.youtube.com/*" ],
"extension_ids": []
}
],
"host_permissions": [
"https://www.youtube.com/*",
],
и он работает
const injectJS = document.createElement('script');
injectJS.type='text/javascript';
injectJS.src=chrome.runtime.getURL("inner.js");
document.body.appendChild(injectJS);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question