diff --git a/src/js/messaging.js b/src/js/messaging.js index 4021fe5d4..0b778394c 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -627,7 +627,13 @@ const retrieveContentScriptParameters = function(sender, request) { response.specificCosmeticFilters = µb.cosmeticFilteringEngine.retrieveSpecificSelectors(request, response); - if ( µb.canInjectScriptletsNow === false ) { + // https://github.com/uBlockOrigin/uBlock-issues/issues/688#issuecomment-748179731 + // For non-network URIs, scriptlet injection is deferred to here. The + // effective URL is available here in `request.url`. + if ( + µb.canInjectScriptletsNow === false || + µb.URI.isNetworkURI(sender.frameURL) === false + ) { response.scriptlets = µb.scriptletFilteringEngine.retrieve(request); } diff --git a/src/js/scriptlet-filtering.js b/src/js/scriptlet-filtering.js index a03e4a04f..39b38396b 100644 --- a/src/js/scriptlet-filtering.js +++ b/src/js/scriptlet-filtering.js @@ -377,7 +377,6 @@ api.injectNow = function(details) { if ( typeof details.frameId !== 'number' ) { return; } - if ( µb.URI.isNetworkURI(details.url) === false ) { return; } const request = { tabId: details.tabId, frameId: details.frameId, diff --git a/src/js/tab.js b/src/js/tab.js index cc09eb7bb..3f70aec0e 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -868,7 +868,10 @@ vAPI.Tabs = class extends vAPI.Tabs { // properly setup if network requests are fired from within the tab. // Example: Chromium + case #6 at // http://raymondhill.net/ublock/popup.html - + // https://github.com/uBlockOrigin/uBlock-issues/issues/688#issuecomment-748179731 + // For non-network URIs, defer scriptlet injection to content script. The + // reason for this is that we need the effective URL and this information + // is not available at this point. onNavigation(details) { super.onNavigation(details); const µb = µBlock; @@ -879,8 +882,8 @@ vAPI.Tabs = class extends vAPI.Tabs { pageStore.journalAddRootFrame('committed', details.url); } } - if ( µb.canInjectScriptletsNow ) { - let pageStore = µb.pageStoreFromTabId(details.tabId); + if ( µb.canInjectScriptletsNow && µb.URI.isNetworkURI(details.url) ) { + const pageStore = µb.pageStoreFromTabId(details.tabId); if ( pageStore !== null && pageStore.getNetFilteringSwitch() ) { µb.scriptletFilteringEngine.injectNow(details); }