Revision 0e002513
Added by jahoti about 2 years ago
| content/freezer.js | ||
|---|---|---|
| 43 | 43 |
element._frozen = true; |
| 44 | 44 |
} |
| 45 | 45 |
|
| 46 |
function script_suppressor(nonce) {
|
|
| 47 |
const blockExecute = e => {
|
|
| 48 |
if (document.readyState === 'complete') {
|
|
| 49 |
removeEventListener('beforescriptexecute', blockExecute, true);
|
|
| 50 |
return; |
|
| 51 |
} |
|
| 52 |
else if (e.isTrusted && e.target.getAttribute('nonce') !== nonce) { // Prevent blocking of injected scripts
|
|
| 53 |
e.preventDefault(); |
|
| 54 |
console.log('Suppressed script', e.target);
|
|
| 55 |
} |
|
| 56 |
}; |
|
| 57 |
return blockExecute; |
|
| 46 |
function mozilla_suppress_scripts(e) {
|
|
| 47 |
if (document.readyState === 'complete') {
|
|
| 48 |
removeEventListener('beforescriptexecute', blockExecute, true);
|
|
| 49 |
console.log('Script suppressor has detached.');
|
|
| 50 |
return; |
|
| 51 |
} |
|
| 52 |
else if (e.isTrusted) { // Prevent blocking of injected scripts
|
|
| 53 |
e.preventDefault(); |
|
| 54 |
console.log('Suppressed script', e.target);
|
|
| 55 |
} |
|
| 58 | 56 |
}; |
| 59 | 57 |
|
| 60 | 58 |
/* |
| 61 | 59 |
* EXPORTS_START |
| 62 |
* EXPORT script_suppressor
|
|
| 60 |
* EXPORT mozilla_suppress_scripts
|
|
| 63 | 61 |
* EXPORT sanitize_attributes |
| 64 | 62 |
* EXPORTS_END |
| 65 | 63 |
*/ |
| content/main.js | ||
|---|---|---|
| 14 | 14 |
* IMPORT csp_rule |
| 15 | 15 |
* IMPORT is_privileged_url |
| 16 | 16 |
* IMPORT sanitize_attributes |
| 17 |
* IMPORT script_suppressor
|
|
| 17 |
* IMPORT mozilla_suppress_scripts
|
|
| 18 | 18 |
* IMPORT is_chrome |
| 19 | 19 |
* IMPORT is_mozilla |
| 20 | 20 |
* IMPORT start_activity_info_server |
| ... | ... | |
| 35 | 35 |
let url = url_item(document.URL); |
| 36 | 36 |
let unique = gen_unique(url); |
| 37 | 37 |
|
| 38 |
const suppressor = script_suppressor(unique); |
|
| 39 |
|
|
| 40 | 38 |
|
| 41 | 39 |
function is_http() |
| 42 | 40 |
{
|
| ... | ... | |
| 144 | 142 |
} |
| 145 | 143 |
|
| 146 | 144 |
if (is_mozilla) |
| 147 |
addEventListener('beforescriptexecute', suppressor, true);
|
|
| 145 |
addEventListener('beforescriptexecute', mozilla_suppress_scripts, true);
|
|
| 148 | 146 |
} |
| 149 | 147 |
} |
Also available in: Unified diff
Remove redundant nonce-based filtering in the script suppressor