don't trust location.href as it hides text fragment
This commit is contained in:
parent
2a12cbdf43
commit
a780ecae67
background
|
@ -8,6 +8,7 @@
|
|||
stringAsRegExp
|
||||
styleCodeEmpty
|
||||
styleSectionGlobal
|
||||
tabManager
|
||||
tryRegExp
|
||||
URLS
|
||||
*/
|
||||
|
@ -148,6 +149,10 @@ const styleManager = API.styles = (() => {
|
|||
/** @returns {Promise<StyleSectionsToApply>} */
|
||||
async getSectionsByUrl(url, id, isInitialApply) {
|
||||
await ready;
|
||||
/* 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.sender;
|
||||
url = tab && tabManager.get(tab.id, 'url', frameId) || url;
|
||||
let cache = cachedStyleForUrl.get(url);
|
||||
if (!cache) {
|
||||
cache = {
|
||||
|
|
|
@ -8,9 +8,9 @@ const tabManager = (() => {
|
|||
chrome.tabs.onRemoved.addListener(tabId => cache.delete(tabId));
|
||||
chrome.tabs.onReplaced.addListener((added, removed) => cache.delete(removed));
|
||||
navigatorUtil.onUrlChange(({tabId, frameId, url}) => {
|
||||
const oldUrl = !frameId && tabManager.get(tabId, 'url', frameId);
|
||||
tabManager.set(tabId, 'url', frameId, url);
|
||||
if (frameId) return;
|
||||
const oldUrl = tabManager.get(tabId, 'url');
|
||||
tabManager.set(tabId, 'url', url);
|
||||
for (const fn of listeners) {
|
||||
try {
|
||||
fn({tabId, url, oldUrl});
|
||||
|
|
Loading…
Reference in New Issue
Block a user