Restructure inclusion of file/ftp protocol-specific content scripts.

This commit is contained in:
hackademix 2024-11-19 23:16:13 +01:00
parent fd33d7b3ce
commit 06cd1c1e4e
No known key found for this signature in database
GPG Key ID: 231A83AFDA9C2434
5 changed files with 206 additions and 207 deletions

View File

@ -46,8 +46,9 @@ if (MANIFEST_VER.includes(3)) {
/^(?:<all_urls>|webRequestBlocking)$/
.test(p)
);
const excludedScriptsRx = /\bcontent\/(?:embeddingDocument|dirindex)\.js$/;
for (const cs of json.content_scripts) {
cs.js = cs.js.filter(js => !js.includes("content/embeddingDocument.js"))
cs.js = cs.js.filter(path => !excludedScriptsRx.test(path));
}
delete json.browser_action;
delete json.commands._execute_browser_action

View File

@ -18,7 +18,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (UA.isMozilla) (() => {
if (FILE_OR_FTP && UA.isMozilla) (() => {
// see https://searchfox.org/mozilla-central/rev/76c1ff5f0de23366fe952ab228610ee695a56e68/netwerk/streamconv/converters/nsIndexedToHTML.cpp#334
'use strict';
var gTable, gOrderBy, gTBody, gRows, gUI_showHidden;

View File

@ -18,8 +18,9 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
'use strict';
const FILE_OR_FTP = /^(?:file|ftp):$/.test(location.protocol);
{
'use strict';
let listenersMap = new Map();
let backlog = new Set();
@ -155,7 +156,7 @@
if (!(UA.isMozilla || perms.capabilities.includes("script")) &&
/^file:\/\/\/(?:[^#?]+\/)?$/.test(document.URL)) {
// Allow Chromium browser UI scripts for directory navigation
// (for Firefox we rely on emulation in content/ftp.js).
// (for Firefox we rely on emulation in content/dirindex.js).
perms.capabilities.push("script");
}
this.capabilities = new Set(perms.capabilities);
@ -177,6 +178,10 @@
globalThis.ns_setupCallBack = ns.domPolicy
? () => {}
: ({domPolicy}) => {
ns.domPolicy = domPolicy;
if (ns.setup) {
if (ns.syncSetup) ns.syncSetup(domPolicy);
else ns.setup(domPolicy);
}
};
}

View File

@ -22,7 +22,8 @@
"use strict";
(window.ns || (window.ns = {})).syncFetchPolicy = function() {
if (FILE_OR_FTP) {
(globalThis.ns ||= {}).syncFetchPolicy = function() {
ns.pendingSyncFetchPolicy = false;
ns.syncFetchPolicy = () => {};
@ -219,8 +220,9 @@
}
ns.fetchLikeNoTomorrow(url, syncSetup);
};
};
if (ns.pendingSyncFetchPolicy) {
if (ns.pendingSyncFetchPolicy) {
ns.syncFetchPolicy();
}
}

View File

@ -116,7 +116,10 @@
"/nscl/content/WebGLHook.js",
"/nscl/content/promptHook.js",
"content/embeddingDocument.js",
"content/content.js"
"content/content.js",
"content/dirindex.js",
"/nscl/content/DocumentFreezer.js",
"content/syncFetchPolicy.js"
]
},
{
@ -134,18 +137,6 @@
"/nscl/main/WebGLHook.main.js",
"/nscl/main/prefetchCSSResources.main.js"
]
},
{
"run_at": "document_start",
"matches": ["file://*/*", "ftp://*/*"],
"match_about_blank": true,
"match_origin_as_fallback": true,
"all_frames": true,
"js": [
"content/ftp.js",
"/nscl/content/DocumentFreezer.js",
"content/syncFetchPolicy.js"
]
}
],