diff options
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 = { |