Using javascript to kill anti-ad-blockers

The ad wars

You pull up your go-to time waster site at work, and get assaulted with this.

Your morals cause a moment of hesitation, and you consider disabling your ad-blocker.

Your morals are wrong.

If you’re using Chrome, open the Developer Tools, and choose the Elements tab.

In the upper left corner, click on the little arrow icon.

When you do, you’ll be able to click on the elements you want to delete.

This is the one we want to delete first.

This is the second one.

You can manually delete these, but you’re just a little bit better than that.

Developer tools comes with another feature, the javascript console. We’ll use that for the next step.

Paste the following into the the console after the >.

var element = document.getElementById("div_iframe_overlay");element.outerHTML = "";var element = document.getElementById("lightbox");element.outerHTML = "";

Now looky der, it’s all cleared up.

You can manually paste that in every time, but you’re just a little bit better than that.

You’re going to build a bookmarklet.

This site gives some nice tips on how to build them.

In Chrome, go to your bookmark manager, click Organize at the top, and choose Add Page.

Name it whatever you want, and paste the following into the URL section.

javascript:(function(){ var element = document.getElementById("div_iframe_overlay");element.outerHTML = "";var element = document.getElementById("lightbox");element.outerHTML = "";})();

It creates an anonymous javascript function, that can be run from your url bar when you load the site.

Navigate to your anti-ad-block site, and when it loads again, go to your url bar and load your bookmarklet.

Hit enter.

Success.

Now you can slack off in peace.

The best way to do it is with a custom Chrome extension. You can probably even make some money from it.

But that is for another day.

Thanks.