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 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 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 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: 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');
    script.onerror = function(){
        script.onerror = null;
        _gaq.push(['_trackEvent', 'adblock popup', "show popup", document.location+""]);
    script.src = "";

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 Anti-Adblock Killer
// @require
// @namespace
// @version      1.0
// @description  Removes the nag screen on when using an ad-blocker
// @author       CornelK
// @match*
// @grant        none
// ==/UserScript==

var script = document.createElement('script');
script.src = "";


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

You may also like

  • Shlomi Laron

    have you seen this anti adblock?

    • Beside having a bold statement that they can bypass every Adblocker, I can not see or find any demo of it.

  • You are of course right, I fixed it 😉 Thanks.

  • 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.

  • John Cena
    • It uses the same method as shown in this tutorial. Add this to your ublock rules: script allow

      • AngryGoomba

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

        • You can right click on the URL and copy paste it.

  • Çağatay Belgen

    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.

    • 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.

      • Çağatay Belgen

        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.

        • Velvetsky

          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.

    • Anita Kai

      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.

      • Çağatay Belgen

        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?

        • Barkfin

          Who says I watch F1 or olympics?
          Because I don’t.

          • Çağatay Belgen

            Ok when you watch a movie and the good guy drives X brand sports car, or use Z brand mobile phone, or wear Y brand watch you think that’s a coincedence?

          • Barkfin

            Ok point taken.
            But there’s a reason why so many stores and brands are failing, it’s because, as people discover they are being psychologically manipulated, they take their business elsewhere.
            The principle you’re describing is called “superliminal” advertising, which is the opposite of subliminal.
            FOR EXAMPLE: here’s one I heard about the other day. The reason why (some) restaurants are so loud is they figured out that people eat quick and get out faster. They don’t care why that happens, but because it happens, their establishment has higher throughput & greater profitability. The fallout? I don’t go to such places any more. People like me will literally go somewhere else, I will watch different movies (or none, hows about that) to avoid being manipulated. I have choice, so guess what! I exercise it.
            I also choose to use ad-block for the very same reasons and not only that, I am not even contrite about it. Sites like Inquirer threaten to go out of business if they cannot deliver ads, that’s not my problem, I’ll just move to the next provider. YES it is theoretically possible for every single business person to go “on strike”, as if Atlas shrugged, but it will never, ever happen.

  • Çağatay Belgen

    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.

    • Fuck off. I use ad blocker.

      • Çağatay Belgen

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

        • 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.

          • Çağatay Belgen

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

    • Velvetsky

      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.

      • Çağatay Belgen

        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…

        • Velvetsky

          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.

          • Çağatay Belgen

            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.

          • Çağatay Belgen

            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?

  • Çağatay Belgen

    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.

    • Barkfin

      Your argument is fallacious.

  • Excellent, thanks for this.

  • ivan_

    Here is the thing. Ads are okay for me, and I’m sure they are for lots of people. I don’t like seeing them, but if it’s on the sides or top/bottom edges, fine so be it. The problem is when ads on popular websites become offensive to browsing. It’s the same issue we have on TV nowadays. Try and watch a sports game, they have breaks catered just to ads. I don’t mind seeing ads on the side panels, on the rink, as sponsors… but cutting out game time to show ads? On the internet we have the same problem, you now have ads that scroll along with the page (you have to scroll to get rid of the ad), and you have ads that make noise. They are forced. Sometimes the ads force you to watch it before you can navigate away. Worst of all, most ads slow down web browsing – they load some unnecessarily complex script onto your browser and bog it down, compared to some clever image or GIF that says everything that needs to be said.

    I’m fine with helping content creators out with ad revenue, but if it’s that much of a hassle to watch an ad I’m all for adblocking and ways to circumvent anti-adblock measures. The internet wasn’t always like this, and quality content was released before “offensive” ads were around. We should support content creators by disabling adblock for them (I do for my favourite YouTube channels + websites, for example), but also say no to creators that force “offensive” ads onto its audience.

    to clarify, by “offensive” I don’t mean “pornographic or vulgar”, but something that negatively impacts the overall browsing experience. not all ads are offensive, as we’ve seen in the past images that are harmless or loop a gif. now we have ads that are not only loud and obstructing of a web page’s content, but also are a security vulnerability by letting ads run scripts.