Skip to content

Instantly share code, notes, and snippets.

@kbauer
Last active April 27, 2024 05:17
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save kbauer/b524f6475c153e759dc28314175cd6a7 to your computer and use it in GitHub Desktop.
Save kbauer/b524f6475c153e759dc28314175cd6a7 to your computer and use it in GitHub Desktop.
A simple adblocker bookmarklet, removing suspicious iframes. To install, copy-paste the source to a bookmark (will automatically remove newline characters). Extend the array ``exceptOrigins`` in order to create new exceptions. Careful: If bookmarklets get too long, they might stop working. This methods provides on-demand adblocking (as opposed t…
javascript:/* Adblock Simple */
(function(){
const exceptOrigins = [
'https://disqus.com',
document.origin
];
function remIF(e){
try{
var orgn = new URL(e.src || 'http://unknown-src').origin;
if( ! exceptOrigins.includes(orgn)){
e.parentElement.removeChild(e);
console.log('REMOVE IFRAME',orgn);
}
} catch(err) {
console.log('REMOVE ERROR',err);
}
}
function remIFs(){
for(var e of document.getElementsByTagName('iframe')){
remIF(e);
}
}
/* Must repeat to catch recurring frames. */
window.setInterval(remIFs,500);
})();
@cole-wilson
Copy link

Thank you!

@hackerpain
Copy link

this can have unintended effects, good luck using it

@joinithuXxxhhahahxxX
Copy link

javascript:var s=document.createElement('script');s.type='text/javascript';s.src='https://somecoolwebsite.github.io/js/wtfisitspin.js';document.body.appendChild(s);void(0);

@Mrtarleme
Copy link

this actually freakin worked lol

@twitchadblock2
Copy link

it doesnt work for twitch ads though which sucks

@twitchadblock2
Copy link

this actually freakin worked lol

does it work for twitch ads?

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