Skip to content

Instantly share code, notes, and snippets.

@rodmcnew
Last active March 2, 2022 23:07
Show Gist options
  • Save rodmcnew/fe5489c9e3081300444c400e6c60bbfa to your computer and use it in GitHub Desktop.
Save rodmcnew/fe5489c9e3081300444c400e6c60bbfa to your computer and use it in GitHub Desktop.
This is a bookmarklet that removes all iframes from the current page. Paste its code into a bookmark URL field. Click the bookmark to remove all iframes. Once started, it also removes newly spawned iframes every 100ms.
javascript:void(function(){setInterval(function(){document.querySelectorAll('iframe').forEach(function(element){console.log('Iframe Killa - Removing Element:', element);element.parentNode.removeChild(element)})},100)}());
@rodmcnew
Copy link
Author

@dnmTX
Here is a version that runs once only when clicked:

javascript:void(function(){document.querySelectorAll('iframe').forEach(function(element){console.log('Iframe Killa - Removing Element:', element);element.parentNode.removeChild(element)})}());

UserScript and website excludes: Could be interesting. Good luck if someone tries. Similar things may already exist somewhere.

@dnmTX
Copy link

dnmTX commented Jun 16, 2021

Rod @rodmcnew,with a slight delay i'm back to thank you. The truth is i ended up using your first creation due to stubborn websites like
amazon.com,imdb.com and whatnot respawning those f*ckers all the time πŸ˜„
The UserScript actually is coming up nicely,i'm in the final stages but banging my head here how to implement to check first if the page has any iframes at all and if not to quit altogether. For example,this is telling me if there are any or there aren't:
(function() { if (document.querySelector('iframe') == null) console.log("no iframes"); else console.log("iframes exist");}
You mind providing some assistance,anything will be greatly appreciated. If you want i can paste here what i got so far.
Either way,big THANK YOU πŸ‘ Your code is working great πŸ˜‰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment