diff --git a/Makefile b/Makefile index f7ce6b215..9c03018d5 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ run_options := $(filter-out $@,$(MAKECMDGOALS)) compare maxcost medcost mincost modifiers record wasm sources := $(wildcard assets/* assets/*/* dist/version src/* src/*/* src/*/*/* src/*/*/*/*) -platform := $(wildcard platform/* platform/*/* platform/*/*/* platform/*/*/*/*) +platform := $(wildcard platform/* platform/*/* platform/*/*/* platform/*/*/*/* platform/*/*/*/*/*) assets := dist/build/uAssets all: chromium firefox npm @@ -55,8 +55,11 @@ dig: dist/build/uBlock0.dig dig-snfe: dig cd dist/build/uBlock0.dig && npm run snfe $(run_options) -mv3: tools/make-mv3.sh $(sources) $(platform) - tools/make-mv3.sh +mv3-chromium: tools/make-mv3.sh $(sources) $(platform) + tools/make-mv3.sh chromium + +mv3-firefox: tools/make-mv3.sh $(sources) $(platform) + tools/make-mv3.sh firefox mv3-quick: tools/make-mv3.sh $(sources) $(platform) tools/make-mv3.sh quick diff --git a/platform/mv3/extension/manifest.json b/platform/mv3/chromium/manifest.json similarity index 100% rename from platform/mv3/extension/manifest.json rename to platform/mv3/chromium/manifest.json diff --git a/platform/mv3/extension/js/background.js b/platform/mv3/extension/js/background.js index 45a879af2..d2ab2c38f 100644 --- a/platform/mv3/extension/js/background.js +++ b/platform/mv3/extension/js/background.js @@ -169,7 +169,9 @@ async function onPermissionsRemoved() { function onMessage(request, sender, callback) { - if ( sender.origin !== UBOL_ORIGIN ) { return; } + // https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/MessageSender + // Firefox API does not set `sender.origin` + if ( sender.origin !== undefined && sender.origin !== UBOL_ORIGIN ) { return; } switch ( request.what ) { @@ -304,7 +306,11 @@ async function start() { console.log(`Available static rule count: ${count}`); }); - dnr.setExtensionActionOptions({ displayActionCountAsBadgeText: true }); + // https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest + // Firefox API does not support `dnr.setExtensionActionOptions` + if ( dnr.setExtensionActionOptions ) { + dnr.setExtensionActionOptions({ displayActionCountAsBadgeText: true }); + } } (async ( ) => { diff --git a/platform/mv3/extension/js/scripting-manager.js b/platform/mv3/extension/js/scripting-manager.js index 16aaff374..c90b942a4 100644 --- a/platform/mv3/extension/js/scripting-manager.js +++ b/platform/mv3/extension/js/scripting-manager.js @@ -353,6 +353,10 @@ function registerDeclarative(context, declarativeDetails) { /******************************************************************************/ function registerScriptlet(context, scriptletDetails) { + // https://bugzilla.mozilla.org/show_bug.cgi?id=1736575 + // `MAIN` world not yet supported in Firefox + if ( navigator && navigator.product === 'Gecko' ) { return; } + const { before, filteringModeDetails, rulesetsDetails } = context; const hasBroadHostPermission = @@ -427,6 +431,10 @@ function registerScriptlet(context, scriptletDetails) { /******************************************************************************/ function registerScriptletEntity(context) { + // https://bugzilla.mozilla.org/show_bug.cgi?id=1736575 + // `MAIN` world not yet supported in Firefox + if ( navigator && navigator.product === 'Gecko' ) { return; } + const { before, filteringModeDetails, rulesetsDetails } = context; const js = []; diff --git a/platform/mv3/extension/js/scripting/css-declarative.js b/platform/mv3/extension/js/scripting/css-declarative.js index 0f7d65d3f..b0d70f642 100644 --- a/platform/mv3/extension/js/scripting/css-declarative.js +++ b/platform/mv3/extension/js/scripting/css-declarative.js @@ -32,6 +32,7 @@ /******************************************************************************/ const declarativeImports = self.declarativeImports || []; +delete self.declarativeImports; const lookupSelectors = (hn, out) => { for ( const { argsList, hostnamesMap } of declarativeImports ) { diff --git a/platform/mv3/extension/js/scripting/css-generic.js b/platform/mv3/extension/js/scripting/css-generic.js index dd78824d9..ad0169128 100644 --- a/platform/mv3/extension/js/scripting/css-generic.js +++ b/platform/mv3/extension/js/scripting/css-generic.js @@ -30,9 +30,9 @@ (function uBOL_cssGeneric() { const genericSelectorMap = self.genericSelectorMap || new Map(); -if ( genericSelectorMap.size === 0 ) { return; } +delete self.genericSelectorMap; -self.genericSelectorMap = undefined; +if ( genericSelectorMap.size === 0 ) { return; } /******************************************************************************/ diff --git a/platform/mv3/extension/js/scripting/css-procedural.js b/platform/mv3/extension/js/scripting/css-procedural.js index f8fc6f0a1..4068023ba 100644 --- a/platform/mv3/extension/js/scripting/css-procedural.js +++ b/platform/mv3/extension/js/scripting/css-procedural.js @@ -659,6 +659,7 @@ class ProceduralFilterer { /******************************************************************************/ const proceduralImports = self.proceduralImports || []; +delete self.proceduralImports; const lookupSelectors = (hn, out) => { for ( const { argsList, hostnamesMap } of proceduralImports ) { diff --git a/platform/mv3/extension/js/scripting/css-specific.entity.js b/platform/mv3/extension/js/scripting/css-specific.entity.js index 9f4379533..9b38d31e6 100644 --- a/platform/mv3/extension/js/scripting/css-specific.entity.js +++ b/platform/mv3/extension/js/scripting/css-specific.entity.js @@ -34,6 +34,7 @@ // $rulesetId$ const specificEntityImports = self.specificEntityImports || []; +delete self.specificEntityImports; /******************************************************************************/ @@ -65,8 +66,6 @@ for ( let i = 0; i < hnpartslen; i++ ) { } } -self.specificEntityImports = undefined; - if ( selectors.length === 0 ) { return; } try { diff --git a/platform/mv3/firefox/background.html b/platform/mv3/firefox/background.html new file mode 100644 index 000000000..58e9c5e17 --- /dev/null +++ b/platform/mv3/firefox/background.html @@ -0,0 +1,10 @@ + + +
+ +