aboutsummaryrefslogtreecommitdiff
path: root/content/page_actions.js
diff options
context:
space:
mode:
authorjahoti <jahoti@tilde.team>2021-12-02 00:00:00 +0000
committerjahoti <jahoti@tilde.team>2021-12-02 00:00:00 +0000
commit6d819aaea70756b778e71478ec6ce40a8d680841 (patch)
tree1acb322aba177da95095f50ddbb43a993824de86 /content/page_actions.js
parent263d03d5a0b85874e988c9ea7373f9f9471ef1be (diff)
parent69e53743393664ed2db59bbe9bbeaf6f124754f3 (diff)
downloadbrowser-extension-6d819aaea70756b778e71478ec6ce40a8d680841.tar.gz
browser-extension-6d819aaea70756b778e71478ec6ce40a8d680841.zip
Merge remote-tracking branch 'origin/koszko' into build-sys
Diffstat (limited to 'content/page_actions.js')
-rw-r--r--content/page_actions.js27
1 files changed, 12 insertions, 15 deletions
diff --git a/content/page_actions.js b/content/page_actions.js
index f20521c..f26e247 100644
--- a/content/page_actions.js
+++ b/content/page_actions.js
@@ -46,19 +46,17 @@
* IMPORT CONNECTION_TYPE
* IMPORT browser
* IMPORT report_script
- * IMPORT report_settings
* IMPORT report_document_type
* IMPORTS_END
*/
-let policy_received_callback;
+let policy;
/* Snapshot url and content type early; these can be changed by other code. */
let url;
let is_html;
let port;
let loaded = false;
let scripts_awaiting = [];
-let nonce;
function handle_message(message)
{
@@ -72,9 +70,8 @@ function handle_message(message)
scripts_awaiting.push(script_text);
}
}
- if (action === "settings") {
- report_settings(data);
- policy_received_callback({url, allow: data[1].allow});
+ else {
+ console.error(`Bad page action '${action}'.`);
}
}
@@ -95,27 +92,27 @@ function add_script(script_text)
let script = document.createElement("script");
script.textContent = script_text;
- script.setAttribute("nonce", nonce);
+ script.setAttribute("nonce", policy.nonce);
script.haketilo_payload = true;
document.body.appendChild(script);
report_script(script_text);
}
-function handle_page_actions(script_nonce, policy_received_cb,
- doc_ready_promise) {
- policy_received_callback = policy_received_cb;
+function handle_page_actions(_policy, doc_ready_promise) {
+ policy = _policy;
+
url = document.URL;
is_html = document instanceof HTMLDocument;
report_document_type(is_html);
doc_ready_promise.then(document_ready);
- port = browser.runtime.connect({name : CONNECTION_TYPE.PAGE_ACTIONS});
- port.onMessage.addListener(handle_message);
- port.postMessage({url});
-
- nonce = script_nonce;
+ if (policy.payload) {
+ port = browser.runtime.connect({name : CONNECTION_TYPE.PAGE_ACTIONS});
+ port.onMessage.addListener(handle_message);
+ port.postMessage({payload: policy.payload});
+ }
}
/*