aboutsummaryrefslogtreecommitdiff
path: root/content/page_actions.js
diff options
context:
space:
mode:
Diffstat (limited to 'content/page_actions.js')
-rw-r--r--content/page_actions.js22
1 files changed, 15 insertions, 7 deletions
diff --git a/content/page_actions.js b/content/page_actions.js
index aff56b8..6a6b3a0 100644
--- a/content/page_actions.js
+++ b/content/page_actions.js
@@ -14,10 +14,13 @@
* IMPORTS_END
*/
-var port;
-var loaded = false;
-var scripts_awaiting = [];
-var nonce;
+let policy_received_callback;
+/* Snapshot url early because document.URL can be changed by other code. */
+let url;
+let port;
+let loaded = false;
+let scripts_awaiting = [];
+let nonce;
function handle_message(message)
{
@@ -31,8 +34,10 @@ function handle_message(message)
scripts_awaiting.push(script_text);
}
}
- if (action === "settings")
+ if (action === "settings") {
report_settings(data);
+ policy_received_callback({url, allow: !!data[1] && data[1].allow});
+ }
}
function document_loaded(event)
@@ -56,11 +61,14 @@ function add_script(script_text)
report_script(script_text);
}
-function handle_page_actions(script_nonce) {
+function handle_page_actions(script_nonce, policy_received_cb) {
+ policy_received_callback = policy_received_cb;
+ url = document.URL;
+
document.addEventListener("DOMContentLoaded", document_loaded);
port = browser.runtime.connect({name : CONNECTION_TYPE.PAGE_ACTIONS});
port.onMessage.addListener(handle_message);
- port.postMessage({url: document.URL});
+ port.postMessage({url});
nonce = script_nonce;
}