MarcellPerger1 / adblock-bookmarklet

A bookmarklet to remove ads.
MIT License
6 stars 3 forks source link

Pop up redirects #46

Open bensmithgb53 opened 3 months ago

bensmithgb53 commented 3 months ago

Please please please get this to block pop up redirects. When I'm on let's say movie website like dopebox.to soon as you click somewhere on the website I get took to other tap that opens up. This is so annoying please if you could add this. Also could you get it so javascript stays running until you go off google. Here is what I have made so far and seem to work only for three small ads no redirects and it stays on even when you refresh the page which I like.

bensmithgb53 commented 3 months ago

Please please please get this to block pop up redirects. When I'm on let's say movie website like dopebox.to soon as you click somewhere on the website I get took to other tap that opens up. This is so annoying please if you could add this. Also could you get it so javascript stays running until you go off google. Here is what I have made so far and seem to work only for three small ads no redirects and it stays on even when you refresh the page which I like.

javascript:(function() { // Function to remove specific iframes function removeAds() { var iframes = document.querySelectorAll('iframe'); iframes.forEach(function(iframe) { var style = getComputedStyle(iframe); // Check for specific ad-like styles if (iframe.clientWidth > 0 && iframe.clientHeight > 0 && style.position === 'fixed' && style.display === 'block' && style.zIndex === '2147483647') { iframe.style.display = 'none'; // Hide the iframe } }); } // Function to close modal or popup with specific attributes function closeModal() { var closeButton = document.querySelector('div[data-dismiss="modal"][aria-label="Close"]'); if (closeButton) { closeButton.click(); // Simulate a click on the close button } } // Execute both functions after a short delay to ensure all content is loaded setTimeout(function() { removeAds(); // Remove specific iframes closeModal(); // Close the modal or popup }, 2000); // Adjust the delay (in milliseconds) as needed})();

MarcellPerger1 commented 3 months ago

I am unfortunately very busy at the moment, so I am unable to work on this right now.
Firefox has a nice feature where it automatically blocks popups and similar annoying stuff, so you could try that (it usually works well for me).

MarcellPerger1 commented 3 months ago

This runs my adblocker code very 0.3s: javascript:setTimeout(()=>(function(e){function t(e){return["DIV","SPAN"].includes(e.tagName)}var a={elem(t){(function(t){for(let a of e.ignore?.selector??[])if(t.matches(a))return!0;for(let a of e.ignore?.func??[])if(a(t))return!0;return!1})(t)||(n.add([t,t.parentElement]),t.remove())},list(e){Array.from(e).forEach((e=>a.elem(e)))},cls(e){a.list(document.getElementsByClassName(e))},selector(e){a.list(document.querySelectorAll(e))},func({func:e,selector:t=null}){let n=null==t?document.getElementsByClassName("*"):document.querySelectorAll(t);for(let t of n)e(t)&&a.elem(t)}},n=new Set,o=new Set;for(let[t,n]of Object.entries(e))if("ignore"!=t)for(let e of n)a[t](e);for(let[e,r]of n)o.has(e)||(o.add(e),r.isConnected&&t(r)&&(r.hasChildNodes()||a.elem(r)))})({cls:["adsbygoogle","mod_ad_container","brn-ads-box","gpt-ad","ad-box","top-ads-container","adthrive-ad"],selector:['[aria-label="advertisement"]','[class*="-ad "],[class*="-ad-"],[class$="-ad"],[class^="ad-"],[class^="adthrive"]',':is(div,iframe)[id^="google_ads_iframe_"]',"#aipPrerollContainer","span[data-ez-ph-id] span[data-ez-ph-owner-id] span.ezoicwhat"],func:[{selector:'[class*="ad" i],[id*="ad" i]',func(e){for(const t of[e.id,...e.classList])if(/(?<!lo|re|he)(ad|Ad|AD)(vertisement)?s?([tT]hrive)?([cC]ontent)?([eE]ngine|[nN]gin)?([cC]ontainer)?s?($|[-_,\s])/.test(t))return!0}},{selector:"div#preroll",func(e){for(let t of e.children)if(t.matches("div#aipBranding"))return!0}},{selector:"html > iframe",func:e=>!(!e.sandbox.contains("allow-scripts")||!e.sandbox.contains("allow-same-origin")||2!=e.sandbox.length||!e.src.toLowerCase().includes("gdpr"))}],ignore:{selector:["body",".ad-layout","#game-holder.game-holder-with-ad",".no-interstitial-ads"],func:[e=>{let t=document.getElementsByTagName("article");for(let a of t)if(e.contains(a))return!0}]}}),300);

bensmithgb53 commented 3 months ago

I am unfortunately very busy at the moment, so I am unable to work on this right now. Firefox has a nice feature where it automatically blocks popups and similar annoying stuff, so you could try that (it usually works well for me).

Thanks for getting back to me so quickly. OK no worries. I trying to use it on my xbox one as it only supports edge that doesn't have extensions. So this will be great. They just pop up when click anything on there page. I have tried yours and doesn't stop small ads and this one mine, stops them as I have put html of the pop ups on this script. If you could get chnage any time that would be great mate.