UNPKG

@eyeo/snippets

Version:

eye/o snippets for Ads blocker

28 lines 30.9 kB
(environment, ...filters) => { /*! * This file is part of eyeo's Anti-Circumvention Snippets module (@eyeo/snippets), * Copyright (C) 2006-present eyeo GmbH * * @eyeo/snippets is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * @eyeo/snippets is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with @eyeo/snippets. If not, see <http://www.gnu.org/licenses/>. */ const e=Proxy,{apply:t,bind:n,call:o}=Function,r=o.bind(t),i=o.bind(n),s=o.bind(o),a={get:(e,t)=>i(o,e[t])},c=t=>new e(t,a),l={get:(e,t)=>i(e[t],e)},u=t=>new e(t,l),{assign:d,defineProperties:f,freeze:h,getOwnPropertyDescriptor:p,getOwnPropertyDescriptors:m,getPrototypeOf:g}=u(Object),{hasOwnProperty:w}=c({}),{species:b}=Symbol,y={get(e,t){const n=e[t];class o extends n{}const r=m(n.prototype);delete r.constructor,h(f(o.prototype,r));const i=m(n);return delete i.length,delete i.prototype,i[b]={value:o},h(f(o,i))}},v=t=>new e(t,y);"undefined"!=typeof currentEnvironment&&currentEnvironment.initial&&"undefined"!=typeof environment&&(currentEnvironment=environment);const k=()=>"undefined"!=typeof currentEnvironment?currentEnvironment:"undefined"!=typeof environment?environment:{};"undefined"==typeof globalThis&&(window.globalThis=window);const{apply:x,ownKeys:S}=u(Reflect),E=k(),M="world"in E,T=M&&"ISOLATED"===E.world,C=M&&"MAIN"===E.world,L="object"==typeof chrome&&!!chrome.runtime,P="object"==typeof browser&&!!browser.runtime,O=!C&&(T||L||P),W=e=>O?e:R(e,F(e)),{create:R,defineProperties:N,defineProperty:I,freeze:D,getOwnPropertyDescriptor:A,getOwnPropertyDescriptors:F}=u(Object),$=u(globalThis),V=O?globalThis:v(globalThis),{Map:H,RegExp:j,Set:B,WeakMap:q,WeakSet:z}=V,_=(e,t,n=null)=>{const o=S(t);for(const r of S(e)){if(o.includes(r))continue;const i=A(e,r);if(n&&"value"in i){const{value:e}=i;"function"==typeof e&&(i.value=n(e))}I(t,r,i)}},G=e=>{const t=V[e];class n extends t{}const{toString:o,valueOf:r}=t.prototype;N(n.prototype,{toString:{value:o},valueOf:{value:r}});const i=e.toLowerCase(),s=e=>function(){const t=x(e,this,arguments);return typeof t===i?new n(t):t};return _(t,n,s),_(t.prototype,n.prototype,s),n},X=D({frozen:new q,hidden:new z,iframePropertiesToAbort:{read:new B,write:new B},abortedIframes:new q}),U=new j("^[A-Z]"),J=O&&(L&&chrome||P&&browser)||void 0;var K=new Proxy(new H([["chrome",J],["browser",J],["isExtensionContext",O],["variables",X],["console",W(console)],["document",globalThis.document],["JSON",W(JSON)],["Map",H],["Math",W(Math)],["Number",O?Number:G("Number")],["RegExp",j],["Set",B],["String",O?String:G("String")],["WeakMap",q],["WeakSet",z],["MouseEvent",MouseEvent]]),{get(e,t){if(e.has(t))return e.get(t);let n=globalThis[t];return"function"==typeof n&&(n=(U.test(t)?V:$)[t]),e.set(t,n),n},has:(e,t)=>e.has(t)});const Q={WeakSet:WeakSet,WeakMap:WeakMap,WeakValue:class{has(){return!1}set(){}}},{apply:Y}=Reflect;const{Map:Z,WeakMap:ee,WeakSet:te,setTimeout:ne}=K;let oe=!0,re=e=>{e.clear(),oe=!oe};var ie=function(e){const{WeakSet:t,WeakMap:n,WeakValue:o}=this||Q,r=new t,i=new n,s=new o;return function(t){if(r.has(t))return t;if(i.has(t))return i.get(t);if(s.has(t))return s.get(t);const n=Y(e,this,arguments);return r.add(n),n!==t&&("object"==typeof t&&t?i:s).set(t,n),n}}.bind({WeakMap:ee,WeakSet:te,WeakValue:class extends Z{set(e,t){return oe&&(oe=!oe,ne(re,0,this)),super.set(e,t)}}});const{concat:se,includes:ae,join:ce,reduce:le,unshift:ue}=c([]),de=v(globalThis),{Map:fe,WeakMap:he}=de,pe=new fe,me=t=>{const n=(e=>{const t=[];let n=e;for(;n;){if(pe.has(n))ue(t,pe.get(n));else{const e=m(n);pe.set(n,e),ue(t,e)}n=g(n)}return ue(t,{}),r(d,null,t)})("function"==typeof t?t.prototype:t),o={get(e,t){if(t in n){const{value:o,get:r}=n[t];if(r)return s(r,e);if("function"==typeof o)return i(o,e)}return e[t]},set(e,t,o){if(t in n){const{set:r}=n[t];if(r)return s(r,e,o),!0}return e[t]=o,!0}};return t=>new e(t,o)},{isExtensionContext:ge,Array:we,Number:be,String:ye,Object:ve}=K,{isArray:ke}=we,{getOwnPropertyDescriptor:xe,setPrototypeOf:Se}=ve,{toString:Ee}=ve.prototype,{slice:Me}=ye.prototype,{get:Te}=xe(Node.prototype,"nodeType"),Ce=ge?{}:{Attr:me(Attr),CanvasRenderingContext2D:me(CanvasRenderingContext2D),CSSStyleDeclaration:me(CSSStyleDeclaration),Document:me(Document),Element:me(Element),HTMLCanvasElement:me(HTMLCanvasElement),HTMLElement:me(HTMLElement),HTMLImageElement:me(HTMLImageElement),HTMLScriptElement:me(HTMLScriptElement),MutationRecord:me(MutationRecord),Node:me(Node),ShadowRoot:me(ShadowRoot),get CSS2Properties(){return Ce.CSSStyleDeclaration}},Le=(e,t)=>{if("Element"!==t&&t in Ce)return Ce[t](e);if(ke(e))return Se(e,we.prototype);const n=(e=>s(Me,s(Ee,e),8,-1))(e);if(n in Ce)return Ce[n](e);if(n in K)return Se(e,K[n].prototype);if("nodeType"in e)switch(s(Te,e)){case 1:if(!(t in Ce))throw new Error("unknown hint "+t);return Ce[t](e);case 2:return Ce.Attr(e);case 3:return Ce.Node(e);case 9:return Ce.Document(e)}throw new Error("unknown brand "+n)};var Pe=ge?e=>e===window||e===globalThis?K:e:ie(((e,t="Element")=>{if(e===window||e===globalThis)return K;switch(typeof e){case"object":return e&&Le(e,t);case"string":return new ye(e);case"number":return new be(e);default:throw new Error("unsupported value")}}));let Oe=!1;function We(){return Oe}let{console:Re,document:Ne,getComputedStyle:Ie,isExtensionContext:De,variables:Ae,Array:Fe,MutationObserver:$e,Object:Ve,XPathEvaluator:He,XPathExpression:je,XPathResult:Be}=Pe(window);const{querySelectorAll:qe}=Ne,ze=qe&&i(qe,Ne);function _e(e,t=!1){try{const n=navigator.userAgent.includes("Firefox")?e.openOrClosedShadowRoot:browser.dom.openOrClosedShadowRoot(e);return null===n&&We()&&!t&&Re.log("Shadow root not found or not added in element yet",e),n}catch(n){return We()&&!t&&Re.log("Error while accessing shadow root",e,n),null}}function Ge(e,t=!1){return Je(e,ze.bind(Ne),Ne,t)}function Xe(e,t,n,o){const r=t.getAttribute("xlink:href")||t.getAttribute("href");if(r){const s=ze(r)[0];if(!s&&We())return Re.log("No elements found matching",r),!1;if(!(i=e)||0===i.length||i.every((e=>""===e.trim()))){const e=o.length>0?o:[];return n.push({element:s,rootParents:[...e,t]}),!1}const a=s.querySelectorAll.bind(s);return{nextBoundElement:s,nestedSelectorsString:e.join("^^"),next$$:a}}var i}function Ue(e,t){const n=_e(t);if(n){const{querySelectorAll:o}=n,r=o&&i(o,n).bind(n);return{nextBoundElement:t,nestedSelectorsString:":host "+e.join("^^"),next$$:r}}return!1}function Je(e,t,n,o,r=[]){if(e.includes("^^")){const[i,s,...a]=e.split("^^");let c,l;switch(s){case"svg":l=Xe;break;case"sh":l=Ue;break;default:return We()&&Re.log(s," is not supported. Supported commands are: \n^^sh^^\n^^svg^^"),[]}c=""===i.trim()?[n]:t(i);const u=[];for(const e of c){const t=l(a,e,u,r);if(!t)continue;const{next$$:n,nestedSelectorsString:i,nextBoundElement:s}=t,c=Je(i,n,s,o,[...r,e]);c&&u.push(...c)}return u}const i=t(e);return o?[...i].map((e=>({element:e,rootParents:r.length>0?r:[]}))):i}function Ke(e,t,n=[]){if(t.includes("^^svg^^")&&(t=t.split("^^svg^^")[0]),t.includes("^^sh^^")){const o=t.split("^^sh^^"),r=o.length-1;if(t=`:host ${o[r]}`,r===n.length)return e.closest(t);return n[r].closest(t)}return n[0]?n[0].closest(t):e.closest(t)}const{assign:Qe,setPrototypeOf:Ye}=Ve;class Ze extends je{evaluate(...e){return Ye(r(super.evaluate,this,e),Be.prototype)}}class et extends He{createExpression(...e){return Ye(r(super.createExpression,this,e),Ze.prototype)}}function tt(e){if(Ae.hidden.has(e))return!1;!function(e){De&&"function"==typeof checkElement&&checkElement(e)}(e),Ae.hidden.add(e);let{style:t}=Pe(e),n=Pe(t,"CSSStyleDeclaration"),o=Pe([]);const r=k();let{debugCSSProperties:i}=r;for(let[e,t]of i||[["display","none"]])n.setProperty(e,t,"important"),o.push([e,n.getPropertyValue(e)]);return new $e((()=>{for(let[e,t]of o){let o=n.getPropertyValue(e),r=n.getPropertyPriority(e);o==t&&"important"==r||n.setProperty(e,t,"important")}})).observe(e,{attributes:!0,attributeFilter:["style"]}),!0}function nt(e){let t=e;if(t.startsWith("xpath(")&&t.endsWith(")")){let e=t.slice(6,-1),n=(new et).createExpression(e,null),o=Be.ORDERED_NODE_SNAPSHOT_TYPE;return e=>{if(!e)return;let t=n.evaluate(Ne,o,null),{snapshotLength:r}=t;for(let n=0;n<r;n++)e(t.snapshotItem(n))}}return t=>Ge(e).forEach(t)}function ot(e,t,n,o){let r;null==n&&(n=t);const i=()=>{for(const{element:i,rootParents:s}of Ge(n,!0)){const n=Ke(Pe(i),t,s);n&&e(i,n,s)&&(r(),tt(n)&&"function"==typeof o&&o(n))}};return Qe(new $e(i),{race(e){r=e,this.observe(Ne,{childList:!0,characterData:!0,subtree:!0}),i()}})}function rt(e,t,n,o){let r=Pe(t,"CSSStyleDeclaration");if("none"==r.getPropertyValue("display"))return!1;let i=r.getPropertyValue("visibility");if("hidden"==i||"collapse"==i)return!1;if(!n||e==n)return!0;let s=Pe(e).parentElement;if(!s){if(!o||!o.length)return!0;s=o[o.length-1],o=o.slice(0,-1)}return rt(s,Ie(s),n,o)}function it(e){let t=Ie(e),{cssText:n}=t;if(n)return n;for(let e of t)n+=`${e}: ${t[e]}; `;return Pe(n).trim()}let{Array:st,Math:at,RegExp:ct}=Pe(window);function lt(e){let{length:t}=e;if(t>1&&"/"===e[0]){let n="/"===e[t-1];if(n||t>2&&Pe(e).endsWith("/i")){let t=[Pe(e).slice(1,n?-1:-2)];return n||t.push("i"),new ct(...t)}}return new ct(Pe(e).replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"))}function ut(e){return Pe(st.from(e)).map((e=>`'${e}'`)).join(" ")}function dt(e){return e.reduce(((e,t)=>e+function(e,t=2){let n=Pe(e).toString(16);return n.length<t&&(n=Pe("0").repeat(t-n.length)+n),n}(t)),"")}let{Math:ft,setInterval:ht,performance:pt}=Pe(window);const mt={mark(){},end(){},toString:()=>"{mark(){},end(){}}"};let gt=!0;function wt(e,t=10){if(gt)return mt;function n(){let e=Pe([]);for(let{name:t,duration:n}of pt.getEntriesByType("measure"))e.push({name:t,duration:n});e.length&&pt.clearMeasures()}return wt[e]||(wt[e]=ht(n,ft.round(6e4/ft.min(60,t)))),{mark(){pt.mark(e)},end(t=!1){pt.measure(e,e);const o=pt.getEntriesByName(e,"measure"),r=o.length>0?o[o.length-1]:null;console.log("PROFILER:",r),pt.clearMarks(e),t&&(clearInterval(wt[e]),delete wt[e],n())}}}const{console:bt}=Pe(window),yt=()=>{};function vt(...e){let{mark:t,end:n}=wt("log");if(We()){const t=["%c DEBUG","font-weight: bold;"],n=e.indexOf("error"),o=e.indexOf("warn"),r=e.indexOf("success"),i=e.indexOf("info");-1!==n?(t[0]+=" - ERROR",t[1]+="color: red; border:2px solid red",Pe(e).splice(n,1)):-1!==o?(t[0]+=" - WARNING",t[1]+="color: orange; border:2px solid orange ",Pe(e).splice(o,1)):-1!==r?(t[0]+=" - SUCCESS",t[1]+="color: green; border:2px solid green",Pe(e).splice(r,1)):-1!==i&&(t[1]+="color: black;",Pe(e).splice(i,1)),Pe(e).unshift(...t)}t(),bt.log(...e),n()}function kt(e){return i(We()?vt:yt,null,e)}let{Array:xt,Error:St,Map:Et,parseInt:Mt}=Pe(window),Tt=null,Ct=null;function Lt(e,t){if(null===Tt)return yt;let n=Tt,{participants:o}=n;return o.set(r,t),r;function r(){if(n.winners<1)return;if(kt("race")("success",`${e} won the race`),n===Tt)Ct.push(r);else if(o.delete(r),--n.winners<1){for(let e of o.values())e();o.clear()}}}const Pt={get(e,t){const n=e;for(;!w(e,t);)e=g(e);const{get:o,set:i}=p(e,t);return function(){return arguments.length?r(i,n,arguments):s(o,n)}}};let{parseFloat:Ot,variables:Wt,clearTimeout:Rt,fetch:Nt,setTimeout:It,Array:Dt,Error:At,Map:Ft,Object:$t,ReferenceError:Vt,Set:Ht,WeakMap:jt}=Pe(window);var Bt;function qt(e,t,n){var o,r;n?"load"===n?(e("info","Waiting until window.load"),window.addEventListener("load",(()=>{e("info","Window.load fired."),t()}))):"loading"===n||"interactive"===n||"complete"===n?(e("info","Waiting document state until :",n),document.addEventListener("readystatechange",(()=>{e("info","Document state changed:",document.readyState),document.readyState===n&&t()}))):(e("info","Waiting until ",n," event is triggered on document"),(o=document,r=n,new Promise((e=>{const t=()=>{o.removeEventListener(r,t),e()};o.addEventListener(r,t)}))).then((()=>{e("info",n," is triggered on document, starting the snippet"),t()})).catch((t=>{e("error","There was an error while waiting for the event.",t)}))):t()}Bt=window,new e(Bt,Pt),Pe(/^\d+$/);let zt=new Ft;function _t(e,{as:t="arrayBuffer",cleanup:n=6e4}={}){let o=t+":"+e,r=zt.get(o)||{remove:()=>zt.delete(o),result:null,timer:0};return Rt(r.timer),r.timer=It(r.remove,n),r.result||(r.result=Nt(e).then((e=>e[t]())).catch(r.remove),zt.set(o,r)),r.result}let{MutationObserver:Gt,WeakSet:Xt,getComputedStyle:Ut}=Pe(window);let{getComputedStyle:Jt,MutationObserver:Kt,Uint8Array:Qt}=Pe(window);const{parseFloat:Yt,Math:Zt,MutationObserver:en,WeakSet:tn}=Pe(window),{min:nn}=Zt,on=(e,t)=>{const n=e.length+1,o=t.length+1,r=[[0]];let i=0,s=0;for(;++i<o;)r[0][i]=i;for(i=0;++i<n;){const n=e[s];let a=0,c=0;for(r[i]=[i];++a<o;)r[i][a]=nn(r[s][a]+1,r[i][c]+1,r[s][c]+(n!=t[c])),++c;++s}return r[n-1][o-1]};let{getComputedStyle:rn,Map:sn,WeakSet:an,parseFloat:cn,DOMMatrix:ln,Math:un}=Pe(window);const{ELEMENT_NODE:dn,TEXT_NODE:fn}=Node;let{MutationObserver:hn,WeakSet:pn,getComputedStyle:mn}=Pe(window);let{getComputedStyle:gn,MutationObserver:wn,WeakSet:bn}=Pe(window);let{MutationObserver:yn,WeakSet:vn}=Pe(window);const{ELEMENT_NODE:kn}=Node;let{MutationObserver:xn,WeakSet:Sn}=Pe(window);const{ELEMENT_NODE:En}=Node;let{getComputedStyle:Mn,MutationObserver:Tn,WeakSet:Cn,DOMParser:Ln,Math:Pn,Map:On}=Pe(window);let{parseInt:Wn,setTimeout:Rn,Error:Nn,MouseEvent:In,MutationObserver:Dn,WeakSet:An}=Pe(window);const Fn=["auxclick","click","dblclick","gotpointercapture","lostpointercapture","mouseenter","mousedown","mouseleave","mousemove","mouseout","mouseover","mouseup","pointerdown","pointerenter","pointermove","pointerover","pointerout","pointerup","pointercancel","pointerleave"];let{isNaN:$n,MutationObserver:Vn,parseInt:Hn,parseFloat:jn,setTimeout:Bn}=Pe(window);const qn={log:vt,race:function(e,t="1"){switch(e){case"start":Tt={winners:Mt(t,10)||1,participants:new Et},Ct=new xt;break;case"end":case"finish":case"stop":Tt=null;for(let e of Ct)e();Ct=null;break;default:throw new St(`Invalid action: ${e}`)}},debug:function(){Oe=!0},profile:function(){gt=!1},"hide-if-matches-xpath":function(e,t,n){const{mark:o,end:r}=wt("hide-if-matches-xpath"),i=ut(arguments),s=kt("hide-if-matches-xpath");qt(s,(()=>{const n=n=>{const a=nt(`xpath(${e})`),c=new vn,l=e=>{c.add(e),f(),Pe(e).nodeType===kn?tt(e):Pe(e).textContent="",s("success","Matched: ",e,"\nFILTER: hide-if-matches-xpath",i)},u=()=>{o(),a((e=>{if(c.has(e))return!1;if(t){nt(`xpath(${t})`)((t=>{if(!t.contains(e))return!1;l(e)}))}else l(e)})),r()},d=new yn(u),f=Lt("hide-if-matches-xpath",(()=>d.disconnect()));d.observe(n,{characterData:!0,childList:!0,subtree:!0}),u()};if(t){let e,o=0;const r=nt(`xpath(${t})`),i=()=>{r((e=>{n(e),o++})),o>0&&e.disconnect()};e=new yn(i),e.observe(document,{characterData:!0,childList:!0,subtree:!0}),i()}else n(document)}),n)},"hide-if-matches-computed-xpath":function(e,t,n,o){const{mark:r,end:i}=wt("hide-if-matches-computed-xpath"),s=ut(arguments),a=kt("hide-if-matches-computed-xpath");if(!t||!e)return void a("error","No query or searchQuery provided.");const c=t=>{const n=(t=>e.replace("{{}}",t))(t);a("info","Starting hiding elements that match query: ",n);const o=nt(`xpath(${n})`),c=new Sn,l=()=>{r(),o((e=>{if(c.has(e))return!1;c.add(e),d(),Pe(e).nodeType===En?tt(e):Pe(e).textContent="",a("success","Matched: ",e,"\nFILTER: hide-if-matches-computed-xpath",s)})),i()},u=new xn(l),d=Lt("hide-if-matches-computed-xpath",(()=>u.disconnect()));u.observe(document,{characterData:!0,childList:!0,subtree:!0}),l()},l=lt(n);qt(a,(()=>{if(t){a("info","Started searching for: ",t);const e=new Sn;let n;const o=nt(`xpath(${t})`),r=()=>{o((t=>{if(e.has(t))return!1;if(e.add(t),a("info","Found node: ",t),t.innerHTML){a("info","Searching in: ",t.innerHTML);const e=t.innerHTML.match(l);if(e&&e.length){let t="";t=e[1]?e[1]:e[0],a("info","Matched search query: ",t),c(t)}}}))};n=new xn(r),n.observe(document,{characterData:!0,childList:!0,subtree:!0}),r()}}),o)},"hide-if-contains":function(e,t="*",n=null){const o=ut(arguments),r=kt("hide-if-contains"),{mark:i,end:s}=wt("hide-if-contains");let a=lt(e);const c=ot((e=>a.test(Pe(e).textContent)),t,n,(e=>{i(),r("success","Matched: ",e,"\nFILTER: hide-if-contains",o),s()}));c.race(Lt("hide-if-contains",(()=>{c.disconnect()})))},"hide-if-contains-similar-text":function(e,t,n=null,o=0,r=0){const i=new tn,s=ut(arguments),a=kt("hide-if-contains-similar-text"),{mark:c,end:l}=wt("hide-if-contains-similar-text"),u=Pe(e),{length:d}=u,f=d+Yt(o)||0,h=Pe([...u]).sort(),p=Yt(r)||1/0;null==n&&(n=t),a("info","Looking for similar text: "+u);const m=()=>{c();for(const{element:e,rootParents:r}of Ge(n,!0)){if(i.has(e))continue;i.add(e);const{innerText:n}=Pe(e),c=nn(p,n.length-f+1);for(let i=0;i<c;i++){const c=Pe(n).substr(i,f);if(on(h,Pe([...c]).sort())-o<=0){const n=Ke(Pe(e),t,r);if(a("success","Found similar text: "+u,n,"\nFILTER: hide-if-contains-similar-text",s),n){w(),tt(n);break}}}}l()};let g=new en(m),w=Lt("hide-if-contains-similar-text",(()=>g.disconnect()));g.observe(document,{childList:!0,characterData:!0,subtree:!0}),m()},"hide-if-contains-visible-text":function(e,t,n=null,...o){const{mark:r,end:i}=wt("hide-if-contains-visible-text"),s=ut(arguments);let a=Pe([]);const c=new sn([["-snippet-box-margin","2"],["-disable-bg-color-check","false"],["-check-is-contained","false"],["-pseudo-box-margin","2"],["-ignore-padding","false"]]);for(let e of o){e=Pe(e);let t=e.indexOf(":");if(t<0)continue;let n=e.slice(0,t).trim().toString(),o=e.slice(t+1).trim().toString();n&&o&&(c.has(n)?c.set(n,o):a.push([n,o]))}let l=Pe([["opacity","0"],["font-size","0px"],["color","rgba(0, 0, 0, 0)"]]),u=new sn(l.concat(a));function d(e,t,{bgColorCheck:n=!0,pseudoElemCheck:o=!1}={}){t||(t=rn(e)),t=Pe(t);for(const[e,n]of u){if(lt(n).test(t.getPropertyValue(e)))return!1}const r=t.getPropertyValue("color");if(n&&t.getPropertyValue("background-color")===r)return!1;if(!o){const t=rn(e,"::first-line");if(t)return d(e,t,{bgColorCheck:n,pseudoElemCheck:!0})}const i=t.getPropertyValue("text-shadow");return!r.includes("rgba(0, 0, 0, 0)")||"none"!==i&&!i.includes("rgba(0, 0, 0, 0)")}function f(e,t=null){let n=rn(e,t).transform;return"none"===n&&(n="matrix(1, 0, 0, 1, 0, 0)"),new ln(n)}function h(e,t,n,{bgColorCheck:o=!0,translateThresh:r=2}={}){let i=rn(e,t);if(!rt(e,i)||!d(e,i,{bgColorCheck:o}))return"";let{content:s}=Pe(i);if(s&&"none"!==s){let o=Pe([]);const i=f(e,t),a=n.multiply(i),c=un.atan2(a.b,a.a)*(180/un.PI);if(un.abs(c)>5)return"";return un.abs(a.e)>r||un.abs(a.f)>r?"":(s=Pe(s).trim().replace(/(["'])(?:(?=(\\?))\2.)*?\1/g,(e=>""+(o.push(Pe(e).slice(1,-1))-1))),s=s.replace(/\s*attr\(\s*([^\s,)]+)[^)]*?\)\s*/g,((t,n)=>Pe(e).getAttribute(n)||"")),s.replace(/\x01(\d+)/g,((e,t)=>o[t])))}return""}function p(e,t,{boxMargin:n=2,ignorePadding:o=!1}={}){let r=Pe(e).getBoundingClientRect();if(o){const t=rn(e),n=cn(t.paddingTop)||0,o=cn(t.paddingRight)||0,i=cn(t.paddingBottom)||0,s=cn(t.paddingLeft)||0;r={left:r.left+s,right:r.right-o,top:r.top+n,bottom:r.bottom-i}}const i=Pe(t).getBoundingClientRect(),s=i.left-n,a=i.right+n,c=i.top-n,l=i.bottom+n;return s<=r.left&&r.left<=a&&c<=r.top&&r.top<=l&&c<=r.bottom&&r.bottom<=l&&s<=r.right&&r.right<=a}function m(e,t,n,o,r,i,s,{boxMargin:a=2,bgColorCheck:c,checkIsContained:l,translateThresh:u}={}){let g=!n;if(g&&(n=rn(e)),!rt(e,n,g&&t,i))return"";o||"hidden"!==Pe(n).getPropertyValue("overflow-x")&&"hidden"!==Pe(n).getPropertyValue("overflow-y")||(o=e);let w=h(e,":before",s=s?s.multiply(f(e)):f(e),{bgColorCheck:c,translateThresh:u});for(let t of function(e,t=!0){const n=_e(e,t);return n?n.childNodes:Pe(e).childNodes}(Pe(e)))switch(Pe(t).nodeType){case dn:w+=m(t,e,rn(t),o,r,i,s,{boxMargin:a,bgColorCheck:c,checkIsContained:l,translateThresh:u});break;case fn:if(o)p(e,o,{boxMargin:a,ignorePadding:v})&&d(e,n,{bgColorCheck:c})&&(w+=Pe(t).nodeValue);else if(d(e,n,{bgColorCheck:c})){if(l&&!p(e,r,{boxMargin:a,ignorePadding:v}))continue;w+=Pe(t).nodeValue}}return w+=h(e,":after",s,{bgColorCheck:c,translateThresh:u}),w}const g=c.get("-snippet-box-margin"),w=cn(g)||0,b=!("true"===c.get("-disable-bg-color-check")),y="true"===c.get("-check-is-contained"),v="true"===c.get("-ignore-padding"),k=c.get("-pseudo-box-margin"),x=cn(k)||0;let S=lt(e),E=new an;const M=ot(((e,t,n)=>{if(r(),E.has(e))return!1;E.add(e);let o=m(e,t,null,null,e,n,null,{boxMargin:w,bgColorCheck:b,checkIsContained:y,translateThresh:x}),a=S.test(o);return We()&&o.length&&(a?vt("success",a,S,o,"\nFILTER: hide-if-contains-visible-text",s):vt("info",a,S,o)),i(),a}),t,n);M.race(Lt("hide-if-contains-visible-text",(()=>{M.disconnect()})))},"hide-if-contains-and-matches-style":function(e,t="*",n=null,o=null,r=null,i,s=null,a=null){const c=ut(arguments),l=kt("hide-if-contains-and-matches-style"),{mark:u,end:d}=wt("hide-if-contains-and-matches-style"),f=new Xt,h=We()&&new Xt;null==n&&(n=t);const p=lt(e),m=o?lt(o):null,g=r?lt(r):null;qt(l,(()=>{const e=()=>{if(u(),!(s&&window.innerWidth<s||a&&window.innerWidth>a)){for(const{element:e,rootParents:o}of Ge(n,!0))if(!f.has(e)&&p.test(Pe(e).textContent))if(!g||g.test(it(e))){const n=Ke(Pe(e),t,o);if(!n)continue;if(!m||m.test(it(n)))r(),tt(n),f.add(e),l("success","Matched: ",n,"which contains: ",e,"\nFILTER: hide-if-contains-and-matches-style",c);else{if(!h||h.has(n))continue;l("info","In this element the searchStyle matched but style didn't:\n",n,Ut(n),c),h.add(n)}}else{if(!h||h.has(e))continue;l("info","In this element the searchStyle didn't match:\n",e,Ut(e),c),h.add(e)}d()}},o=new Gt(e),r=Lt("hide-if-contains-and-matches-style",(()=>o.disconnect()));o.observe(document,{childList:!0,characterData:!0,subtree:!0}),e()}),i)},"hide-if-has-and-matches-style":function(e,t="*",n=null,o=null,r=null,i=null,s=null,a=null){const c=ut(arguments),l=kt("hide-if-has-and-matches-style"),{mark:u,end:d}=wt("hide-if-has-and-matches-style"),f=new pn,h=We()&&new pn;null==n&&(n=t);const p=o?lt(o):null,m=r?lt(r):null;qt(l,(()=>{const o=()=>{if(u(),!(s&&window.innerWidth<s||a&&window.innerWidth>a)){for(const{element:o,rootParents:r}of Ge(n,!0))if(!f.has(o))if(!Pe(o).querySelector(e)||m&&!m.test(it(o))){if(!h||h.has(o))continue;l("info","In this element the searchStyle didn't match:\n",o,mn(o),...arguments),h.add(o)}else{const e=Ke(Pe(o),t,r);if(!e||p&&!p.test(it(e))){if(!h||h.has(e))continue;l("info","In this element the searchStyle matchedbut style didn't:\n",e,mn(e),...arguments),h.add(e)}else i(),tt(e),f.add(o),l("success","Matched: ",e,"which contains: ",o,"\nFILTER: hide-if-has-and-matches-style",c)}d()}},r=new hn(o),i=Lt("hide-if-has-and-matches-style",(()=>r.disconnect()));r.observe(document,{childList:!0,subtree:!0}),o()}),i)},"hide-if-labelled-by":function(e,t,n=null){const{mark:o,end:r}=wt("hide-if-labelled-by");let i=null==n,s=lt(e),a=new bn,c=()=>{o();for(const{element:e,rootParents:o}of Ge(t,!0)){let t=i?e:Ke(Pe(e),n,o);if(!t||!rt(e,gn(e),t))continue;let r=Pe(e).getAttribute("aria-labelledby"),c=()=>{a.has(t)||s.test(Pe(e).getAttribute("aria-label")||"")&&(u(),a.add(t),tt(t))};if(r)for(let e of Pe(r).split(/\s+/)){let n=Pe(document).getElementById(e);n?!a.has(n)&&s.test(n.innerText)&&(u(),a.add(n),tt(t)):c()}else c()}r()},l=new wn(c),u=Lt("hide-if-labelled-by",(()=>l.disconnect()));l.observe(document,{characterData:!0,childList:!0,subtree:!0}),c()},"hide-if-contains-image":function(e,t,n){null==n&&(n=t);let o=lt(e);const r=ut(arguments),i=kt("hide-if-contains-image"),{mark:s,end:a}=wt("hide-if-contains-image");let c=()=>{s();for(const{element:e,rootParents:s}of Ge(n,!0)){let n=Jt(e),a=Pe(n["background-image"]).match(/^url\("(.*)"\)$/);a&&_t(a[1]).then((n=>{if(o.test(dt(new Qt(n)))){let n=Ke(Pe(e),t,s);n&&(u(),tt(n),i("success","Matched: ",n,"\nFILTER: hide-if-contains-image",r))}}))}a()},l=new Kt(c),u=Lt("hide-if-contains-image",(()=>l.disconnect()));l.observe(document,{childList:!0,subtree:!0}),c()},"hide-if-svg-contains":function(e,t,n,...o){null==n&&(n=t);const r=lt(e),i=ut(arguments),s=new Cn,a=kt("hide-if-svg-contains"),{mark:c,end:l}=wt("hide-if-svg-contains"),u=new On([["-position-threshold","500"],["-disable-contained-check","false"],["-wait-until",""],["-opacity-alpha-threshold","0.1"],["-font-size-threshold","1"]]);let d=Pe([]);for(let e of o){e=Pe(e);let t=e.indexOf(":");if(t<0)continue;let n=e.slice(0,t).trim(),o=e.slice(t+1).trim();n&&o&&(u.has(n)?u.set(n,o):d.push([n,o]))}let f=Pe([["display","none"],["visibility","hidden"],["opacity","0"],["fill","none"],["font-size","0"]]),h=new On(f.concat(d));const p=parseFloat(u.get("-position-threshold"))||0,m="true"===u.get("-disable-contained-check"),g=parseFloat(u.get("-opacity-alpha-threshold"))||0,w=parseFloat(u.get("-font-size-threshold"))||0,b=new On,y=u.get("-wait-until");function v(e,t){if(!t.test(e.textContent))return!1;const n=Mn(e),o=e.getBoundingClientRect(),r=e.ownerSVGElement.getBoundingClientRect(),i=/\b(rgba?|hsla?|hwb)\b/;for(const[e,t]of h){const o=n[e],r=parseFloat(o);switch(e){case"color":case"fill":if(o&&i.test(o)&&0!=g){const e=o.split(",")[3]||o.split("/")[1],t=e?parseFloat(e):1;if(!isNaN(t)&&t<=g)return!1}else if(o&&lt(t).test(o))return!1;break;case"opacity":if(!isNaN(r)&&g>0&&r<=g)return!1;break;case"font-size":if(!isNaN(r)&&w>0&&r<=w)return!1;break;default:if(o&&lt(t).test(o))return!1}}if(!m&&p>0){const e=o.x-r.x,t=o.y-r.y;if(Pn.abs(e)>p||Pn.abs(t)>p)return!1}return!0}function k(){a("info","Creating Isolated element to host SVGs");const e=document.createElement("div");e.style.cssText="position: absolute; top: -9999px; left: -9999px; border: none; pointer-events: none;",document.body.appendChild(e);const t=e.attachShadow({mode:"closed"});return t.innerHTML='\n <div id="container" style="{ all: initial; }">\n </div>\n ',{svgContainer:t.querySelector("#container"),cleanup:()=>e.remove()}}qt(a,(async()=>{let e,o=async()=>{c();for(const{element:o,rootParents:c}of Ge(n,!0)){if(e||(e=k()),s.has(o))continue;let n=!1;try{const t=Pe(Mn(o).backgroundImage).match(/url\("?(.+?)"?\)/);if(!t)continue;const i=t[1];let c=b.get(i);c||(c=_t(i,{as:"text"}),b.set(i,c));const l=await c;if(s.has(o))continue;const u=(new Ln).parseFromString(l,"image/svg+xml");if(u.querySelector("parsererror")){a("warn","Skipping malformed SVG:",i,"for element:",o);continue}e.svgContainer.innerHTML="",e.svgContainer.appendChild(u.documentElement);const d=e.svgContainer.querySelectorAll("text, tspan");for(const e of d)if(v(e,r)){n=!0,a("info","Condition met: Text found visible in SVG of element",o);break}}catch(e){a("warn","An error occurred while processing element:",o,e);continue}if(n&&!s.has(o)){const e=Ke(Pe(o),t,c);e&&(d(),tt(e),s.add(o),a("success","Matched: ",e,"\nFILTER: hide-if-svg-contains",i))}}l()},u=new Tn(o),d=Lt("hide-if-svg-contains",(()=>{u.disconnect(),e.cleanup()}));u.observe(document,{childList:!0,subtree:!0}),o()}),y)},"simulate-mouse-event":function(...e){const t=ut(arguments),n=kt("simulate-mouse-event"),{mark:o,end:r}=wt("simulate-mouse-event");if(e.length<1)throw new Nn("[simulate-mouse-event snippet]: No selector provided.");e.length>7&&(e=e.slice(0,7));const i=Pe([]);function s(){return i.forEach((e=>{if(!e.found){(function(e){let t=e;if(t.startsWith("xpath(")&&t.endsWith(")")){let t=nt(e);return()=>{let e=Pe([]);return t((t=>e.push(t))),e}}return()=>Fe.from(Ge(e))})(e.selector)().length>0&&(e.found=!0)}})),i.every((e=>e.found))}function a(e,o,r){e&&o&&("click"===o&&e.click?(e.click(),n("success","Clicked on this node:\n",e,"\nwith a delay of",r,"ms",`n\nFILTER: simulate-mouse-event ${t}`)):(e.dispatchEvent(new In(o,{bubbles:!0,cancelable:!0})),n("success","A",o,"event was dispatched with a delay of",r,"ms on this node:\n",e,`n\nFILTER: simulate-mouse-event ${t}`)))}Pe(e).forEach((e=>{const t=function(e){if(!e)return null;const t={selector:"",continue:!1,trigger:!1,event:"click",delay:"500",clicked:!1,found:!1},o=e.split("$");let r=[];o.length>=2&&(r=o[1].toLowerCase().split(",")),[t.selector]=o;for(const e of r)if("trigger"===e)t.trigger=!0;else if("continue"===e)t.continue=!0;else if(e.startsWith("event")){const n=e.toLowerCase().split("=");n[1]?t.event=n[1]:t.event="click"}else if(e.startsWith("delay")){const n=e.toLowerCase().split("=");n[1]?t.delay=n[1]:t.delay="500"}return Fn.includes(t.event)||n("warn",t.event," might be misspelled, check for typos.\n","These are the supported events:",Fn),t}(e);i.push(t)}));let c=!1;const[l]=i.slice(-1);l.trigger=!0;let u=new An;function d(){if(o(),c||(c=s()),c)for(const e of i){const t=nt(e.selector),n=Wn(e.delay,10);e.trigger&&t((t=>{u.has(t)||(u.add(t),e.continue?setInterval((()=>{i.forEach((e=>{e.found=!1,e.clicked=!1}));s()&&a(t,e.event,e.delay)}),n):Rn((()=>{a(t,e.event,e.delay)}),n))}))}r()}new Dn(d).observe(document,{childList:!0,subtree:!0}),d()},"skip-video":function(e,t,...n){const o=ut(arguments),r=new Map([["-max-attempts","10"],["-retry-ms","10"],["-run-once","false"],["-wait-until",""],["-skip-to","-0.1"],["-stop-on-video-end","false"],["-start-from","0"],["-mute-video-when-skipping","true"]]);for(let e of n){e=Pe(e);let t=e.indexOf(":");if(t<0)continue;let n=e.slice(0,t).trim().toString(),o=e.slice(t+1).trim().toString();n&&o&&r.has(n)&&r.set(n,o)}const i=r.get("-max-attempts"),s=Hn(i||10,10),a=r.get("-retry-ms"),c=Hn(a||10,10),l="true"===r.get("-run-once"),u=r.get("-skip-to"),d=jn(u||-.1),f=r.get("-start-from"),h=Hn(f||0,10),p=r.get("-wait-until"),m="true"===r.get("-stop-on-video-end"),g=!("false"===r.get("-mute-video-when-skipping")),w=kt("skip-video"),{mark:b,end:y}=wt("skip-video"),v=nt(`xpath(${t})`);let k=!1;qt(w,(()=>{b();const n=new WeakSet,r=(u=0)=>{k&&l?i&&i.disconnect():v((i=>{let l,f=n.has(i);f||(w("info","Matched:",i," for selector: ",t),w("info","Running video skipping logic."));const p=Ge(e);let b=!1;for(const e of p){if(!e||$n(e.duration)||$n(e.currentTime))continue;b=!0;const t=e.duration-e.currentTime<.5;!(e.duration>0&&e.currentTime<e.duration)||m&&t||(g&&(e.muted=!0,f||w("success","Muted video...")),h<=1e3*e.currentTime&&(d<=0?e.currentTime=e.duration+d:e.currentTime+=d,l!==e.duration&&(w("success","Skipped video, currentTime: ",e.currentTime,"s.","\nFILTER: skip-video",o),n.add(i),l=e.duration),e.paused&&e.play(),k=!0,a()))}!b&&u<s&&Bn((()=>{const e=u+1;w("info","Running video skipping logic. Attempt: ",e),r(e)}),c)}))},i=new Vn(r),a=Lt("skip-video",(()=>i.disconnect()));i.observe(document,{characterData:!0,childList:!0,subtree:!0}),r(),y()}),p)}}; const snippets=qn; let context; for (const [name, ...args] of filters) { if (snippets.hasOwnProperty(name)) { try { context = snippets[name].apply(context, args); } catch (error) { console.error(error); } } } context = void 0; }