From 46eb3801ec5097ce21a51b3c8a4bcc191e2c3ad7 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 26 Aug 2021 18:36:18 -0400 Subject: [PATCH] Revert "Inject scriptlets at webNavigation.onCommitted time in Firefox" This reverts commit 7ee9c21b377a57831a75a4f3adca64210b77c00d. Potentially related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1696 --- src/js/background.js | 1 + src/js/messaging.js | 5 ++++- src/js/tab.js | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/js/background.js b/src/js/background.js index b7070cafa..5bb86f021 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -127,6 +127,7 @@ const µBlock = { // jshint ignore:line privacySettingsSupported: vAPI.browserSettings instanceof Object, cloudStorageSupported: vAPI.cloud instanceof Object, canFilterResponseData: typeof browser.webRequest.filterResponseData === 'function', + canInjectScriptletsNow: vAPI.webextFlavor.soup.has('chromium'), // https://github.com/chrisaljoudi/uBlock/issues/180 // Whitelist directives need to be loaded once the PSL is available diff --git a/src/js/messaging.js b/src/js/messaging.js index 4be010fe4..3888bab45 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -627,7 +627,10 @@ const retrieveContentScriptParameters = async function(sender, request) { // 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 ( isNetworkURI(sender.frameURL) === false ) { + if ( + µb.canInjectScriptletsNow === false || + isNetworkURI(sender.frameURL) === false + ) { response.scriptlets = scriptletFilteringEngine.retrieve(request); } diff --git a/src/js/tab.js b/src/js/tab.js index 93faf4c49..9d1e7e2ce 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -913,7 +913,11 @@ vAPI.Tabs = class extends vAPI.Tabs { const pageStore = µb.pageStoreFromTabId(tabId); if ( pageStore === null ) { return; } pageStore.setFrameURL(details); - if ( isNetworkURI(url) && pageStore.getNetFilteringSwitch() ) { + if ( + µb.canInjectScriptletsNow && + isNetworkURI(url) && + pageStore.getNetFilteringSwitch() + ) { scriptletFilteringEngine.injectNow(details); } }