From 3fd2588650ab16d6cbc1417a3adb2bb7a20e1dfe Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 16 Nov 2023 17:07:48 -0500 Subject: [PATCH] Allow scriptlets to be injected in `about:blank` Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/2963 --- src/js/scriptlet-filtering.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/js/scriptlet-filtering.js b/src/js/scriptlet-filtering.js index 120e3f410..71cd60826 100644 --- a/src/js/scriptlet-filtering.js +++ b/src/js/scriptlet-filtering.js @@ -159,14 +159,11 @@ const mainWorldInjector = (( ) => { const parts = [ '(', function(injector, details) { + if ( typeof self.uBO_scriptletsInjected === 'string' ) { return; } const doc = document; - if ( - doc.location === null || - details.hostname !== doc.location.hostname || - typeof self.uBO_scriptletsInjected === 'string' - ) { - return; - } + if ( doc.location === null ) { return; } + const hostname = doc.location.hostname; + if ( hostname !== '' && details.hostname !== hostname ) { return; } injector(doc, details); return 0; }.toString(), @@ -193,14 +190,11 @@ const isolatedWorldInjector = (( ) => { const parts = [ '(', function(details) { + if ( self.uBO_isolatedScriptlets === 'done' ) { return; } const doc = document; - if ( - doc.location === null || - details.hostname !== doc.location.hostname || - self.uBO_isolatedScriptlets === 'done' - ) { - return; - } + if ( doc.location === null ) { return; } + const hostname = doc.location.hostname; + if ( hostname !== '' && details.hostname !== hostname ) { return; } const isolatedScriptlets = function(){}; isolatedScriptlets(); self.uBO_isolatedScriptlets = 'done';