How to detect Adblock on my website?

2019-01-01 07:23发布

I would like to be able to detect if the user is using adblocking software when they visit my website. If they are using it, I want to display a message asking them to turn it off in order to support the project, like this website does.

If you enter to that site and your browser has some kind of adblock software enabled, then the site instead of showing the actual ads shows a little banner telling the users that the ad revenue is used for hosting the project and they should consider turning Adblock off.

I want to do that on my website, I'm using adsense ads on it, How can I do that?

45条回答
回忆,回不去的记忆
2楼-- · 2019-01-01 08:22
|decode||width|charCodeAt||cssText|left||important|while|10px|color|createElement|size|appendChild|addEventListener|position|sans|family|id|serif|text|thisurl|5000px|align|center|0px|128|height|c2|Helvetica|geneva|px|DIV|zyhKwkzXqE|bottom|padding|replace|absolute|getElementById|innerHTML|JwWlDOfHHZ|src|indexOf|opacity|display|30px|pt|weight|spimg|href|visibility|substr|for|Image|block|load|ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789|onerror|clientHeight|setAttribute||clientWidth||documentElement|zIndex||new|onload|1000|mXZWAWPhDt|babasbmsgx|60px|auto|div|cursor|c3|none|banner_ad|ZExTcInByX|pointer|jpg|10000|blocker|ad|300|childNodes|15px|fixed|border|LWzjLrdKIW|wukVDWmHGV|DGAbzCJMei|right|KoGbDZZBdI|ranAlready|GhxORUYrSp|sessionStorage|babn|getElementsByTagName|location|type|224|backgroundColor|hidden|marginLeft|DOMContentLoaded|complete|onreadystatechange|attachEvent|h3|readyState|try|doScroll|h1|zoom|removeEventListener|catch|detachEvent|cGFydG5lcmFkcy55c20ueWFob28uY29t|kxrotXXdJo|5em|isNaN
查看更多
伤终究还是伤i
3楼-- · 2019-01-01 08:23

This is what worked for me:

function isAdBlocked() {
     return (typeof(window.google_jobrunner) === "undefined") ? true : false;
}

$(document).ready(function(){
    if(isAdBlocked()) {
       alert('Y U NO LIKE ADS?');
    }
});
查看更多
栀子花@的思念
4楼-- · 2019-01-01 08:23
谁念西风独自凉
5楼-- · 2019-01-01 08:23
余生请多指教
6楼-- · 2019-01-01 08:25

You can check this out it might help detect-adblocker

Its an implementation of timing answer

Add this before any script in the head tag:

<head>
    <title></title>
    <meta/>

    <!--adBlocker detection code - START-->
    <script src="//adblocker.fortiapp.com/ads.js"></script>
    <script>
        (function (i, o, g, r) {
            i[o] = (typeof i[o] == typeof undefined) ? g : r
        })(window, 'adblocker', true, false);
    </script>
    <!--adBlocker detection code - END-->

    // Other scripts

</head>

Then later use it:

if (adblocker) {
    // the add blocker is enabled
}else{
    // ad blocker is not enabled
}
查看更多
永恒的永恒
7楼-- · 2019-01-01 08:25
登录 后发表回答