From c3dcf300a60f581cb97ce29a4ba76190cb362604 Mon Sep 17 00:00:00 2001 From: hackademix Date: Sun, 29 Sep 2019 00:47:58 +0200 Subject: Work-around for Chromium not supporting frameAncestors in webRequest. --- src/lib/TabCache.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/lib/TabCache.js (limited to 'src/lib') diff --git a/src/lib/TabCache.js b/src/lib/TabCache.js new file mode 100644 index 0000000..16d6e1f --- /dev/null +++ b/src/lib/TabCache.js @@ -0,0 +1,24 @@ +var TabCache = (() => { + + let cache = new Map(); + + browser.tabs.onUpdated.addListener(tab => { + cache.set(tab.id, tab); + }); + + browser.tabs.onRemoved.addListener(tab => { + cache.delete(tab.id); + }); + + (async () => { + for (let tab of await browser.tabs.query({})) { + cache.set(tab.id, tab); + } + })(); + + return { + get(tabId) { + return cache.get(tabId); + } + }; +})(); -- cgit v1.2.3