Seegatesite will share an article about how to install anti adblock plugin or adblock killer on wordpress site. Using the anti adblock plugin is form of rejection from adblock addon on browsers that reduce advertising revenues from website, where the ads used as lives a website. I get the anti adblock script from various reliable sources, and can function well for WordPress site.
I personally use adblock plus addon, although I didn’t support any ad-blocking activity. I use adblock because too many sites use the annoying ads such as pop-up ads, animated ads that heavy burden the CPU and spend our internet bandwidth.
Many of bloggers who began to fret with the existence of adblock plus, many people ask me, “How do I install anti adblock plugin ? “, “What is the best anti adblock adsense? ” And some even ask “How to create anti adblock script for bloggers? “. Frankly, I myself never use anti adblock script for my site. An outline, the purpose of adblock killer plugin can be good or bad for your site. Using anti adblock plugin can reduce your visitors.
Table of Contents
How Does Anti Adblock Plugin Work
Anti Adblock plugin created with javascript where the js detect the existence of adblock plus addon the browser. Anti adblock plugin has the following functions
– Users install / activate the Adblock extension in the browser
– Users Enable Javascript on the site
– Users install / activate Anti Adblock extension Killer in browser
How to create anti adblock plugin for wordpress
Previously I thank to http://www.arlinadzgn.com/ who share how to create anti adblock script for blogger. From this source i try to implement anti adblock code to wordpress site in some methods.
#1. Installation Anti Adblock script from wordpress’s widget and blogger’s widget
1. Copy this code below to your widget menu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | <style type='text/css'> #h237 { position: fixed !important; position: absolute; top: 0; top: expression((t=document.documentElement.scrollTop?document.documentElement.scrollTop: document.body.scrollTop)+"px"); left: 0; width: 102%; height: 102%; background-color: #000000; opacity: .99; display: block; padding: 7% 0; bottom: 0; right: 0; z-index: 9999!important; } #h237 * { text-align: center; margin: 0 auto; display: block; font: bold 14px Verdana, Arial, sans-serif; text-decoration: none } #h237 * a { padding: 12px 15px!important; background-color: #f77c6a; color: #fff!important; font-weight: 700; font-size: 14px; font-family: 'Open Sans', sans-serif; text-align: center; text-transform: uppercase; letter-spacing: 0.5px; border-radius: 3px; display: block; margin: 15px auto; clear: both; width: 20%; transition: all 0.3s ease-out; } #h237 * a:hover { opacity: .9; } #h237 ~ * { display: none } </style> <div id="h237"> <span>Please enable javascript!</span></div> <script> window.document.getElementById("h237").parentNode.removeChild(window.document.getElementById("h237")); (function(l, m) { function n(a) { a && h237.nextFunction() } var h = l.document, p = ["i", "s", "u"]; n.prototype = { rand: function(a) { return Math.floor(Math.random() * a) }, getElementBy: function(a, b) { return a ? h.getElementById(a) : h.getElementsByTagName(b) }, getStyle: function(a) { var b = h.defaultView; return b && b.getComputedStyle ? b.getComputedStyle(a, null) : a.currentStyle }, deferExecution: function(a) { setTimeout(a, 250) }, insert: function(a, b) { var e = h.createElement("span"), d = h.body, c = d.childNodes.length, g = d.style, f = 0, k = 0; if ("h237" == b) { e.setAttribute("id", b); g.margin = g.padding = 0; g.height = "100%"; for (c = this.rand(c); f < c; f++) 1 == d.childNodes[f].nodeType && (k = Math.max(k, parseFloat(this.getStyle(d.childNodes[f]).zIndex) || 0)); k && (e.style.zIndex = k + 1); c++ } e.innerHTML = a; d.insertBefore(e, d.childNodes[c - 1]) }, displayMessage: function(a) { var b = this; a = "abisuq".charAt(b.rand(5)); b.insert("<" + a + '> <h3 style="color:#ffffff">Please disable ad-blocker to view this page</h3> <a href="JavaScript:window.location.reload()">Reload</a>' + ("</" + a + ">"), "h237"); h.addEventListener && b.deferExecution(function() { b.getElementBy("h237").addEventListener("DOMNodeRemoved", function() { b.displayMessage() }, !1) }) }, i: function() { for (var a = "DivTopAd,ad-zone-1,ad_190x90,ads-sticky,iqadtile5,leftframeAD,tobsideAd,ad,ads,adsense".split(","), b = a.length, e = "", d = this, c = 0, g = "abisuq".charAt(d.rand(5)); c < b; c++) d.getElementBy(a[c]) || (e += "<" + g + ' id="' + a[c] + '"></' + g + ">"); d.insert(e); d.deferExecution(function() { for (c = 0; c < b; c++) if (null == d.getElementBy(a[c]).offsetParent || "none" == d.getStyle(d.getElementBy(a[c])).display) return d.displayMessage("#" + a[c] + "(" + c + ")"); d.nextFunction() }) }, s: function() { var a = { 'pagead2.googlesyndic': 'google_ad_client', 'js.adscale.de/getads': 'adscale_slot_id', 'get.mirando.de/miran': 'adPlaceId' }, b = this, e = b.getElementBy(0, "script"), d = e.length - 1, c, g, f, k; h.write = null; for (h.writeln = null; 0 <= d; --d) if (c = e[d].src.substr(7, 20), a[c] !== m) { f = h.createElement("script"); f.type = "text/javascript"; f.src = e[d].src; g = a[c]; l[g] = m; f.onload = f.onreadystatechange = function() { k = this; l[g] !== m || k.readyState && "loaded" !== k.readyState && "complete" !== k.readyState || (l[g] = f.onload = f.onreadystatechange = null, e[0].parentNode.removeChild(f)) }; e[0].parentNode.insertBefore(f, e[0]); b.deferExecution(function() { if (l[g] === m) return b.displayMessage(f.src); b.nextFunction() }); return } b.nextFunction() }, u: function() { var a = "ad&adv_keywords=,-page-peel/,/adchain.,/adfootright.,/adsxml/ad,/adyard300.,/impopup/ad,/loadadsparam.,/meme_ad.,_adshare.".split(","), b = this, e = b.getElementBy(0, "img"), d, c; e[0] !== m && e[0].src !== m && (d = new Image, d.onload = function() { c = this; c.onload = null; c.onerror = function() { p = null; b.displayMessage(c.src) }; c.src = e[0].src + "#" + a.join("") }, d.src = e[0].src); b.deferExecution(function() { b.nextFunction() }) }, nextFunction: function() { var a = p[0]; a !== m && (p.shift(), this[a]()) } }; l.h237 = h237 = new n; h.addEventListener ? l.addEventListener("load", n, !1) : l.attachEvent("onload", n) })(window); </script> |
2. Save and refresh your browser to see the result
#2. Create Anti Adblock plugin wordpress
1. Create a new folder on your plugin directory as sgt_anti_adblock
2. Create new php file as sgt_anti_adblock.php and copy this code below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <?php /** * Plugin Name: Anti adblock shield * Plugin URI: https://seegatesite.com * Description: This plugin allow you block the content when users use adblock or anti adblock killer on browser * Version: 1.0.0 * Author: Sigit Prasetya Nugroho * Author URI: https://seegatesite.com * License: GPL2 */ function sgt_anti_adblock_plugin() { echo ' <div id="h237"> <span>Please enable javascript!</span></div> '; } add_action( 'wp_footer', 'sgt_anti_adblock_plugin' ); function sgt_anti_adblock_script() { wp_register_style( 'sgt_anti_adblock_css', plugins_url('sgt_anti_adblock.css', __FILE__),array() ); wp_enqueue_style( 'sgt_anti_adblock_css' ); wp_register_script( 'sgt_anti_adblock_js', plugins_url('sgt_anti_adblock.js',__FILE__ ),array(),'1.0.0', true ); wp_enqueue_script('sgt_anti_adblock_js'); } add_action( 'wp_enqueue_scripts', 'sgt_anti_adblock_script' ); |
2. Create new javascript file as sgt_anti_adblock.js and copy this script below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | window.document.getElementById("h237").parentNode.removeChild(window.document.getElementById("h237")); (function(l, m) { function n(a) { a && h237.nextFunction() } var h = l.document, p = ["i", "s", "u"]; n.prototype = { rand: function(a) { return Math.floor(Math.random() * a) }, getElementBy: function(a, b) { return a ? h.getElementById(a) : h.getElementsByTagName(b) }, getStyle: function(a) { var b = h.defaultView; return b && b.getComputedStyle ? b.getComputedStyle(a, null) : a.currentStyle }, deferExecution: function(a) { setTimeout(a, 250) }, insert: function(a, b) { var e = h.createElement("span"), d = h.body, c = d.childNodes.length, g = d.style, f = 0, k = 0; if ("h237" == b) { e.setAttribute("id", b); g.margin = g.padding = 0; g.height = "100%"; for (c = this.rand(c); f < c; f++) 1 == d.childNodes[f].nodeType && (k = Math.max(k, parseFloat(this.getStyle(d.childNodes[f]).zIndex) || 0)); k && (e.style.zIndex = k + 1); c++ } e.innerHTML = a; d.insertBefore(e, d.childNodes[c - 1]) }, displayMessage: function(a) { var b = this; a = "abisuq".charAt(b.rand(5)); b.insert("<" + a + '> <h3 style="color:#ffffff">Please disable ad-blocker to view this page</h3> <a href="JavaScript:window.location.reload()">Reload</a>' + ("</" + a + ">"), "h237"); h.addEventListener && b.deferExecution(function() { b.getElementBy("h237").addEventListener("DOMNodeRemoved", function() { b.displayMessage() }, !1) }) }, i: function() { for (var a = "DivTopAd,ad-zone-1,ad_190x90,ads-sticky,iqadtile5,leftframeAD,tobsideAd,ad,ads,adsense".split(","), b = a.length, e = "", d = this, c = 0, g = "abisuq".charAt(d.rand(5)); c < b; c++) d.getElementBy(a[c]) || (e += "<" + g + ' id="' + a[c] + '"></' + g + ">"); d.insert(e); d.deferExecution(function() { for (c = 0; c < b; c++) if (null == d.getElementBy(a[c]).offsetParent || "none" == d.getStyle(d.getElementBy(a[c])).display) return d.displayMessage("#" + a[c] + "(" + c + ")"); d.nextFunction() }) }, s: function() { var a = { 'pagead2.googlesyndic': 'google_ad_client', 'js.adscale.de/getads': 'adscale_slot_id', 'get.mirando.de/miran': 'adPlaceId' }, b = this, e = b.getElementBy(0, "script"), d = e.length - 1, c, g, f, k; h.write = null; for (h.writeln = null; 0 <= d; --d) if (c = e[d].src.substr(7, 20), a[c] !== m) { f = h.createElement("script"); f.type = "text/javascript"; f.src = e[d].src; g = a[c]; l[g] = m; f.onload = f.onreadystatechange = function() { k = this; l[g] !== m || k.readyState && "loaded" !== k.readyState && "complete" !== k.readyState || (l[g] = f.onload = f.onreadystatechange = null, e[0].parentNode.removeChild(f)) }; e[0].parentNode.insertBefore(f, e[0]); b.deferExecution(function() { if (l[g] === m) return b.displayMessage(f.src); b.nextFunction() }); return } b.nextFunction() }, u: function() { var a = "ad&adv_keywords=,-page-peel/,/adchain.,/adfootright.,/adsxml/ad,/adyard300.,/impopup/ad,/loadadsparam.,/meme_ad.,_adshare.".split(","), b = this, e = b.getElementBy(0, "img"), d, c; e[0] !== m && e[0].src !== m && (d = new Image, d.onload = function() { c = this; c.onload = null; c.onerror = function() { p = null; b.displayMessage(c.src) }; c.src = e[0].src + "#" + a.join("") }, d.src = e[0].src); b.deferExecution(function() { b.nextFunction() }) }, nextFunction: function() { var a = p[0]; a !== m && (p.shift(), this[a]()) } }; l.h237 = h237 = new n; h.addEventListener ? l.addEventListener("load", n, !1) : l.attachEvent("onload", n) })(window); |
3. Create new css file as sgt_anti_adblock.css and copy this css script below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #h237 { position: fixed !important; position: absolute; top: 0; top: expression((t=document.documentElement.scrollTop?document.documentElement.scrollTop: document.body.scrollTop)+"px"); left: 0; width: 102%; height: 102%; background-color: #000000; opacity: .99; display: block; padding: 7% 0; bottom: 0; right: 0; z-index: 9999!important; } #h237 * { text-align: center; margin: 0 auto; display: block; font: bold 14px Verdana, Arial, sans-serif; text-decoration: none } #h237 * a { padding: 12px 15px!important; background-color: #f77c6a; color: #fff!important; font-weight: 700; font-size: 14px; font-family: 'Open Sans', sans-serif; text-align: center; text-transform: uppercase; letter-spacing: 0.5px; border-radius: 3px; display: block; margin: 15px auto; clear: both; width: 20%; transition: all 0.3s ease-out; } #h237 * a:hover { opacity: .9; } #h237 ~ * { display: none } |
4. Active the sgt_anti_adblock plugin from plugin menu wordpress.
Voila, your anti adblock plugin is already to used. The anti adblock full script can be downloaded below
[sociallocker id=”58″]Sgt Anti Adblock[/sociallocker]
Conclusion :Â Anti adblock plugin not the best solution to fight adblock extension, create content that is good and useful to others then they will reply to you
This Script is for WordPress , but i want for blogger, & most of the scripts are working only on pc , so what to do for phone adblockers
i will update if i have these script 🙂
thats cool thanks but im not using wordperess is the code can be used on other web builders?
you can customize the code