diff --git a/dist/debug/adblocker.debug.js b/dist/debug/adblocker.debug.js index 4eac811..abe0357 100644 --- a/dist/debug/adblocker.debug.js +++ b/dist/debug/adblocker.debug.js @@ -1 +1 @@ -(function(what){function shouldIgnore(elem){for(let s of what.ignore?.selector??[]){if(elem.matches(s)){return true}}for(let f of what.ignore?.func??[]){if(f(elem)){return true}}return false}function isContainerElem(elem){return["DIV","SPAN"].includes(elem.tagName)}var rm={elem(elem){if(!shouldIgnore(elem)){removedElems.add([elem,elem.parentElement]);elem.remove()}},list(elems){Array.from(elems).forEach((v=>rm.elem(v)))},cls(name){rm.list(document.getElementsByClassName(name))},selector(selector){rm.list(document.querySelectorAll(selector))},func({func,selector=null}){let elems=selector==null?document.getElementsByClassName("*"):document.querySelectorAll(selector);for(let elem of elems){if(func(elem)){rm.elem(elem)}}}};var removedElems=new Set;var handledElems=new Set;for(let[name,args]of Object.entries(what)){if(name!="ignore"){for(let arg of args){rm[name](arg)}}}for(let[elem,parent]of removedElems){if(handledElems.has(elem)){continue}handledElems.add(elem);if(!parent.isConnected){continue}if(!isContainerElem(parent)){continue}if(parent.hasChildNodes()){continue}rm.elem(parent)}})({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"],[id*="ad"]',func(elem){for(const name of[elem.id,...elem.classList]){if(/(? iframe",func(elem){if(!(elem.sandbox.contains("allow-scripts")&&elem.sandbox.contains("allow-same-origin")&&elem.sandbox.length==2)){return false}if(!elem.src.toLowerCase().includes("gdpr")){return false}return true}}],ignore:{selector:["body",".ad-layout","#game-holder.game-holder-with-ad",".no-interstitial-ads"],func:[elem=>{let articles=document.getElementsByTagName("article");for(let a of articles){if(elem.contains(a)){return true}}}]}}); \ No newline at end of file +(function(what){function shouldIgnore(elem){for(let s of what.ignore?.selector??[]){if(elem.matches(s)){return true}}for(let f of what.ignore?.func??[]){if(f(elem)){return true}}return false}function isContainerElem(elem){return["DIV","SPAN"].includes(elem.tagName)}var rm={elem(elem){if(!shouldIgnore(elem)){removedElems.add([elem,elem.parentElement]);elem.remove()}},list(elems){Array.from(elems).forEach((v=>rm.elem(v)))},cls(name){rm.list(document.getElementsByClassName(name))},selector(selector){rm.list(document.querySelectorAll(selector))},func({func,selector=null}){let elems=selector==null?document.getElementsByClassName("*"):document.querySelectorAll(selector);for(let elem of elems){if(func(elem)){rm.elem(elem)}}}};var removedElems=new Set;var handledElems=new Set;for(let[name,args]of Object.entries(what)){if(name!="ignore"){for(let arg of args){rm[name](arg)}}}for(let[elem,parent]of removedElems){if(handledElems.has(elem)){continue}handledElems.add(elem);if(!parent.isConnected){continue}if(!isContainerElem(parent)){continue}if(parent.hasChildNodes()){continue}rm.elem(parent)}})({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(elem){for(const name of[elem.id,...elem.classList]){if(/(? iframe",func(elem){if(!(elem.sandbox.contains("allow-scripts")&&elem.sandbox.contains("allow-same-origin")&&elem.sandbox.length==2)){return false}if(!elem.src.toLowerCase().includes("gdpr")){return false}return true}}],ignore:{selector:["body",".ad-layout","#game-holder.game-holder-with-ad",".no-interstitial-ads"],func:[elem=>{let articles=document.getElementsByTagName("article");for(let a of articles){if(elem.contains(a)){return true}}}]}}); \ No newline at end of file diff --git a/dist/debug/bookmarklet.debug.txt b/dist/debug/bookmarklet.debug.txt index cc599fe..43e4e01 100644 --- a/dist/debug/bookmarklet.debug.txt +++ b/dist/debug/bookmarklet.debug.txt @@ -1 +1 @@ -javascript:(function(what){function shouldIgnore(elem){for(let s of what.ignore?.selector??[]){if(elem.matches(s)){return true}}for(let f of what.ignore?.func??[]){if(f(elem)){return true}}return false}function isContainerElem(elem){return["DIV","SPAN"].includes(elem.tagName)}var rm={elem(elem){if(!shouldIgnore(elem)){removedElems.add([elem,elem.parentElement]);elem.remove()}},list(elems){Array.from(elems).forEach((v=>rm.elem(v)))},cls(name){rm.list(document.getElementsByClassName(name))},selector(selector){rm.list(document.querySelectorAll(selector))},func({func,selector=null}){let elems=selector==null?document.getElementsByClassName("*"):document.querySelectorAll(selector);for(let elem of elems){if(func(elem)){rm.elem(elem)}}}};var removedElems=new Set;var handledElems=new Set;for(let[name,args]of Object.entries(what)){if(name!="ignore"){for(let arg of args){rm[name](arg)}}}for(let[elem,parent]of removedElems){if(handledElems.has(elem)){continue}handledElems.add(elem);if(!parent.isConnected){continue}if(!isContainerElem(parent)){continue}if(parent.hasChildNodes()){continue}rm.elem(parent)}})({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"],[id*="ad"]',func(elem){for(const name of[elem.id,...elem.classList]){if(/(? iframe",func(elem){if(!(elem.sandbox.contains("allow-scripts")&&elem.sandbox.contains("allow-same-origin")&&elem.sandbox.length==2)){return false}if(!elem.src.toLowerCase().includes("gdpr")){return false}return true}}],ignore:{selector:["body",".ad-layout","#game-holder.game-holder-with-ad",".no-interstitial-ads"],func:[elem=>{let articles=document.getElementsByTagName("article");for(let a of articles){if(elem.contains(a)){return true}}}]}}); \ No newline at end of file +javascript:(function(what){function shouldIgnore(elem){for(let s of what.ignore?.selector??[]){if(elem.matches(s)){return true}}for(let f of what.ignore?.func??[]){if(f(elem)){return true}}return false}function isContainerElem(elem){return["DIV","SPAN"].includes(elem.tagName)}var rm={elem(elem){if(!shouldIgnore(elem)){removedElems.add([elem,elem.parentElement]);elem.remove()}},list(elems){Array.from(elems).forEach((v=>rm.elem(v)))},cls(name){rm.list(document.getElementsByClassName(name))},selector(selector){rm.list(document.querySelectorAll(selector))},func({func,selector=null}){let elems=selector==null?document.getElementsByClassName("*"):document.querySelectorAll(selector);for(let elem of elems){if(func(elem)){rm.elem(elem)}}}};var removedElems=new Set;var handledElems=new Set;for(let[name,args]of Object.entries(what)){if(name!="ignore"){for(let arg of args){rm[name](arg)}}}for(let[elem,parent]of removedElems){if(handledElems.has(elem)){continue}handledElems.add(elem);if(!parent.isConnected){continue}if(!isContainerElem(parent)){continue}if(parent.hasChildNodes()){continue}rm.elem(parent)}})({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(elem){for(const name of[elem.id,...elem.classList]){if(/(? iframe",func(elem){if(!(elem.sandbox.contains("allow-scripts")&&elem.sandbox.contains("allow-same-origin")&&elem.sandbox.length==2)){return false}if(!elem.src.toLowerCase().includes("gdpr")){return false}return true}}],ignore:{selector:["body",".ad-layout","#game-holder.game-holder-with-ad",".no-interstitial-ads"],func:[elem=>{let articles=document.getElementsByTagName("article");for(let a of articles){if(elem.contains(a)){return true}}}]}}); \ No newline at end of file diff --git a/dist/release/adblocker.min.js b/dist/release/adblocker.min.js index 40908a2..66aaab8 100644 --- a/dist/release/adblocker.min.js +++ b/dist/release/adblocker.min.js @@ -1 +1 @@ -(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"],[id*="ad"]',func(e){for(const t of[e.id,...e.classList])if(/(? 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}]}}); \ No newline at end of file +(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(/(? 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}]}}); \ No newline at end of file diff --git a/dist/release/bookmarklet.min.txt b/dist/release/bookmarklet.min.txt index 2a93976..f6b9a68 100644 --- a/dist/release/bookmarklet.min.txt +++ b/dist/release/bookmarklet.min.txt @@ -1 +1 @@ -javascript:(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"],[id*="ad"]',func(e){for(const t of[e.id,...e.classList])if(/(? 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}]}}); \ No newline at end of file +javascript:(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(/(? 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}]}}); \ No newline at end of file diff --git a/src/adblocker.js b/src/adblocker.js index e70ce15..860ec21 100644 --- a/src/adblocker.js +++ b/src/adblocker.js @@ -84,12 +84,12 @@ /** @type {{selector: string?, func: (elem: Element) => any}[]} */ func: [ { - selector: '[class*="ad"],[id*="ad"]', + selector: '[class*="ad" i],[id*="ad" i]', /** This is the one that gets most of them, rest is just special cases */ func(elem) { for (const name of [elem.id, ...elem.classList]) { // TODO also check lowercase followed by uppercase at end e.g. adBox - if(/(?