diff --git a/background/common.js b/background/common.js index 87de1c10..d6e01fea 100644 --- a/background/common.js +++ b/background/common.js @@ -12,11 +12,20 @@ uuidIndex */ -const uuidIndex = new Map(); const bgReady = {}; bgReady.styles = new Promise(r => (bgReady._resolveStyles = r)); bgReady.all = new Promise(r => (bgReady._resolveAll = r)); +const uuidIndex = Object.assign(new Map(), { + custom: {}, + customize(obj, setter) { + Object.defineProperty(uuidIndex.custom, obj.id, { + get: () => obj, + set: setter, + }); + }, +}); + function addAPI(methods) { for (const [key, val] of Object.entries(methods)) { const old = API[key]; diff --git a/background/style-manager.js b/background/style-manager.js index fc9de492..b480911c 100644 --- a/background/style-manager.js +++ b/background/style-manager.js @@ -73,10 +73,7 @@ const styleMan = (() => { _id: `${chrome.runtime.id}-${INJ_ORDER}`, _rev: 0, }; - uuidIndex.custom = Object.defineProperty({}, INJ_ORDER, { - get: () => orderWrap, - set: setOrder, - }); + uuidIndex.customize(orderWrap, setOrder); /** @type {Promise|boolean} will be `true` to avoid wasting a microtask tick on each `await` */ let ready = init();