-
-
Save elbywan/5138c9f3bbafa3f5826186e022beadae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assume that this code is executed inside the mutation observer callback: | |
addedNodes.forEach(node => { | |
// See above for script tag checks… | |
node.type = 'javascript/blocked' | |
// Firefox has this additional event which prevents scripts from beeing executed | |
const beforeScriptExecuteListener = function (event) { | |
// Prevent only marked scripts from executing | |
if(node.getAttribute('type') === 'javascript/blocked') | |
event.preventDefault() | |
node.removeEventListener('beforescriptexecute', beforeScriptExecuteListener) | |
} | |
node.addEventListener('beforescriptexecute', beforeScriptExecuteListener) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment