Created
May 24, 2019 22:51
-
-
Save techmuzz/26f724d5c6dbada3dab57837103a3f11 to your computer and use it in GitHub Desktop.
Simple Way To Block AdBlocker For WordPress Without Plugin - https://www.techmuzz.com/how-to/wordpress/simple-way-to-block-adblocker-for-wordpress-without-plugin/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = function(){ | |
setTimeout(function() { | |
var ad = document.querySelector("ins.adsbygoogle"); | |
if (ad && ad.innerHTML.replace(/\s/g, "").length == 0) { | |
alert("Please don't use Ad blocker on this site."); | |
var x = document.createElement("IMG"); | |
x.setAttribute("src", "https://www.techmuzz.com/wp-content/uploads/2018/12/stop-ad-blockers.png"); | |
x.setAttribute("width", "750"); | |
x.setAttribute("height", "415"); | |
x.setAttribute("alt", "Please don't use Ad blocker for this site."); | |
document.querySelectorAll("article").forEach(function(e) { | |
e.parentElement.appendChild(x); | |
e.remove(); | |
}); | |
} | |
}, 2000); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment