skip to Main Content

Anti-Adblock-Killer Guide to fight Anti-Adblock

Anti-Adblock Introdution

If you use an Adblock technology like uBlock, you sometimes see an Anti-Adblock technology on a website that blocks you from accessing the website content. A famous example recently is forbes.com. I will use a website as an example to show how you can defeat that by creating a custom whitelist rule that will fight the Anti-Adblock but still disable the Advertisements and Tracking. You can call it an Anti-Anti-Adblock or Anti-Adblock-Killer.

Create an Anti-Adblock-Killer for an example website

The example website for this tutorial is sc2casts.com that shows a nag screen. When you open the website with Adblock enabled, you receive a message like this:

Anti-Adblock Nag Screen

Open the developer tools (by pressing F12 on Windows for Chrome), click the magnifier to inspect the element and click on the dialog that shows the Anti-Adblock message.

Anti-Adblock Nag Screen Div

The sourcecode shows the div that displays this message. The name indicates that the div id is random, refreshing the page and inspecting the div again proofs that. Therefore a black or white-listing based on the div id would not work. Now search for the id of the div in the code by pressing Ctrl+F. One of the matches is:

Anti-Adblock Nag Screen JavaScript

As you can see by the code and name of the canRunAds variable, it is used to determine if the user can show Ads or uses an Adblocker. Searching for canRunAds reveals no code location that sets it, therefore it must be set by an external script (If the code to set it is not obfuscated of course). Open the Network tab of the developer tools and refresh the page. You will now see all network requests that got blocked by the Adblocker marked red.

Anti-Adblock Network View Developer Tools

Right click on each of the blocked scripts and select Open in new tab. The url http://sc2casts.com/tt/banner_ads.js reveals an interesting script:

var canRunAds = true;

Now all we need to do is whitelist this specific url in uBlock. Open the uBlock settings, select My rules, click Edit below Temporary rules and insert a new line:

sc2casts.com http://sc2casts.com/tt/banner_ads.js script allow

Save the whitelist rules, refresh the website and voila the nag screen is gone and shows no Ads.

Update the Anti-Adblock-Killer

Update 2015-08-2: The website Anti-Adblock code changed and the solution above does not work anymore. A look into the code of the website reveals the new added JavaScript code:

var script = document.createElement('script');
    console.log("1");
    script.onerror = function(){
        script.onerror = null;
        document.body.removeChild(script);
        document.getElementById("OOXGW").style.display="";
        _gaq.push(['_trackEvent', 'adblock popup', "show popup", document.location+""]);
    }
    script.src = "http://pagead2.googlesyndication.com/pagead/js/r20150723/r20150728/show_ads_impl.js";
    document.body.appendChild(script);
</script>

This code uses the window.onerror function to catch failed http request which in our case is the blocked the Ad script. In the source code of the nag screen you can see that is uses the css class headline. If you search for it in the html you will see that it is only used in the nag screen. That allows us to use that class to find the nag screen with a jquery selector and from there to traverse up the DOM tree to find the main div of the nag screen that has a random id. Install Tampermonkey for Chrome or Greasemonkey for Firefox and add a new user script with the following content:

// ==UserScript==
// @name         sc2casts.com Anti-Adblock Killer
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js
// @namespace    http://www.codejuggle.dj/
// @version      1.0
// @description  Removes the nag screen on http://sc2casts.com/ when using an ad-blocker
// @author       CornelK
// @match        http://sc2casts.com/*
// @grant        none
// ==/UserScript==

var script = document.createElement('script');
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(script);

$('.headline').parent().parent().parent().remove();

Refresh the site and voila, the nag screen is gone again (for now).

This Post Has 26 Comments
  1. I've read some of the comments and I'm kind of disappointed because ads are part of a marketing strategy and marketing is not illegal in any country from what I know. It is true, some advertising spaces are annoying, doesn't fit with the page/content where are displayed - and those are good ads... bad ones are click-jacking type , hidden ad-spaces and worst ones are pop-up windows which are used dramatically wrong and abusive. McDonalds is bad too...let's block/close McDonalds.
    Some of you have no idea what advertising is and how to use it and that's one of the reason which makes ads bad for some.
    I like a good advertising space and I even enjoy looking / interacting with that particular advertising space if it interests me, if not, I simply move on.
    As adult-orientated web-designer I work with animated images (gif image format) and they too are blocked by add-blocker programs...
    Bottom line, adds will exist forever even if adblocker is active/installed/used or not... furthermore the new concepts and web design technologies are evolving fast and, for example now anyone can design, build and code interactive ads with CSS and HTML... a work around to classic animated images which are blocked.

      1. Disqus autometically truncating the full text of your comment. could you please repost the above comment again?

  2. ad income is a huge motivation for content creators. I don't like ads either, but the more people block ads, less quality content we will read.

    1. Nonsense. It's the internet. There's crap content regardless of ads. Ad rape isn't going to last...traffic will vote by x-ing out and traffic will evaporate. We are not interested in ads. Period.

      1. If you want quality content, why don't you visit libraries. Takes too much time? If you hit the google search button you accept the fact you will see ads. Just like buying a printed newspaper.. Unlike the printed newspapers, websites provide content for free.

        1. BS, if I like your site enough, I might donate to it's running costs, but if you are trying to FORCE me to read your stupid ads, it's not going to happen. I'll just look elsewhere. That is the way of the world.

    2. They should find some other venue of income, as I'm not going to stop blocking ads even if made someone starve. And starving they can avert by other means, and not leeching.

      1. what do you do when you watch a F1 race, or olympics? how do you get rid of ads? you can't. You can not, because large corporations can afford to put their ads on those events. They even put their ads on movies. Movies which you pay to watch. This is not disturbing you, but a humble web content creator's ad is irritating you ha?

  3. what are you going to do if you want to run your own business? Stick your head in the sand and wait for people to hear what you're doing and expect them to make business with you? How are you planning to survive? Ads are parts of our lives.
    What do you do when you walk on the street? close your eyes not to see the ads around? You just ignore them... do the same on the internet and stop crying about it.

      1. hahahha I knew that one's coming. When people got nothing to say, they use the F word.

        1. I've got plenty to say. But it's more fun to punctuate it with go fuck yourself. Besides, it's not my fault you douchebag marketing spammers don't understand how to market anything without being the most obnoxious dipshits on the planet. No wonder you all have to resort to this sort of thing. You don't have a clue about effective marketing. That's why you're broke.

          1. Kara, you seriously need proper love treatment from a real man. Unfortunately, I live far away.

    1. LMAO. I do run a website and on said site, we have open donations. Users actually like us enough to pay our running costs by donating. If you have a good reputation, you don't need ads. If you have much larger costs, have some form of premium membership. Give people something back for their money, but forcing people to view ads, or whining about what they would do if they had a site isn't going to make us feel any better about ads. Today, I visited a site, decent content and about 20 fucking ads, share on facebook popup and a whole slew of other trash. BTW, I had disabled my adblocker and was so overwhelmed with this trash that it slowed my browser right down lol. Last time I disable my adblock lol.

      1. what do you do when you walk outside? close your eyes not to see the ads around? what do you do when you watch F1 or Nascar? turn adblock on? ohh yess I am not a big corporation, I've got a humble website which has 3 adsense units and that's your biggest problem ohh I see...

        1. I'm a graphic designer. I create ads for people. 😛 I look at ads outside because I chose to look at interesting campaigns. I choose not to look at people's ugly ads online. :3 Oh and i don't care about your website. I don't know what it is, and probably would never stumble on it in the vast expanse of the internet.

          1. you avoid answering my question lol. don't give me BS, we both know you look and see those ads outside and you can't do shit about it lol.

          2. you still didn't answer my question. What do you do when you see ads outside? You stay at home? You refuse to go outside?

  4. What do you do when walking on the street? Unless you live in antartica, you probably see hundreds of them outside. The government, municipality, agencies charge for ads and companies sell their products that's how you get social services, roads, electric, safety services, etc.. that's an ecosystem of today's living.

    Serious, quality websites doesn't put too much ads. If that's their only way of making money, then I am totally fine with it. I hate shit quality content more than ads.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top