From 57d883d63e9b8232e275dac7eec24f84c040dd24 Mon Sep 17 00:00:00 2001 From: hackademix Date: Wed, 15 Aug 2018 16:41:55 +0200 Subject: Policy serialization using the contentScripts API. --- src/content/content.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/content/content.js') 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 = { -- cgit v1.2.3