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

This Post Has 30 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. i agree with u completely. “Adblocking has become dilemma for publishers as they are facing issues in maintaining the revenue generated through advertising. Actually not all users find ads as annoying or waste of their time. Many advertisements are informative and have insightful knowledge with which users can get to know about new things. Internet users prefer unrestricted access to free, high quality content without ads. They love free content more than they hate ads. Blocking ads limits the ability of internet users to explore and get to know new things though they amenities the users to choose what to accept as users might filtered away with them.
      Adblockers are killing revenue stream of publishers. The great majority of publishers relies on ads for profiting revenue and has set dominant paradigm. Besides publishers hundreds of authors, bloggers, journalists, columnists, content creators, researchers and editors also get affected who earn from the online content industry by providing insightful ideas and knowledge.
      Hence, adblockers are needed to be squashed. We need to take firm action against them.
      Even I have faced adblocking issues. I had lost a good portion of ad revenues. Then I tried Adzsafe. It completely disables adblocker and supports my ads to load safely. I started earning revenues instantly and I got control over my ads. “

      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?

        1. Just saying that a person requiring participation in advertisement viewing to explore the content of the site – opposite of humble. “Humble: having or showing a modest or low estimate of one’s own importance” so if a content creator was humble, they wouldn’t seek payment or fame. Like has already been stated, the world will find another route than being forced to see ads against their will. Freedom of information is too embedded into our minds to pay to view or succumb to ads in trade of this information. It is cheapest tactic for a paycheck I have ever seen actually. CREATES WEBSITE>COPIES OR CREATES CONTENT>RESERVES SIDE BAR AND PROVIDES INITIAL-LOAD-ADVERTISEMENT/ADBLOCKER ALERT>PAID FOR REST OF LIFE. Look. We are lowly consumers. If we were all jumping on every advertisement, we’d be even more lowly. If we wanted to look at “what is on the market today” we would go to Kroger or Best Buy, or google for “hot new products worth dropping my money on” right? So if you are following so far, let me finally just mention how if one car wash charges 5$ and has free vacuum, people going there for free vacuum only. That is just human nature to save where possible. Time and money btw. So if a site has intrusive adverstisements and obfuscating popups, WE WILL FIND ANOTHER SITE WITHOUT IT. We don’t care if you wasted two clicks of our time at that point, the advertisements are simply ugly. This is a huge motion that never should have started. Mark my words: Police upgrade their security, thugs upgrade their crimes. We upgrade our adblockers, you upgrade your ad-block-detectors. Its a vicious cycle that we will never escape. ITS UP TO YOU if you want to rely on that insecure future as your income. Do not brag on a date that your income is from ad revenue, you will be followed home probably, and you know the rest.

  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?

    2. Just going to educate you here – the majority of words and colors you see as you drive – they are the signs to tell you what business you are approaching. They are required because we do not have alien intuition. “Mom, where is kroger? I need bread…” “Oh Billy, you know its the 46th red-brick building on the south side of Main St on the west side of James Dr” LMFAO come on mate. Trying to justify the existence of ads by getting confused about the world around you.

      The only people crying are those who can’t get a real job and rely on leeching off consumers like this for income. Suckas.

  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.

  5. Why do I recommend people view ads online? It brings me more business in removing viruses and assorted ad delivered malware. Why do I use an adblocker? So I don’t have to deal with malware, adware and ad delivered ransomeware. But what about outside advertisements? I wear a hat. It is easy to tilt my head and miss the adverts. Simply put, Ogden Nash explained it. “I think that I shall never see, a billboard lovely as a tree. But if the billboards should never fall, I think I’ll never see a tree at all.” Are ads important to web content providers as much as brick and mortar stores? Yes. Is the security of my customer’s computers and privacy important? Yes. Even more so today. See EU’s newest privacy laws. What is the solution? Advertisers and ad network providers need to clean up their act and seriously filter the ad content. Bandwidth included. What should content providers do? Outside of a Patreon account, force ad providers to stop the war of adblockers vs anti-adblockers by providing non-invasive and safe advertisements. Will they? Probably not until there is no longer any real free ad served/payed for content available and the Internet returns to nothing more that P2P BBS of the early PC days. So pick one. Clean up advertisements or kiss your content revenue generating malware serving
    ass goodbye.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top