From a56e528b310b439df7d4156a788324f099d6ecf7 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 28 Feb 2021 18:01:26 +0300 Subject: [PATCH] trust sender's URL in FF fixes #1194 --- background/style-manager.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/background/style-manager.js b/background/style-manager.js index 26406feb..81898e82 100644 --- a/background/style-manager.js +++ b/background/style-manager.js @@ -1,5 +1,5 @@ /* global API msg */// msg.js -/* global URLS stringAsRegExp tryRegExp */// toolbox.js +/* global CHROME URLS stringAsRegExp tryRegExp */// toolbox.js /* global bgReady compareRevision */// common.js /* global calcStyleDigest styleCodeEmpty styleSectionGlobal */// sections-util.js /* global db */ @@ -128,10 +128,13 @@ const styleMan = (() => { if (isInitialApply && prefs.get('disableAll')) { return {disableAll: true}; } - /* Chrome hides text frament from location.href of the page e.g. #:~:text=foo - so we'll use the real URL reported by webNavigation API */ - const {tab, frameId} = this && this.sender || {}; - url = tab && tabMan.get(tab.id, 'url', frameId) || url; + if (CHROME && this && this.sender) { + /* Chrome hides text frament from location.href of the page e.g. #:~:text=foo + so we'll use the real URL reported by webNavigation API. + TODO: if FF will do the same, this won't work as is: FF reports onCommitted too late */ + const {tab, frameId} = this.sender; + url = tab && tabMan.get(tab.id, 'url', frameId) || url; + } let cache = cachedStyleForUrl.get(url); if (!cache) { cache = {