Skip to content

Commit a7dad0f

Browse files
committed
fix updateStyleEntry for frame styles in popup
1 parent b1e8cbc commit a7dad0f

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/background/style-manager/index.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,29 @@ export function getAllOrdered(keys) {
8181
: res;
8282
}
8383

84+
/**
85+
* @param {number} [id]
86+
* @param {number} [tabId]
87+
* @param {boolean} [needsOvrs]
88+
* @returns {MatchUrlResult[]}
89+
*/
90+
export function getByIdInTab(id, tabId, needsOvrs) {
91+
const urlObj = tabCache[tabId]?.[kUrl] || {};
92+
const urls = new Set();
93+
const res = [];
94+
for (const frameId in urlObj) {
95+
const url = urlObj[frameId];
96+
if (!urls.has(url)) {
97+
urls.add(url);
98+
for (const v of getByUrl(url, id, tabId, needsOvrs)) {
99+
v.frameUrl = +frameId ? url : '';
100+
res.push(v);
101+
}
102+
}
103+
}
104+
return res;
105+
}
106+
84107
/**
85108
* @param {string} url
86109
* @param {number} [id]

src/popup/render.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {CHROME} from '@/js/ua';
99
import {ownRoot} from '@/js/urls';
1010
import {capitalize, clipString, stringAsRegExpStr, t} from '@/js/util';
1111
import {MF} from '@/js/util-webext';
12-
import {isBlocked, tabId, tabUrl, tabUrlSupported} from '.';
12+
import {isBlocked, tabId, tabUrlSupported} from '.';
1313
import {openOptions, openStyleFinder, pSideConfig, tSideHint} from './events';
1414
import {closeMenu, menu, openMenu} from './menu';
1515

@@ -279,7 +279,7 @@ export function updateStateIcon(newDark, newDisabled) {
279279
export async function updateStyleEntry(id, del) {
280280
const entry = $id(kStyleIdPrefix + id);
281281
const inMenu = id === menu.styleId && menu.isConnected;
282-
const [res] = del ? [] : await API.styles.getByUrl(tabUrl, id, tabId, inMenu);
282+
const [res] = del ? [] : await API.styles.getByIdInTab(id, tabId, inMenu);
283283
if (res) {
284284
const el = createStyleElement(Object.assign(res.style, res), entry);
285285
if (!el.isConnected) installed.append(el);

0 commit comments

Comments
 (0)