Skip to content

Instantly share code, notes, and snippets.

@Xanir Xanir/frameBuster.js
Last active Jan 4, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.