Revision 53837634
Added by koszko about 2 years ago
content/page_actions.js | ||
---|---|---|
14 | 14 |
* IMPORTS_END |
15 | 15 |
*/ |
16 | 16 |
|
17 |
var port; |
|
18 |
var loaded = false; |
|
19 |
var scripts_awaiting = []; |
|
20 |
var nonce; |
|
17 |
let policy_received_callback; |
|
18 |
/* Snapshot url early because document.URL can be changed by other code. */ |
|
19 |
let url; |
|
20 |
let port; |
|
21 |
let loaded = false; |
|
22 |
let scripts_awaiting = []; |
|
23 |
let nonce; |
|
21 | 24 |
|
22 | 25 |
function handle_message(message) |
23 | 26 |
{ |
... | ... | |
31 | 34 |
scripts_awaiting.push(script_text); |
32 | 35 |
} |
33 | 36 |
} |
34 |
if (action === "settings") |
|
37 |
if (action === "settings") {
|
|
35 | 38 |
report_settings(data); |
39 |
policy_received_callback({url, allow: !!data[1] && data[1].allow}); |
|
40 |
} |
|
36 | 41 |
} |
37 | 42 |
|
38 | 43 |
function document_loaded(event) |
... | ... | |
56 | 61 |
report_script(script_text); |
57 | 62 |
} |
58 | 63 |
|
59 |
function handle_page_actions(script_nonce) { |
|
64 |
function handle_page_actions(script_nonce, policy_received_cb) { |
|
65 |
policy_received_callback = policy_received_cb; |
|
66 |
url = document.URL; |
|
67 |
|
|
60 | 68 |
document.addEventListener("DOMContentLoaded", document_loaded); |
61 | 69 |
port = browser.runtime.connect({name : CONNECTION_TYPE.PAGE_ACTIONS}); |
62 | 70 |
port.onMessage.addListener(handle_message); |
63 |
port.postMessage({url: document.URL});
|
|
71 |
port.postMessage({url}); |
|
64 | 72 |
|
65 | 73 |
nonce = script_nonce; |
66 | 74 |
} |
Also available in: Unified diff
enable whitelisting of `file://' protocol\n\nThis commit additionally also changes the semantics of triple asterisk wildcard in URL path.