Infrastructure to replace patchWindow.js with MAIN world content scripts.

This commit is contained in:
hackademix 2024-11-11 17:58:50 +01:00
parent 89b7e188d0
commit 91e3d25744
No known key found for this signature in database
GPG Key ID: 231A83AFDA9C2434
3 changed files with 24 additions and 3 deletions

View File

@ -241,8 +241,17 @@ var LifeCycle = (() => {
if (!UA.isMozilla) {
// Chromium does not inject content scripts at startup automatically for already loaded pages,
// let's hack it manually.
const contentScripts = browser.runtime.getManifest().content_scripts.find(s =>
s.js && s.matches.includes("<all_urls>") && s.all_frames && s.match_about_blank).js;
const contentScripts = browser.runtime
.getManifest()
.content_scripts.find(
(s) =>
s.js &&
s.matches.includes("<all_urls>") &&
s.all_frames &&
s.match_about_blank &&
// do not expose MAIN world scripts meant to run before untrusted page ones
s.world !== "MAIN"
).js;
await Promise.allSettled((await browser.tabs.query({})).map(async tab => {
try {

View File

@ -117,6 +117,18 @@
"content/content.js"
]
},
{
"run_at": "document_start",
"matches": ["<all_urls>"],
"match_about_blank": true,
"match_origin_as_fallback": true,
"all_frames": true,
"world": "MAIN",
"js": [
"/nscl/main/uuid.js",
"/nscl/main/Worlds.js"
]
},
{
"run_at": "document_start",
"matches": ["file://*/*", "ftp://*/*"],

@ -1 +1 @@
Subproject commit a9022721771d7a2ff3da289452718ab9101a98dc
Subproject commit 7a6592483cc7a985127da6d0ac21d482ca028b26