Skip to content

Instantly share code, notes, and snippets.

@Xanir
Last active January 4, 2019 04:36
Show Gist options
  • Save Xanir/9d72519c0d6cf756083f60790b1bb9b2 to your computer and use it in GitHub Desktop.
Save Xanir/9d72519c0d6cf756083f60790b1bb9b2 to your computer and use it in GitHub Desktop.
Strip / Prevent IFrames
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