|
|
@@ -25,55 +25,47 @@
|
|
|
|
|
|
singlefile.extension.lib.core.bg.scripts = (() => {
|
|
|
|
|
|
- let contentScript, frameScript, moduleScript;
|
|
|
+ let contentScript, frameScript;
|
|
|
|
|
|
const contentScriptFiles = [
|
|
|
"/lib/index.js",
|
|
|
- "/extension/index.js",
|
|
|
- "/extension/lib/browser-polyfill/chrome-browser-polyfill.js",
|
|
|
- "/lib/hooks/content/content-hooks.js",
|
|
|
+ "/lib/single-file/vendor/css-font-property-parser.js",
|
|
|
+ "/lib/single-file/vendor/css-media-query-parser.js",
|
|
|
"/lib/single-file/vendor/css-tree.js",
|
|
|
"/lib/single-file/vendor/html-srcset-parser.js",
|
|
|
+ "/lib/single-file/vendor/css-minifier.js",
|
|
|
+ "/lib/single-file/modules/html-minifier.js",
|
|
|
+ "/lib/single-file/modules/html-serializer.js",
|
|
|
+ "/lib/single-file/modules/html-images-alt-minifier.js",
|
|
|
+ "/lib/single-file/modules/css-fonts-minifier.js",
|
|
|
+ "/lib/single-file/modules/css-fonts-alt-minifier.js",
|
|
|
+ "/lib/single-file/modules/css-matched-rules.js",
|
|
|
+ "/lib/single-file/modules/css-rules-minifier.js",
|
|
|
+ "/lib/single-file/modules/css-medias-alt-minifier.js",
|
|
|
"/lib/single-file/single-file-util.js",
|
|
|
"/lib/single-file/single-file-helper.js",
|
|
|
"/lib/single-file/single-file-core.js",
|
|
|
"/lib/single-file/single-file.js",
|
|
|
- "/common/index.js",
|
|
|
- "/common/ui/content/content-infobar.js",
|
|
|
+ "/lib/lazy/content/content-lazy-loader.js",
|
|
|
+ "/lib/hooks/content/content-hooks.js",
|
|
|
+ "/extension/index.js",
|
|
|
+ "/extension/lib/browser-polyfill/chrome-browser-polyfill.js",
|
|
|
"/extension/lib/fetch/content/content-fetch-resources.js",
|
|
|
- "/extension/core/content/content-main.js",
|
|
|
- "/extension/ui/content/content-ui-main.js"
|
|
|
];
|
|
|
|
|
|
const frameScriptFiles = [
|
|
|
"/lib/index.js",
|
|
|
- "/extension/index.js",
|
|
|
- "/extension/lib/browser-polyfill/chrome-browser-polyfill.js",
|
|
|
"/lib/hooks/content/content-hooks-frames.js",
|
|
|
"/lib/single-file/single-file-helper.js",
|
|
|
"/lib/frame-tree/content/content-frame-tree.js",
|
|
|
+ "/extension/index.js",
|
|
|
+ "/extension/lib/browser-polyfill/chrome-browser-polyfill.js",
|
|
|
"/extension/lib/fetch/content/content-fetch-resources.js"
|
|
|
];
|
|
|
|
|
|
- const moduleScriptFiles = [
|
|
|
- "/lib/single-file/modules/html-minifier.js",
|
|
|
- "/lib/single-file/modules/html-serializer.js",
|
|
|
- "/lib/single-file/vendor/css-minifier.js",
|
|
|
- "/lib/lazy/content/content-lazy-loader.js",
|
|
|
- "/lib/single-file/modules/html-images-alt-minifier.js",
|
|
|
- "/lib/single-file/vendor/css-font-property-parser.js",
|
|
|
- "/lib/single-file/modules/css-fonts-minifier.js",
|
|
|
- "/lib/single-file/modules/css-fonts-alt-minifier.js",
|
|
|
- "/lib/single-file/modules/css-matched-rules.js",
|
|
|
- "/lib/single-file/modules/css-rules-minifier.js",
|
|
|
- "/lib/single-file/vendor/css-media-query-parser.js",
|
|
|
- "/lib/single-file/modules/css-medias-alt-minifier.js"
|
|
|
- ];
|
|
|
-
|
|
|
- initScripts();
|
|
|
return {
|
|
|
- async inject(tabId, options) {
|
|
|
- await initScripts();
|
|
|
+ async inject(tabId, options, extensionScriptFiles) {
|
|
|
+ await initScripts(extensionScriptFiles);
|
|
|
let scriptsInjected;
|
|
|
if (!options.removeFrames) {
|
|
|
try {
|
|
|
@@ -83,7 +75,7 @@ singlefile.extension.lib.core.bg.scripts = (() => {
|
|
|
}
|
|
|
}
|
|
|
try {
|
|
|
- await browser.tabs.executeScript(tabId, { code: moduleScript + "\n" + contentScript, allFrames: false, runAt: "document_idle" });
|
|
|
+ await browser.tabs.executeScript(tabId, { code: contentScript, allFrames: false, runAt: "document_idle" });
|
|
|
scriptsInjected = true;
|
|
|
} catch (error) {
|
|
|
// ignored
|
|
|
@@ -97,12 +89,11 @@ singlefile.extension.lib.core.bg.scripts = (() => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- async function initScripts() {
|
|
|
- if (!contentScript && !frameScript && !moduleScript) {
|
|
|
- [contentScript, frameScript, moduleScript] = await Promise.all([
|
|
|
- getScript(contentScriptFiles),
|
|
|
- getScript(frameScriptFiles),
|
|
|
- getScript(moduleScriptFiles)
|
|
|
+ async function initScripts(extensionScriptFiles = []) {
|
|
|
+ if (!contentScript && !frameScript) {
|
|
|
+ [contentScript, frameScript] = await Promise.all([
|
|
|
+ getScript(contentScriptFiles.concat(extensionScriptFiles)),
|
|
|
+ getScript(frameScriptFiles)
|
|
|
]);
|
|
|
}
|
|
|
}
|