diff options
author | hackademix | 2018-08-15 16:41:55 +0200 |
---|---|---|
committer | hackademix | 2018-08-16 23:43:36 +0200 |
commit | 57d883d63e9b8232e275dac7eec24f84c040dd24 (patch) | |
tree | a4a9f05f0744ccef23e31643f80c400abe0dab37 /src/content/content.js | |
parent | 2c75eedadddd8bda0522cddaf119e1e5c621c7c2 (diff) | |
download | noscript-57d883d63e9b8232e275dac7eec24f84c040dd24.tar.gz noscript-57d883d63e9b8232e275dac7eec24f84c040dd24.tar.xz noscript-57d883d63e9b8232e275dac7eec24f84c040dd24.zip |
Policy serialization using the contentScripts API.
Diffstat (limited to 'src/content/content.js')
-rw-r--r-- | src/content/content.js | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/content/content.js b/src/content/content.js index 886c363..37d0d32 100644 --- a/src/content/content.js +++ b/src/content/content.js @@ -1,7 +1,34 @@ 'use strict'; // debug = () => {}; // REL_ONLY - +{ + let listenersMap = new Map(); + var ns = { + on(eventName, listener) { + let listeners = listenersMap.get(eventName); + if (!listeners) listenersMap.set(eventName, listeners = new Set()); + listeners.add(listener); + }, + detach(eventName, listener) { + let listeners = listenersMap.get(eventName); + if (listeners) listeners.delete(listener); + }, + fire(eventName) { + let listeners = listenersMap.get(eventName); + if (listeners) { + for (let l of listeners) { + l(this); + } + } + }, + perms: { DEFAULT: null, CURRENT: null }, + allows(cap) { + let perms = this.perms.CURRENT; + return perms && perms.capabilities.includes(cap); + } + } +} + var canScript = true, shouldScript = false; let now = () => performance.now() + performance.timeOrigin; @@ -24,7 +51,6 @@ function probe() { var _ = browser.i18n.getMessage; - var embeddingDocument = false; var seen = { |