Google Adsense Conflict
Hey there,
after removing google Adsense it still conflicts.
Domain: Mr-Dialect.com
Script:
<script id="ads-cleaner">
document.addEventListener("DOMContentLoaded", function () {
const adSelector = 'ins.adsbygoogle';
const adScriptContent = '(adsbygoogle = window.adsbygoogle || []).push({});';
function removeGoogleAdsElements() {
document.querySelectorAll(adSelector).forEach(el => el.remove());
}
function removeGoogleAdsScripts() {
document.querySelectorAll('script').forEach(script => {
if (script.innerHTML.includes(adScriptContent)) {
script.remove();
}
});
}
function adsCompletelyRemoved() {
const adsStillExist = document.querySelector(adSelector) !== null;
const scriptsStillExist = Array.from(document.querySelectorAll('script')).some(script =>
script.innerHTML.includes(adScriptContent)
);
return !adsStillExist && !scriptsStillExist;
}
function removeThisScript() {
const self = document.getElementById('ads-cleaner');
if (self) self.remove();
}
function insertGrowScript() {
const script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.setAttribute('data-noptimize', '1');
script.setAttribute('data-cfasync', 'false');
script.src = '//scripts.scriptwrapper.com/tags/11c5e….6c53c2.js';
document.head.appendChild(script);
}
// Initial Cleanup
removeGoogleAdsElements();
removeGoogleAdsScripts();
const observer = new MutationObserver(() => {
removeGoogleAdsElements();
removeGoogleAdsScripts();
if (adsCompletelyRemoved()) {
observer.disconnect(); // Stop monitoring
removeThisScript(); // Remove this script
insertGrowScript(); // Add grow script
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
// Fallback timeout
setTimeout(() => {
removeGoogleAdsElements();
removeGoogleAdsScripts();
if (adsCompletelyRemoved()) {
observer.disconnect();
removeThisScript();
insertGrowScript();
}
}, 3000);
});
</script>
What else can I do, I have static ad-placeholders on more than 5000 sites…therfore I have to remove it dynamically by script.
Greetings Vincent
-
Hi Vincent Weis , Our system will look for every instance of other ads script on your site and will not place our script unless there are no instances in the source, so using a script to remove the placed ads will not work. You will need to actually remove the instances of the AdSense code from your page source.
0
Journey is Self Supported
Please sign in to leave a comment.
Comments
1 comment