diff options
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/PlaceHolder.js | 3 | ||||
-rw-r--r-- | src/content/content.js | 15 |
2 files changed, 4 insertions, 14 deletions
diff --git a/src/content/PlaceHolder.js b/src/content/PlaceHolder.js index 764b7bc..ec2ab5b 100644 --- a/src/content/PlaceHolder.js +++ b/src/content/PlaceHolder.js @@ -116,8 +116,7 @@ var PlaceHolder = (() => { async enable(replacement) { debug("Enabling %o", this.request, this.policyType); - let ok = await browser.runtime.sendMessage({ - action: "enable", + let ok = await Messages.send("enable", { url: this.request.url, policyType: this.policyType, documentUrl: document.URL diff --git a/src/content/content.js b/src/content/content.js index d5adc94..22dbf1e 100644 --- a/src/content/content.js +++ b/src/content/content.js @@ -114,8 +114,7 @@ var seen = { } } -var handlers = { - +Messages.addHandler({ seen(event) { let {allowed, policyType, request, ownFrame} = event; if (window.top === window) { @@ -129,19 +128,11 @@ var handlers = { } } }, - collect(event) { let list = seen.list; debug("COLLECT", list); return list; } -}; - -browser.runtime.onMessage.addListener(async event => { - if (event.type in handlers) { - debug("Received message", event); - return handlers[event.type](event); - } }); if (document.readyState !== "complete") { @@ -157,7 +148,7 @@ let notifyPage = async () => { debug("Page %s shown, %s", document.URL, document.readyState); if (document.readyState === "complete") { try { - await browser.runtime.sendMessage({action: "pageshow", seen: seen.list, canScript}); + await Messages.send("pageshow", {seen: seen.list, canScript}); return true; } catch (e) { debug(e); @@ -184,7 +175,7 @@ async function init(oldPage = false) { document.URL, document.contentType, document.readyState, window.frameElement && frameElement.data); try { - ({canScript, shouldScript} = await browser.runtime.sendMessage({action: "docStatus", url: document.URL})); + ({canScript, shouldScript} = await Messages.send("queryDocStatus", {url: document.URL})); debug(`document %s, canScript=%s, shouldScript=%s, readyState %s`, document.URL, canScript, shouldScript, document.readyState); if (canScript) { if (oldPage) { |