Last active
January 4, 2019 04:36
-
-
Save Xanir/9d72519c0d6cf756083f60790b1bb9b2 to your computer and use it in GitHub Desktop.
Strip / Prevent IFrames
This file contains hidden or 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
if (!window.iframeBuster) { | |
var append = window.document.append; | |
window.document.append = function(node) { | |
if (node instanceof HTMLIFrameElement) { | |
console.log('blocked addition of iframe via append') | |
} else { | |
append.apply(apply, node); | |
} | |
}; | |
var appendChild = window.document.appendChild; | |
window.document.appendChild = function(node) { | |
if (node instanceof HTMLIFrameElement) { | |
console.log('blocked addition of iframe via appendChild') | |
} else { | |
appendChild.apply(apply, node); | |
} | |
}; | |
existingFrames = window.document.querySelectorAll('iframe'); | |
existingFrames.forEach(i => i.remove()); | |
consle.log('striped frames from page: ' + existingFrames.length) | |
window.iframeBuster = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment