Skip to content

Commit 549c0c6

Browse files
committed
observe own tabs
1 parent 1f9e91d commit 549c0c6

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

src/background/broadcast.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ async function doBroadcast() {
5757
}
5858
tabs.length = tabsLen;
5959
} else if (activeTab) {
60-
for (const t of tabCache.values()) {
61-
if (t[kStyleIds] && !t[kUrl][0].startsWith(ownRoot)) {
62-
tabsLen = tabs[t.id === activeTab.id ? 'unshift' : 'push'](t.id);
60+
for (const {id, [kUrl]: url, [kStyleIds]: styleIds} of tabCache.values()) {
61+
if (styleIds && url && url[0] && !url[0].startsWith(ownRoot)) {
62+
tabsLen = tabs[id === activeTab.id ? 'unshift' : 'push'](id);
6363
}
6464
}
6565
}

src/background/navigation-manager.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import '@/js/browser';
22
import {kAboutBlank, kUrl} from '@/js/consts';
33
import {CHROME, FIREFOX} from '@/js/ua';
4-
import {chromeProtectsNTP} from '@/js/urls';
4+
import {chromeProtectsNTP, ownRoot} from '@/js/urls';
55
import {deepEqual} from '@/js/util';
66
import {ignoreChromeError, MF} from '@/js/util-webext';
77
import {pingTab, sendTab} from './broadcast';
@@ -11,7 +11,10 @@ import tabCache from './tab-manager';
1111
export const webNavigation = chrome.webNavigation;
1212
/** @type {{ url: chrome.events.UrlFilter[] }} */
1313
const WEBNAV_FILTER_STYLABLE = {
14-
url: [{schemes: ['http', 'https', 'file', 'ftp', 'ftps']}],
14+
url: [
15+
{schemes: ['http', 'https', 'file', 'ftp', 'ftps']},
16+
{urlPrefix: ownRoot},
17+
],
1518
};
1619
export const kCommitted = 'committed';
1720
let prevData = {};

src/background/style-manager/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,15 @@ export function getSectionsByUrl(url, id, isInitialApply) {
280280
buildCache(cache, url, res);
281281
}
282282
res = cache.sections;
283+
res = id
284+
? ((res = res[id])) ? [res] : []
285+
: Object.values(res);
286+
if (isInitialApply === true && res.length) {
287+
(td[kUrl] ??= {})[frameId] ??= url;
288+
}
283289
return {
284290
cfg,
285-
sections: id
286-
? ((res = res[id])) ? [res] : []
287-
: Object.values(res),
291+
sections: res,
288292
};
289293
}
290294

0 commit comments

Comments
 (0)