diff options
author | hackademix | 2019-09-29 00:47:58 +0200 |
---|---|---|
committer | hackademix | 2019-09-29 17:29:38 +0200 |
commit | c3dcf300a60f581cb97ce29a4ba76190cb362604 (patch) | |
tree | 37c51d065ee98015842058278aca488b70962f66 /src/lib | |
parent | 78063f341225b85d68ef45faad5197672d5a01c2 (diff) | |
download | noscript-c3dcf300a60f581cb97ce29a4ba76190cb362604.tar.gz noscript-c3dcf300a60f581cb97ce29a4ba76190cb362604.tar.xz noscript-c3dcf300a60f581cb97ce29a4ba76190cb362604.zip |
Work-around for Chromium not supporting frameAncestors in webRequest.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/TabCache.js | 24 |
1 files changed, 24 insertions, 0 deletions
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); + } + }; +})(); |