summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorhackademix2019-09-29 00:47:58 +0200
committerhackademix2019-09-29 17:29:38 +0200
commitc3dcf300a60f581cb97ce29a4ba76190cb362604 (patch)
tree37c51d065ee98015842058278aca488b70962f66 /src/lib
parent78063f341225b85d68ef45faad5197672d5a01c2 (diff)
downloadnoscript-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.js24
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);
+ }
+ };
+})();