diff --git a/src/js/contentscript.js b/src/js/contentscript.js index 7cbc12381..850449734 100644 --- a/src/js/contentscript.js +++ b/src/js/contentscript.js @@ -118,6 +118,26 @@ vAPI.contentScript = true; /******************************************************************************/ /******************************************************************************/ +// https://github.com/uBlockOrigin/uBlock-issues/issues/688#issuecomment-663657508 +{ + let location = self.location; + if ( location.protocol === 'about:' ) { + try { + let context = self; + do { + context = context.parent; + location = context.location; + } while ( context !== self.top && location.protocol === 'about:' ); + } catch(ex) { + } + } + vAPI.pageLocation = location; +} + +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ + vAPI.userStylesheet = { added: new Set(), removed: new Set(), @@ -1765,8 +1785,8 @@ vAPI.injectScriptlet = function(doc, text) { vAPI.bootstrap = function() { vAPI.messaging.send('contentscript', { what: 'retrieveContentScriptParameters', - url: window.location.href, - isRootFrame: window === window.top, + url: vAPI.pageLocation.href, + isRootFrame: self === self.top, charset: document.characterSet, }).then(response => { bootstrapPhase1(response); diff --git a/src/js/messaging.js b/src/js/messaging.js index d0e18a1f2..a8d6128f0 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -524,11 +524,15 @@ const µb = µBlock; const retrieveContentScriptParameters = function(senderDetails, request) { if ( µb.readyToFilter !== true ) { return; } - const { url, tabId, frameId } = senderDetails; - if ( url === undefined || tabId === undefined || frameId === undefined ) { + const { url: senderURL, tabId, frameId } = senderDetails; + if ( + tabId === undefined || + frameId === undefined || + senderURL === undefined || + senderURL !== request.url && senderURL.startsWith('about:') === false + ) { return; } - if ( request.url !== url ) { return; } const pageStore = µb.pageStoreFromTabId(tabId); if ( pageStore === null || pageStore.getNetFilteringSwitch() === false ) { return; @@ -714,7 +718,7 @@ const onMessage = function(request, sender, callback) { xhr.responseType = 'text'; xhr.onload = function() { this.onload = null; - var i18n = { + const i18n = { bidi_dir: document.body.getAttribute('dir'), create: vAPI.i18n('pickerCreate'), pick: vAPI.i18n('pickerPick'), diff --git a/src/js/scriptlets/cosmetic-logger.js b/src/js/scriptlets/cosmetic-logger.js index 57ee4723a..a096a331c 100644 --- a/src/js/scriptlets/cosmetic-logger.js +++ b/src/js/scriptlets/cosmetic-logger.js @@ -211,10 +211,12 @@ const processTimer = new vAPI.SafeAnimationFrame(( ) => { if ( toLog.length === 0 ) { return; } + const location = vAPI.pageLocation || self.location; + vAPI.messaging.send('scriptlets', { what: 'logCosmeticFilteringData', - frameURL: window.location.href, - frameHostname: window.location.hostname, + frameURL: location.href, + frameHostname: location.hostname, matchedSelectors: toLog, }); //console.timeEnd('dom logger/scanning for matches');