aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjahoti <jahoti@tilde.team>2021-07-11 00:00:00 +0000
committerjahoti <jahoti@tilde.team>2021-07-11 00:00:00 +0000
commit0e002513d443ef7cddcc17acf178478844f609e9 (patch)
treefc3e6065474044a060202435d85c1b7d63460271
parent229e86f6086f90f5c132b4a11e5922de899dbb21 (diff)
downloadbrowser-extension-0e002513d443ef7cddcc17acf178478844f609e9.tar.gz
browser-extension-0e002513d443ef7cddcc17acf178478844f609e9.zip
Remove redundant nonce-based filtering in the script suppressor
-rw-r--r--content/freezer.js24
-rw-r--r--content/main.js6
2 files changed, 13 insertions, 17 deletions
diff --git a/content/freezer.js b/content/freezer.js
index 1696f53..8e543a6 100644
--- a/content/freezer.js
+++ b/content/freezer.js
@@ -43,23 +43,21 @@ function sanitize_attributes(element) {
element._frozen = true;
}
-function script_suppressor(nonce) {
- const blockExecute = e => {
- if (document.readyState === 'complete') {
- removeEventListener('beforescriptexecute', blockExecute, true);
- return;
- }
- else if (e.isTrusted && e.target.getAttribute('nonce') !== nonce) { // Prevent blocking of injected scripts
- e.preventDefault();
- console.log('Suppressed script', e.target);
- }
- };
- return blockExecute;
+function mozilla_suppress_scripts(e) {
+ if (document.readyState === 'complete') {
+ removeEventListener('beforescriptexecute', blockExecute, true);
+ console.log('Script suppressor has detached.');
+ return;
+ }
+ else if (e.isTrusted) { // Prevent blocking of injected scripts
+ e.preventDefault();
+ console.log('Suppressed script', e.target);
+ }
};
/*
* EXPORTS_START
- * EXPORT script_suppressor
+ * EXPORT mozilla_suppress_scripts
* EXPORT sanitize_attributes
* EXPORTS_END
*/
diff --git a/content/main.js b/content/main.js
index 5d88a6d..9acf749 100644
--- a/content/main.js
+++ b/content/main.js
@@ -14,7 +14,7 @@
* IMPORT csp_rule
* IMPORT is_privileged_url
* IMPORT sanitize_attributes
- * IMPORT script_suppressor
+ * IMPORT mozilla_suppress_scripts
* IMPORT is_chrome
* IMPORT is_mozilla
* IMPORT start_activity_info_server
@@ -35,8 +35,6 @@
let url = url_item(document.URL);
let unique = gen_unique(url);
-const suppressor = script_suppressor(unique);
-
function is_http()
{
@@ -144,6 +142,6 @@ if (!is_privileged_url(document.URL)) {
}
if (is_mozilla)
- addEventListener('beforescriptexecute', suppressor, true);
+ addEventListener('beforescriptexecute', mozilla_suppress_scripts, true);
}
}