UNPKG

@eyeo/snippets

Version:

eye/o snippets for Ads blocker

28 lines 47 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:r}=Function,o=r.bind(t),s=r.bind(n),i=r.bind(r),a={get:(e,t)=>s(r,e[t])},c=t=>new e(t,a),l=(t,n)=>new e(t,{apply:(e,t,r)=>o(n,t,r)}),u={get:(e,t)=>s(e[t],e)},f=t=>new e(t,u),{assign:p,defineProperties:d,freeze:h,getOwnPropertyDescriptor:g,getOwnPropertyDescriptors:y,getPrototypeOf:w}=f(Object),{hasOwnProperty:m}=c({}),{species:v}=Symbol,b={get(e,t){const n=e[t];class r extends n{}const o=y(n.prototype);delete o.constructor,h(d(r.prototype,o));const s=y(n);return delete s.length,delete s.prototype,s[v]={value:r},h(d(r,s))}},E=t=>new e(t,b);"undefined"!=typeof currentEnvironment&&currentEnvironment.initial&&"undefined"!=typeof environment&&(currentEnvironment=environment);const $=()=>"undefined"!=typeof currentEnvironment?currentEnvironment:"undefined"!=typeof environment?environment:{};"undefined"==typeof globalThis&&(window.globalThis=window);const{apply:S,ownKeys:T}=f(Reflect),x=$(),j="world"in x,k=j&&"ISOLATED"===x.world,R=j&&"MAIN"===x.world,M="object"==typeof chrome&&!!chrome.runtime,L="object"==typeof browser&&!!browser.runtime,P=!R&&(k||M||L),A=e=>P?e:O(e,F(e)),{create:O,defineProperties:N,defineProperty:C,freeze:I,getOwnPropertyDescriptor:W,getOwnPropertyDescriptors:F}=f(Object),D=f(globalThis),H=P?globalThis:E(globalThis),{Map:z,RegExp:B,Set:U,WeakMap:q,WeakSet:V}=H,J=(e,t,n=null)=>{const r=T(t);for(const o of T(e)){if(r.includes(o))continue;const s=W(e,o);if(n&&"value"in s){const{value:e}=s;"function"==typeof e&&(s.value=n(e))}C(t,o,s)}},G=e=>{const t=H[e];class n extends t{}const{toString:r,valueOf:o}=t.prototype;N(n.prototype,{toString:{value:r},valueOf:{value:o}});const s=e.toLowerCase(),i=e=>function(){const t=S(e,this,arguments);return typeof t===s?new n(t):t};return J(t,n,i),J(t.prototype,n.prototype,i),n},X=I({frozen:new q,hidden:new V,iframePropertiesToAbort:{read:new U,write:new U},abortedIframes:new q}),_=new B("^[A-Z]"),K=P&&(M&&chrome||L&&browser)||void 0;var Y=new Proxy(new z([["chrome",K],["browser",K],["isExtensionContext",P],["variables",X],["console",A(console)],["document",globalThis.document],["JSON",A(JSON)],["Map",z],["Math",A(Math)],["Number",P?Number:G("Number")],["RegExp",B],["Set",U],["String",P?String:G("String")],["WeakMap",q],["WeakSet",V],["MouseEvent",MouseEvent]]),{get(e,t){if(e.has(t))return e.get(t);let n=globalThis[t];return"function"==typeof n&&(n=(_.test(t)?H:D)[t]),e.set(t,n),n},has:(e,t)=>e.has(t)});const Z={WeakSet:WeakSet,WeakMap:WeakMap,WeakValue:class{has(){return!1}set(){}}},{apply:Q}=Reflect;const{Map:ee,WeakMap:te,WeakSet:ne,setTimeout:re}=Y;let oe=!0,se=e=>{e.clear(),oe=!oe};var ie=function(e){const{WeakSet:t,WeakMap:n,WeakValue:r}=this||Z,o=new t,s=new n,i=new r;return function(t){if(o.has(t))return t;if(s.has(t))return s.get(t);if(i.has(t))return i.get(t);const n=Q(e,this,arguments);return o.add(n),n!==t&&("object"==typeof t&&t?s:i).set(t,n),n}}.bind({WeakMap:te,WeakSet:ne,WeakValue:class extends ee{set(e,t){return oe&&(oe=!oe,re(se,0,this)),super.set(e,t)}}});const{concat:ae,includes:ce,join:le,reduce:ue,unshift:fe}=c([]),pe=E(globalThis),{Map:de,WeakMap:he}=pe,ge=new de,ye=t=>{const n=(e=>{const t=[];let n=e;for(;n;){if(ge.has(n))fe(t,ge.get(n));else{const e=y(n);ge.set(n,e),fe(t,e)}n=w(n)}return fe(t,{}),o(p,null,t)})("function"==typeof t?t.prototype:t),r={get(e,t){if(t in n){const{value:r,get:o}=n[t];if(o)return i(o,e);if("function"==typeof r)return s(r,e)}return e[t]},set(e,t,r){if(t in n){const{set:o}=n[t];if(o)return i(o,e,r),!0}return e[t]=r,!0}};return t=>new e(t,r)},{isExtensionContext:we,Array:me,Number:ve,String:be,Object:Ee}=Y,{isArray:$e}=me,{getOwnPropertyDescriptor:Se,setPrototypeOf:Te}=Ee,{toString:xe}=Ee.prototype,{slice:je}=be.prototype,{get:ke}=Se(Node.prototype,"nodeType"),Re=we?{}:{Attr:ye(Attr),CanvasRenderingContext2D:ye(CanvasRenderingContext2D),CSSStyleDeclaration:ye(CSSStyleDeclaration),Document:ye(Document),Element:ye(Element),HTMLCanvasElement:ye(HTMLCanvasElement),HTMLElement:ye(HTMLElement),HTMLImageElement:ye(HTMLImageElement),HTMLScriptElement:ye(HTMLScriptElement),MutationRecord:ye(MutationRecord),Node:ye(Node),ShadowRoot:ye(ShadowRoot),get CSS2Properties(){return Re.CSSStyleDeclaration}},Me=(e,t)=>{if("Element"!==t&&t in Re)return Re[t](e);if($e(e))return Te(e,me.prototype);const n=(e=>i(je,i(xe,e),8,-1))(e);if(n in Re)return Re[n](e);if(n in Y)return Te(e,Y[n].prototype);if("nodeType"in e)switch(i(ke,e)){case 1:if(!(t in Re))throw new Error("unknown hint "+t);return Re[t](e);case 2:return Re.Attr(e);case 3:return Re.Node(e);case 9:return Re.Document(e)}throw new Error("unknown brand "+n)};var Le=we?e=>e===window||e===globalThis?Y:e:ie(((e,t="Element")=>{if(e===window||e===globalThis)return Y;switch(typeof e){case"object":return e&&Me(e,t);case"string":return new be(e);case"number":return new ve(e);default:throw new Error("unsupported value")}}));const Pe={get(e,t){const n=e;for(;!m(e,t);)e=w(e);const{get:r,set:s}=g(e,t);return function(){return arguments.length?o(s,n,arguments):i(r,n)}}},Ae=t=>new e(t,Pe);let{Math:Oe,setInterval:Ne,performance:Ce}=Le(window);const Ie={mark(){},end(){},toString:()=>"{mark(){},end(){}}"};let We=!0;function Fe(e,t=10){if(We)return Ie;function n(){let e=Le([]);for(let{name:t,duration:n}of Ce.getEntriesByType("measure"))e.push({name:t,duration:n});e.length&&Ce.clearMeasures()}return Fe[e]||(Fe[e]=Ne(n,Oe.round(6e4/Oe.min(60,t)))),{mark(){Ce.mark(e)},end(t=!1){Ce.measure(e,e);const r=Ce.getEntriesByName(e,"measure"),o=r.length>0?r[r.length-1]:null;console.log("PROFILER:",o),Ce.clearMarks(e),t&&(clearInterval(Fe[e]),delete Fe[e],n())}}}let De=!1;function He(){return De}const{console:ze}=Le(window),Be=()=>{};function Ue(...e){let{mark:t,end:n}=Fe("log");if(He()){const t=["%c DEBUG","font-weight: bold;"],n=e.indexOf("error"),r=e.indexOf("warn"),o=e.indexOf("success"),s=e.indexOf("info");-1!==n?(t[0]+=" - ERROR",t[1]+="color: red; border:2px solid red",Le(e).splice(n,1)):-1!==r?(t[0]+=" - WARNING",t[1]+="color: orange; border:2px solid orange ",Le(e).splice(r,1)):-1!==o?(t[0]+=" - SUCCESS",t[1]+="color: green; border:2px solid green",Le(e).splice(o,1)):-1!==s&&(t[1]+="color: black;",Le(e).splice(s,1)),Le(e).unshift(...t)}t(),ze.log(...e),n()}function qe(e){return s(He()?Ue:Be,null,e)}let{Array:Ve,Math:Je,RegExp:Ge}=Le(window);function Xe(e){let{length:t}=e;if(t>1&&"/"===e[0]){let n="/"===e[t-1];if(n||t>2&&Le(e).endsWith("/i")){let t=[Le(e).slice(1,n?-1:-2)];return n||t.push("i"),new Ge(...t)}}return new Ge(Le(e).replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"))}function _e(){return Le(Je.floor(2116316160*Je.random()+60466176)).toString(36)}function Ke(e){return Le(Ve.from(e)).map((e=>`'${e}'`)).join(" ")}let{parseFloat:Ye,variables:Ze,clearTimeout:Qe,fetch:et,setTimeout:tt,Array:nt,Error:rt,Map:ot,Object:st,ReferenceError:it,Set:at,WeakMap:ct}=Le(window),{onerror:lt}=Ae(window),ut=Node.prototype,ft=Element.prototype,pt=null;function dt(e,t,n,r=!0){let o=Le(t),s=o.indexOf(".");if(-1==s){let o=st.getOwnPropertyDescriptor(e,t);if(o&&!o.configurable)return;let s=st.assign({},n,{configurable:r});if(!o&&!s.get&&s.set){let n=e[t];s.get=()=>n}return void st.defineProperty(e,t,s)}let i=o.slice(0,s).toString();t=o.slice(s+1).toString();let a=e[i];!a||"object"!=typeof a&&"function"!=typeof a||dt(a,t,n);let c=st.getOwnPropertyDescriptor(e,i);if(c&&!c.configurable)return;pt||(pt=new ct),pt.has(e)||pt.set(e,new ot);let l=pt.get(e);if(l.has(i))return void l.get(i).set(t,n);let u=new ot([[t,n]]);l.set(i,u),st.defineProperty(e,i,{get:()=>a,set(e){if(a=e,a&&("object"==typeof a||"function"==typeof a))for(let[e,t]of u)dt(a,e,t)},configurable:r})}function ht(e){let t=lt();lt(((...n)=>{let r=n.length&&n[0];return!("string"!=typeof r||!Le(r).includes(e))||("function"==typeof t?o(t,this,n):void 0)}))}function gt(e,t,n,r="",o=!0){let s=qe(e);if(!n)return void s("error","no property to abort on read");let i=_e();s("info",`aborting on ${n} access`),dt(t,n,{get:function(){throw s("success",`${n} access aborted`,`\nFILTER: ${e} ${r}`),new it(i)},set(){}},o),ht(i)}function yt(e,t,n,r="",o=!0){let s=qe(e);if(!n)return void s("error","no property to abort on write");let i=_e();s("info",`aborting when setting ${n}`),dt(t,n,{set:function(){throw s("success",`setting ${n} aborted`,`\nFILTER: ${e} ${r}`),new it(i)}},o),ht(i)}function wt(e,t=!1,n=!1){let r=Ze.abortedIframes,s=Ze.iframePropertiesToAbort;const a=Ke(e);for(let o of nt.from(window.frames))if(r.has(o))for(let s of e)t&&r.get(o).read.add({property:s,formattedProperties:a}),n&&r.get(o).write.add({property:s,formattedProperties:a});for(let r of e)t&&s.read.add({property:r,formattedProperties:a}),n&&s.write.add({property:r,formattedProperties:a});function c(){for(let e of nt.from(window.frames)){r.has(e)||r.set(e,{read:new at(s.read),write:new at(s.write)});let t=r.get(e).read;if(t.size>0){let n=nt.from(t);t.clear();for(let{property:t,formattedProperties:r}of n)gt("abort-on-iframe-property-read",e,t,r)}let n=r.get(e).write;if(n.size>0){let t=nt.from(n);n.clear();for(let{property:n,formattedProperties:r}of t)yt("abort-on-iframe-property-write",e,n,r)}}}c(),r.has(document)||(r.set(document,!0),function(e){let t;function n(e,t){for(let n of t){dt(e,n,r(e,n))}}function r(t,n){let r=t[n];return{get:()=>function(...t){let n;return n=o(r,this,t),e&&e(),n}}}function s(t,n){let r=st.getOwnPropertyDescriptor(t,n),{set:o}=r||{};return{set(t){let n;return n=i(o,this,t),e&&e(),n}}}n(ut,["appendChild","insertBefore","replaceChild"]),n(ft,["append","prepend","replaceWith","after","before","insertAdjacentElement","insertAdjacentHTML"]),t=s(ft,"innerHTML"),dt(ft,"innerHTML",t),t=s(ft,"outerHTML"),dt(ft,"outerHTML",t)}(c))}let{Object:mt}=window;function vt(e,t){if(!(e instanceof mt))return;let n=e,r=Le(t).split(".");if(0===r.length)return;for(let e=0;e<r.length-1;e++){let t=r[e];if(!m(n,t))return;if(n=n[t],!(n instanceof mt))return}let o=r[r.length-1];return m(n,o)?[n,o]:void 0}const bt=Le(/^\d+$/);function Et(e){switch(e){case"false":return!1;case"true":return!0;case"falseStr":return"false";case"trueStr":return"true";case"null":return null;case"noopFunc":return()=>{};case"trueFunc":return()=>!0;case"falseFunc":return()=>!1;case"emptyArray":return[];case"emptyObj":return{};case"undefined":return;case"":return e;default:return bt.test(e)?Ye(e):e}}function $t(e,t){if(!e||!e.length)return!0;const n=_e(),r=new rt(n),o=new URL(self.location.href);o.hash="";const s=/(.*?@)?(\S+)(:\d+):\d+\)?$/,i=[];for(let e of r.stack.split(/[\n\r]+/)){if(Le(e).includes(n))continue;e=Le(e).trim();const t=Le(s).exec(e);if(null===t)continue;let r=t[2];Le(r).startsWith("(")&&(r=Le(r).slice(1)),r===o.href?r="inlineScript":Le(r).startsWith("<anonymous>")&&(r="injectedScript");let a=t[1]?Le(t[1]).slice(0,-1):Le(e).slice(0,Le(t).index).trim();Le(a).startsWith("at")&&(a=Le(a).slice(2).trim());let c=t[3];Le(i).push(" "+`${a} ${r}${c}:1`.trim())}i[0]="stackDepth:"+(i.length-1);const a=Le(i).join("\n");for(let n of e){if(Xe(n).test(a))return t("info",`Found needle in stack trace: ${n}`),!0}return t("info",`Stack trace does not match any needle. Stack trace: ${a}`),!1}new ot;let{HTMLScriptElement:St,Object:Tt,ReferenceError:xt}=Le(window),jt=Tt.getPrototypeOf(St);const{Error:kt,Object:Rt,Array:Mt,Map:Lt}=Le(window);let Pt=null;function At(e,t,n){let r=e;for(const e of n){if(!r||!m(r,e))return!1;r=r[e]}if("string"==typeof r||"number"==typeof r){const e=r.toString();return t.test(e)}return!1}const{Array:Ot,Blob:Nt,Error:Ct,Object:It,Reflect:Wt}=Le(window),Ft=[];let{Error:Dt,URL:Ht}=Le(window),{cookie:zt}=Ae(document);const{Map:Bt,Object:Ut,Reflect:qt,WeakMap:Vt}=Le(window),Jt=window.EventTarget.prototype.addEventListener,Gt=window.EventTarget.prototype.removeEventListener,Xt=new Vt;let _t=[];let{console:Kt,document:Yt,getComputedStyle:Zt,isExtensionContext:Qt,variables:en,Array:tn,MutationObserver:nn,Object:rn,XPathEvaluator:on,XPathExpression:sn,XPathResult:an}=Le(window);const{querySelectorAll:cn}=Yt,ln=cn&&s(cn,Yt);function un(e,t=!1){return dn(e,ln.bind(Yt),Yt,t)}function fn(e,t,n,r){const o=t.getAttribute("xlink:href")||t.getAttribute("href");if(o){const i=ln(o)[0];if(!i&&He())return Kt.log("No elements found matching",o),!1;if(!(s=e)||0===s.length||s.every((e=>""===e.trim()))){const e=r.length>0?r:[];return n.push({element:i,rootParents:[...e,t]}),!1}const a=i.querySelectorAll.bind(i);return{nextBoundElement:i,nestedSelectorsString:e.join("^^"),next$$:a}}var s}function pn(e,t){const n=function(e,t=!1){try{const n=navigator.userAgent.includes("Firefox")?e.openOrClosedShadowRoot:browser.dom.openOrClosedShadowRoot(e);return null===n&&He()&&!t&&Kt.log("Shadow root not found or not added in element yet",e),n}catch(n){return He()&&!t&&Kt.log("Error while accessing shadow root",e,n),null}}(t);if(n){const{querySelectorAll:r}=n,o=r&&s(r,n).bind(n);return{nextBoundElement:t,nestedSelectorsString:":host "+e.join("^^"),next$$:o}}return!1}function dn(e,t,n,r,o=[]){if(e.includes("^^")){const[s,i,...a]=e.split("^^");let c,l;switch(i){case"svg":l=fn;break;case"sh":l=pn;break;default:return He()&&Kt.log(i," is not supported. Supported commands are: \n^^sh^^\n^^svg^^"),[]}c=""===s.trim()?[n]:t(s);const u=[];for(const e of c){const t=l(a,e,u,o);if(!t)continue;const{next$$:n,nestedSelectorsString:s,nextBoundElement:i}=t,c=dn(s,n,i,r,[...o,e]);c&&u.push(...c)}return u}const s=t(e);return r?[...s].map((e=>({element:e,rootParents:o.length>0?o:[]}))):s}const{assign:hn,setPrototypeOf:gn}=rn;class yn extends sn{evaluate(...e){return gn(o(super.evaluate,this,e),an.prototype)}}class wn extends on{createExpression(...e){return gn(o(super.createExpression,this,e),yn.prototype)}}function mn(e){if(en.hidden.has(e))return!1;!function(e){Qt&&"function"==typeof checkElement&&checkElement(e)}(e),en.hidden.add(e);let{style:t}=Le(e),n=Le(t,"CSSStyleDeclaration"),r=Le([]);const o=$();let{debugCSSProperties:s}=o;for(let[e,t]of s||[["display","none"]])n.setProperty(e,t,"important"),r.push([e,n.getPropertyValue(e)]);return new nn((()=>{for(let[e,t]of r){let r=n.getPropertyValue(e),o=n.getPropertyPriority(e);r==t&&"important"==o||n.setProperty(e,t,"important")}})).observe(e,{attributes:!0,attributeFilter:["style"]}),!0}function vn(e){let t=e;if(t.startsWith("xpath(")&&t.endsWith(")")){let t=function(e){let t=e;if(t.startsWith("xpath(")&&t.endsWith(")")){let e=t.slice(6,-1),n=(new wn).createExpression(e,null),r=an.ORDERED_NODE_SNAPSHOT_TYPE;return e=>{if(!e)return;let t=n.evaluate(Yt,r,null),{snapshotLength:o}=t;for(let n=0;n<o;n++)e(t.snapshotItem(n))}}return t=>un(e).forEach(t)}(e);return()=>{let e=Le([]);return t((t=>e.push(t))),e}}return()=>tn.from(un(e))}let{ELEMENT_NODE:bn,TEXT_NODE:En,prototype:$n}=Node,{prototype:Sn}=Element,{prototype:Tn}=HTMLElement,{console:xn,variables:jn,DOMParser:kn,Error:Rn,MutationObserver:Mn,Object:Ln,ReferenceError:Pn}=Le(window),{getOwnPropertyDescriptor:An}=Ln;const{CanvasRenderingContext2D:On,document:Nn,Map:Cn,MutationObserver:In,Object:Wn,Set:Fn,WeakSet:Dn}=Le(window);let Hn,zn=new Fn,Bn=new Dn;function Un(e,t,n,r){zn.add({canvasElement:e,rule:t,functionName:n,text:r})}Le(window);const{Map:qn,MutationObserver:Vn,Object:Jn,Set:Gn,WeakSet:Xn}=Le(window);let _n=Element.prototype,{attachShadow:Kn}=_n,Yn=new Xn,Zn=new qn,Qn=null;const{Array:er,Error:tr,JSON:nr,Map:rr,Object:or,Response:sr}=Le(window);let ir=null;let{Array:ar,Error:cr,JSON:lr,Map:ur,Object:fr,Response:pr}=Le(window),dr=null;const{Error:hr,Object:gr,Map:yr}=Le(window);let wr=null;function mr(e,t,n){if(!n.length){if("string"==typeof e||"number"==typeof e){const n=e.toString();return t.test(n)}return!1}let r=e;for(const e of n){if(!r||!m(r,e))return!1;r=r[e]}if("string"==typeof r||"number"==typeof r){const e=r.toString();return t.test(e)}return!1}let{Error:vr}=Le(window);let{Error:br,Map:Er,Object:$r,console:Sr}=Le(window),{toString:Tr}=Function.prototype,xr=EventTarget.prototype,{addEventListener:jr}=xr,kr=null;let{fetch:Rr}=Le(window),Mr=!1;const Lr=[],Pr=[],Ar=()=>{Mr||(window.fetch=l(Rr,((...e)=>{let[t]=e;if(Lr.length>0&&"string"==typeof t){let n;try{n=new URL(t)}catch(e){if(!(e instanceof TypeError))throw e;n=new URL(t,Le(document).location)}Lr.forEach((e=>e(n))),e[0]=n.href}return o(Rr,self,e).then((e=>{let t=e;return Pr.forEach((e=>{t=e(t)})),t}))})),Mr=!0)};let Or,{Map:Nr,Object:Cr,RegExp:Ir,Response:Wr}=Le(window);const{Error:Fr,Object:Dr,atob:Hr,btoa:zr,RegExp:Br}=Le(window);let Ur,qr,{RegExp:Vr,XMLHttpRequest:Jr,WeakMap:Gr}=Le(window);let Xr,{delete:_r,has:Kr}=c(URLSearchParams.prototype);const Yr={"abort-current-inline-script":function(e,t=null){const n=Ke(arguments),r=qe("abort-current-inline-script"),{mark:o,end:s}=Fe("abort-current-inline-script"),a=t?Xe(t):null,c=_e(),l=Le(document).currentScript;let u=window;const f=Le(e).split("."),p=Le(f).pop();for(let e of Le(f))if(u=u[e],!u||"object"!=typeof u&&"function"!=typeof u)return void r("warn",f," is not found");const{get:d,set:h}=Tt.getOwnPropertyDescriptor(u,p)||{};let g=u[p];void 0===g&&r("warn","The property",p,"doesn't exist yet. Check typos.");const y=()=>{const e=Le(document).currentScript;if(e instanceof jt&&""==Le(e,"HTMLScriptElement").src&&e!=l&&(!a||a.test(Le(e).textContent)))throw r("success",f," is aborted \n",e,"\nFILTER: abort-current-inline-script",n),new xt(c)},w={get(){return y(),d?i(d,this):g},set(e){y(),h?i(h,this,e):g=e}};o(),dt(u,p,w),s(),ht(c)},"abort-on-iframe-property-read":function(...e){const{mark:t,end:n}=Fe("abort-on-iframe-property-read");t(),wt(e,!0,!1),n()},"abort-on-iframe-property-write":function(...e){const{mark:t,end:n}=Fe("abort-on-iframe-property-write");t(),wt(e,!1,!0),n()},"abort-on-property-read":function(e,t){const n=!("false"===t),r=Ke(arguments),{mark:o,end:s}=Fe("abort-on-property-read");o(),gt("abort-on-property-read",window,e,r,n),s()},"abort-on-property-write":function(e,t){const n=Ke(arguments),{mark:r,end:o}=Fe("abort-on-property-write"),s=!("false"===t);r(),yt("abort-on-property-write",window,e,n,s),o()},"array-override":function(e,t,n="false",r,s){if(!e)throw new kt("[array-override snippet]: Missing method to override.");if(!t)throw new kt("[array-override snippet]: Missing needle.");Pt||(Pt=new Lt);let i=qe("array-override");const{mark:a,end:c}=Fe("array-override"),u=Ke(arguments);if("push"!==e||Pt.has("push"))if("includes"!==e||Pt.has("includes")){if("forEach"===e&&!Pt.has("forEach")){a();const{forEach:e}=Mt.prototype;Pt.set("forEach",Le([])),Rt.defineProperty(window.Array.prototype,"forEach",{value:l(e,(function(t,n){const r=Pt.get("forEach");return o(e,this,[function(e,s,a){for(const{needleRegex:t,pathSegments:n,stackNeedles:o}of r)if(n.length||"string"!=typeof e&&"number"!=typeof e){if(n.length&&"object"==typeof e&&null!==e&&At(e,t,n)&&$t(o,i))return void i("success",`Array.forEach skipped callback for object containing needle: ${t}\nFILTER: array-override ${u}`)}else{const n=e.toString();if(n.match&&n.match(t)&&$t(o,i))return void i("success",`Array.forEach skipped callback for item matching needle: ${t}\nFILTER: array-override ${u}`)}return o(t,n||this,[e,s,a])},n])}))}),i("info","Wrapped Array.prototype.forEach"),c()}}else{a();const{includes:e}=Mt.prototype;Pt.set("includes",Le([])),Rt.defineProperty(window.Array.prototype,"includes",{value:l(e,(function(t){const n=Pt.get("includes");for(const{needleRegex:e,retVal:r,pathSegments:o,stackNeedles:s}of n)if(o.length||"string"!=typeof t&&"number"!=typeof t){if(o.length&&"object"==typeof t&&null!==t&&At(t,e,o)&&$t(s,i))return i("success",`Array.includes returned ${r} for object containing ${e}\nFILTER: array-override ${u}`),r}else if(t.toString().match&&t.toString().match(e)&&$t(s,i))return i("success",`Array.includes returned ${r} for ${e}\nFILTER: array-override ${u}`),r;return o(e,this,arguments)}))}),i("info","Wrapped Array.prototype.includes"),c()}else{a();const{push:e}=Mt.prototype;Pt.set("push",Le([])),Rt.defineProperty(window.Array.prototype,"push",{value:l(e,(function(t){const n=Pt.get("push");for(const{needleRegex:e,pathSegments:r,stackNeedles:o}of n)if(r.length||"string"!=typeof t&&"number"!=typeof t){if(r.length&&"object"==typeof t&&null!==t&&At(t,e,r)&&$t(o,i))return void i("success",`Array.push is ignored for object containing needle: ${e}\nFILTER: array-override ${u}`)}else{const n=t.toString();if(n.match&&n.match(e)&&$t(o,i))return void i("success",`Array.push is ignored for needle: ${e}\nFILTER: array-override ${u}`)}return o(e,this,arguments)}))}),i("info","Wrapped Array.prototype.push"),c()}const f=Xe(t);let p=[];r&&(p=r.split("."));let d=[];s&&(d=s.split(",").map((e=>e.trim())));const h=Pt.get(e),g="true"===n;h.push({needleRegex:f,retVal:g,pathSegments:p,stackNeedles:d}),Pt.set(e,h)},"blob-override":function(e,t="",n=null){if(!e)throw new Ct("[blob-override snippet]: Missing parameter search.");const r=qe("blob-override"),o=Ke(arguments),{mark:s,end:i}=Fe("blob-override");if(s(),Ft.push({match:Xe(e),replaceWith:t,needle:n?Xe(n):null,formattedArgs:o}),Ft.length>1)return;const a=Nt;function c(e,t={}){if(Ot.isArray(e)){let t=Le(e).join("");for(const e of Le(Ft))e.needle&&!e.needle.test(t)||!e.match.test(t)||(t=t.replace(e.match,e.replaceWith),r("success",`Replaced: ${e.match}${e.replaceWith},\nFILTER: blob-override ${e.formattedArgs}`));e=[t]}const n=Wt.construct(a,[e,t]);return It.setPrototypeOf(n,c.prototype),n}c.prototype=a.prototype,It.setPrototypeOf(c,a),window.Blob=c,r("info","Wrapped Blob constructor in context "),i()},"cookie-remover":function(e,t=!1){if(!e)throw new Dt("[cookie-remover snippet]: No cookie to remove.");const n=Ke(arguments);let r=qe("cookie-remover");const{mark:o,end:s}=Fe("cookie-remover");let i=Xe(e);if(!Le(/^http|^about/).test(location.protocol))return void r("warn","Snippet only works for http or https and about.");function a(){return Le(zt()).split(";").filter((e=>i.test(Le(e).split("=")[0])))}const c=()=>{r("info","Parsing cookies for matches"),o();for(const e of Le(a())){let t=Le(location.hostname);!t&&Le(location.ancestorOrigins)&&Le(location.ancestorOrigins[0])&&(t=new Ht(Le(location.ancestorOrigins[0])).hostname);const o=Le(e).split("=")[0],s="expires=Thu, 01 Jan 1970 00:00:00 GMT",i="path=/",a=t.split(".");for(let e=a.length;e>0;e--){const t=a.slice(a.length-e).join(".");zt(`${Le(o).trim()}=;${s};${i};domain=${t}`),zt(`${Le(o).trim()}=;${s};${i};domain=.${t}`),r("success",`Set expiration date on ${o}`,"\nFILTER: cookie-remover",n)}}s()};if(c(),t){let e=a();setInterval((()=>{let t=a();if(t!==e)try{c()}finally{e=t}}),1e3)}},profile:function(){We=!1},debug:function(){De=!0},"event-override":function(e,t,n=null){const r=Ke(arguments),s={eventType:e,mode:t,needle:n?Xe(n):null,formattedArgs:r};if(_t.includes(s)||_t.push(s),_t.length>1)return;let a=qe("[event-override]");const{mark:c,end:u}=Fe("event-override"),f=Ut.getOwnPropertyDescriptor(window.EventTarget.prototype,"addEventListener");f.configurable&&Ut.defineProperty(window.EventTarget.prototype,"addEventListener",{...f,value:l(Jt,(function(e,t,n){c();const r=_t.filter((t=>t.eventType===e));if(!r.length||e!==r[0].eventType)return u(),o(Jt,this,arguments);const s=r.find((e=>"disable"===e.mode&&(!e.needle||e.needle.test(t.toString()))));if(s)return a("success",`Disabling ${s.eventType} event, \nFILTER: event-override ${s.formattedArgs}`),void u();const l=r.filter((e=>"trusted"===e.mode&&(!e.needle||e.needle.test(t.toString()))));if("function"!=typeof t&&(!t||"function"!=typeof t.handleEvent)||!l.length||e!==l[0].eventType)return u(),o(Jt,this,arguments);const f=function(e){const n=new Proxy(e,{get(t,n){if("isTrusted"===n)return a("success",`Providing trusted value for ${e.type} event`),!0;const r=qt.get(t,n);return"function"==typeof r?function(...e){return o(r,t,e)}:r}});return"function"==typeof t?i(t,this,n):i(t.handleEvent,t,n)};return f.originalListener=t,Xt.has(t)||Xt.set(t,new Bt),Xt.get(t).set(e,f),a("info",`\nWrapping event listener for ${e}`),u(),o(Jt,this,[e,f,n])}))});const p=Ut.getOwnPropertyDescriptor(window.EventTarget.prototype,"removeEventListener");p.configurable&&Ut.defineProperty(window.EventTarget.prototype,"removeEventListener",{...p,value:l(Gt,(function(e,t,n){if(t&&Xt.has(t)&&Xt.get(t).has(e)){const r=Xt.get(t).get(e);return Xt.get(t).delete(e),o(Gt,this,[e,r,n])}return o(Gt,this,arguments)}))}),a("info","Initialized event-override snippet")},"freeze-element":function(e,t="",...n){let r,s,a=!1,c=!1,l=Le(n).filter((e=>!h(e))),u=Le(n).filter((e=>h(e))).map(Xe),f=_e(),p=vn(e);!function(){let n=Le(t).split("+");1===n.length&&""===n[0]&&(n=[]);for(let t of n)switch(t){case"subtree":a=!0;break;case"abort":c=!0;break;default:throw new Rn("[freeze] Unknown option passed to the snippet. [selector]: "+e+" [option]: "+t)}}();let d={selector:e,shouldAbort:c,rid:f,exceptionSelectors:l,regexExceptions:u,changeId:0};function h(e){return e.length>=2&&"/"==e[0]&&"/"==e[e.length-1]}function g(){s=p(),y(s,!1)}function y(e,t=!0){for(let n of e)jn.frozen.has(n)||(jn.frozen.set(n,d),!t&&a&&new Mn((e=>{for(let t of Le(e))y(Le(t,"MutationRecord").addedNodes)})).observe(n,{childList:!0,subtree:!0}),a&&Le(n).nodeType===bn&&y(Le(n).childNodes))}function w(e,...t){Ue(`[freeze][${e}] `,...t)}function m(e,t,n,r){let o=r.selector,s=r.changeId,i="string"==typeof e,a=r.shouldAbort?"aborting":"watching";switch(xn.groupCollapsed(`[freeze][${s}] ${a}: ${o}`),n){case"appendChild":case"append":case"prepend":case"insertBefore":case"replaceChild":case"insertAdjacentElement":case"insertAdjacentHTML":case"insertAdjacentText":case"innerHTML":case"outerHTML":w(s,i?"text: ":"node: ",e),w(s,"added to node: ",t);break;case"replaceWith":case"after":case"before":w(s,i?"text: ":"node: ",e),w(s,"added to node: ",Le(t).parentNode);break;case"textContent":case"innerText":case"nodeValue":w(s,"content of node: ",t),w(s,"changed to: ",e)}w(s,`using the function "${n}"`),xn.groupEnd(),r.changeId++}function v(e,t){if(t)for(let n of t)if(n.test(e))return!0;return!1}function b(e){throw new Pn(e)}function E(e,t,n,r){let o=new kn,{body:s}=Le(o.parseFromString(e,"text/html")),i=$(Le(s).childNodes,t,n,r);return Le(i).map((e=>{switch(Le(e).nodeType){case bn:return Le(e).outerHTML;case En:return Le(e).textContent;default:return""}})).join("")}function $(e,t,n,r){let o=Le([]);for(let s of e)S(s,t,n,r)&&o.push(s);return o}function S(e,t,n,r){let o=r.shouldAbort,s=r.regexExceptions,i=r.exceptionSelectors,a=r.rid;if("string"==typeof e){let i=e;return!!v(i,s)||(He()&&m(i,t,n,r),o&&b(a),He())}let c=e;switch(Le(c).nodeType){case bn:return!!function(e,t){if(t){let n=Le(e);for(let e of t)if(n.matches(e))return!0}return!1}(c,i)||(o&&(He()&&m(c,t,n,r),b(a)),!!He()&&(mn(c),m(c,t,n,r),!0));case En:return!!v(Le(c).textContent,s)||(He()&&m(c,t,n,r),o&&b(a),!1);default:return!0}}function T(e,t,n,r){let s=An(e,t)||{},a=s.get&&i(s.get,e)||s.value;if(a)return{get:()=>function(...e){if(n(this)){let n=r(this);if(n){let r=e[0];if(!S(r,this,t,n))return r}}return o(a,this,e)}}}function x(e,t,n,r){let s=An(e,t)||{},a=s.get&&i(s.get,e)||s.value;if(a)return{get:()=>function(...e){if(!n(this))return o(a,this,e);let s=r(this);if(!s)return o(a,this,e);let i=$(e,this,t,s);return i.length>0?o(a,this,i):void 0}}}function j(e,t,n,r){let s=An(e,t)||{},a=s.get&&i(s.get,e)||s.value;if(a)return{get:()=>function(...e){let[s,c]=e,l="afterbegin"===s||"beforeend"===s;if(n(this,l)){let e=r(this,l);if(e){let n,r=l?this:Le(this).parentNode;switch(t){case"insertAdjacentElement":if(!S(c,r,t,e))return c;break;case"insertAdjacentHTML":return n=E(c,r,t,e),n?i(a,this,s,n):void 0;case"insertAdjacentText":if(!S(c,r,t,e))return}}}return o(a,this,e)}}}function k(e,t,n,r){let o=An(e,t)||{},{set:s}=o;if(s)return{set(e){if(!n(this))return i(s,this,e);let o=r(this);if(!o)return i(s,this,e);let a=E(e,this,t,o);return a?i(s,this,a):void 0}}}function R(e,t,n,r){let o=An(e,t)||{},{set:s}=o;if(s)return{set(e){if(!n(this))return i(s,this,e);let o=r(this);return o?S(e,this,t,o)?i(s,this,e):void 0:i(s,this,e)}}}jn.frozen.has(document)||(jn.frozen.set(document,!0),function(){let e;function t(e){return e&&jn.frozen.has(e)}function n(e){try{return e&&(jn.frozen.has(e)||jn.frozen.has(Le(e).parentNode))}catch(e){return!1}}function r(e,t){try{return e&&(jn.frozen.has(e)&&t||jn.frozen.has(Le(e).parentNode)&&!t)}catch(e){return!1}}function o(e){return jn.frozen.get(e)}function s(e){try{if(jn.frozen.has(e))return jn.frozen.get(e);let t=Le(e).parentNode;return jn.frozen.get(t)}catch(e){}}function i(e,t){try{if(jn.frozen.has(e)&&t)return jn.frozen.get(e);let n=Le(e).parentNode;return jn.frozen.get(n)}catch(e){}}e=T($n,"appendChild",t,o),dt($n,"appendChild",e),e=T($n,"insertBefore",t,o),dt($n,"insertBefore",e),e=T($n,"replaceChild",t,o),dt($n,"replaceChild",e),e=x(Sn,"append",t,o),dt(Sn,"append",e),e=x(Sn,"prepend",t,o),dt(Sn,"prepend",e),e=x(Sn,"replaceWith",n,s),dt(Sn,"replaceWith",e),e=x(Sn,"after",n,s),dt(Sn,"after",e),e=x(Sn,"before",n,s),dt(Sn,"before",e),e=j(Sn,"insertAdjacentElement",r,i),dt(Sn,"insertAdjacentElement",e),e=j(Sn,"insertAdjacentHTML",r,i),dt(Sn,"insertAdjacentHTML",e),e=j(Sn,"insertAdjacentText",r,i),dt(Sn,"insertAdjacentText",e),e=k(Sn,"innerHTML",t,o),dt(Sn,"innerHTML",e),e=k(Sn,"outerHTML",n,s),dt(Sn,"outerHTML",e),e=R($n,"textContent",t,o),dt($n,"textContent",e),e=R(Tn,"innerText",t,o),dt(Tn,"innerText",e),e=R($n,"nodeValue",t,o),dt($n,"nodeValue",e)}()),r=new Mn(g),r.observe(document,{childList:!0,subtree:!0}),g()},"hide-if-canvas-contains":function(e,t="canvas"){const n=qe("hide-if-canvas-contains"),r=Ke(arguments),{mark:s,end:i}=Fe("hide-if-canvas-contains");if(!e)return void n("error","The parameter 'search' is required");if(!Hn){s();const c=On.prototype;function u(e){const t=c[e];Wn.defineProperty(window.CanvasRenderingContext2D.prototype,e,{value:l(t,(function(r,...s){for(const[t,o]of Hn)if(t.test(r)){const t=this.canvas;let s=Le(t).closest(o.selector);s&&!Bn.has(s)?(mn(s),Bn.add(s),n("success","Matched: ",s,`\nFILTER: hide-if-canvas-contains ${o.formattedArguments}`)):Un(t,o,e,r)}return o(t,this,[r,...s])}))})}n("info","CanvasRenderingContext2D proxied"),u("fillText"),u("strokeText"),Hn=new Cn;new In((e=>{for(let t of Le(e))"childList"===t.type&&zn.forEach((({canvasElement:e,rule:t,functionName:n,text:r})=>{let o=Le(e).closest(t.selector);o&&!Bn.has(o)&&(mn(o),Bn.add(o),zn.delete({canvasElement:e,rule:t,functionName:n,text:r}),qe("hide-if-canvas-contains")("success","Matched: ",o,`\nFILTER: hide-if-canvas-contains ${t.formattedArguments}`))}))})).observe(Nn,{childList:!0,subtree:!0}),i()}const a=Xe(e);Hn.set(a,{selector:t,formattedArguments:r})},"hide-if-shadow-contains":function(e,t="*"){const n=Ke(arguments);let r=`${e}\\${t}`;Zn.has(r)||Zn.set(r,[Xe(e),t,Be],n);const s=qe("hide-if-shadow-contains"),{mark:i,end:a}=Fe("hide-if-shadow-contains");Qn||(Qn=new Vn((e=>{i();let t=new Gn;for(let{target:r}of Le(e)){let e=Le(r).parentNode;for(;e;)[r,e]=[e,Le(r).parentNode];if(!Yn.has(r)&&!t.has(r)){t.add(r);for(let[e,t,o]of Zn.values())if(e.test(Le(r).textContent)){let e=Le(r.host).closest(t);e&&(o(),Le(r).appendChild(document.createElement("style")).textContent=":host {display: none !important}",mn(e),Yn.add(r),s("success","Hiding: ",e,`\nFILTER: hide-if-shadow-contains ${n}`)),a()}}}})),Jn.defineProperty(_n,"attachShadow",{value:l(Kn,(function(){let e=o(Kn,this,arguments);return s("info","attachShadow is called for: ",e),Qn.observe(e,{childList:!0,characterData:!0,subtree:!0}),e}))}))},"json-override":function(e,t,n="",r=""){if(!e)throw new tr("[json-override snippet]: Missing paths to override.");if(void 0===t)throw new tr("[json-override snippet]: No value to override with.");if(!ir){let i=qe("json-override");const{mark:a,end:c}=Fe("json-override");function u(e,t){for(let{formattedArgs:n,prune:r,needle:o,filter:s,value:i}of ir.values())if(!s||s.test(t)){if(Le(o).some((t=>!vt(e,t))))return e;for(let t of r)t.includes("{}")||t.includes("[]")?f(e,t,i,n):p(e,t,i,n)}return e}function f(e,t,n,r){let o=Le(t).split("."),s=e;for(let e=0;e<o.length;e++){let a=o[e];if("[]"===a)return void(er.isArray(s)&&(i("info",`Iterating over array at: ${a}`),Le(s).forEach((t=>{null!=t&&f(t,o.slice(e+1).join("."),n,r)}))));if("{}"===a)return void(s&&"object"==typeof s&&(i("info",`Iterating over object at: ${a}`),or.keys(s).forEach((t=>{let i=s[t];null!=i&&f(i,o.slice(e+1).join("."),n,r)}))));if(!s||"object"!=typeof s||!m(s,a))return;e===o.length-1?(i("success",`Found ${t}, replaced it with ${n}`,`\nFILTER: json-override ${r}`),s[a]=Et(n)):s=s[a]}}function p(e,t,n,r){let o=vt(e,t);void 0!==o&&(i("success",`Found ${t}, replaced it with ${n}`,`\nFILTER: json-override ${r}`),o[0][o[1]]=Et(n))}a();let{parse:d}=nr;ir=new rr,or.defineProperty(window.JSON,"parse",{value:l(d,(function(e){return u(o(d,this,arguments),e)}))}),i("info","Wrapped JSON.parse for override");let{json:h}=sr.prototype;or.defineProperty(window.Response.prototype,"json",{value:l(h,(function(e){return o(h,this,arguments).then((t=>u(t,e)))}))}),i("info","Wrapped Response.json for override"),c()}const s=Ke(arguments);ir.set(e,{formattedArgs:s,prune:Le(e).split(/ +/),needle:n.length?Le(n).split(/ +/):[],filter:r?Xe(r):null,value:t})},"json-prune":function(e,t="",n=""){if(!e)throw new cr("Missing paths to prune");if(!dr){let s=qe("json-prune");const{mark:i,end:a}=Fe("json-prune");function c(e){for(let{prune:t,needle:n,stackNeedle:r,formattedArgs:o}of dr.values()){if(Le(n).length>0&&Le(n).some((t=>!vt(e,t))))return e;if(Le(r)&&Le(r).length>0&&!$t(r,s))return e;for(let n of t)n.includes("{}")||n.includes("[]")||n.includes("{-}")||n.includes("[-]")?u(e,n,o):p(e,n,o)}return e}function u(e,t,n){let r=Le(t).split("."),o=e;for(let e=0;e<r.length;e++){let i=r[e];if("[]"===i)return void(ar.isArray(o)&&(s("info",`Iterating over array at: ${i}`),Le(o).forEach((t=>u(t,r.slice(e+1).join("."),n)))));if("[-]"===i){if(ar.isArray(o)){s("info",`Iterating over array with element removal at: ${i}`);let t=r.slice(e+1).join("."),a=[];Le(o).forEach(((e,n)=>{f(e,t)&&a.push(n)}));for(let e=a.length-1;e>=0;e--)s("success",`Found element at index ${a[e]} matching ${t} and removed entire element, \nFILTER: json-prune ${n}`),o.splice(a[e],1)}return}if("{}"===i)return void("object"==typeof o&&null!==o&&(s("info",`Iterating over object at: ${i}`),fr.keys(o).forEach((t=>u(o[t],r.slice(e+1).join("."),n)))));if("{-}"===i){if("object"==typeof o&&null!==o){s("info",`Iterating over object with element removal at: ${i}`);let t=r.slice(e+1).join("."),a=[];fr.keys(o).forEach((e=>{f(o[e],t)&&a.push(e)})),a.forEach((e=>{s("success",`Found object key ${e} matching ${t} and removed entire element, \nFILTER: json-prune ${n}`),delete o[e]}))}return}if(!o||"object"!=typeof o||!m(o,i))return;e===r.length-1?(s("success",`Found ${t} and deleted, \nFILTER: json-prune ${n}`),delete o[i]):o=o[i]}}function f(e,t){if(!t||""===t)return!0;let n=Le(t).split("."),r=e;for(let e=0;e<n.length;e++){let t=n[e];if("[]"===t)return!!ar.isArray(r)&&Le(r).some((t=>f(t,n.slice(e+1).join("."))));if("{}"===t)return"object"==typeof r&&null!==r&&fr.keys(r).some((t=>f(r[t],n.slice(e+1).join("."))));if(!r||"object"!=typeof r||!m(r,t))return!1;if(e===n.length-1)return!0;r=r[t]}return!1}function p(e,t,n){let r=vt(e,t);void 0!==r&&(s("success",`Found ${t} and deleted`,`\nFILTER: json-prune ${n}`),delete r[0][r[1]])}i();let{parse:d}=lr;dr=new ur,fr.defineProperty(window.JSON,"parse",{value:l(d,(function(){return c(o(d,this,arguments))}))}),s("info","Wrapped JSON.parse for prune");let{json:h}=pr.prototype;fr.defineProperty(window.Response.prototype,"json",{value:l(h,(function(){return o(h,this,arguments).then((e=>c(e)))}))}),s("info","Wrapped Response.json for prune"),a()}const r=Ke(arguments);dr.set(e,{formattedArgs:r,prune:Le(e).split(/ +/),needle:t.length?Le(t).split(/ +/):[],stackNeedle:n.length?Le(n).split(/ +/):[]})},"map-override":function(e,t,n="",r,s){if(!e)throw new hr("[map-override snippet]: Missing method to override.");if(!t)throw new hr("[map-override snippet]: Missing needle.");wr||(wr=new yr);let a=qe("map-override");const{mark:c,end:u}=Fe("map-override"),{set:f,get:p,has:d}=yr.prototype,h=Ke(arguments);"set"!==e||wr.has("set")?"get"!==e||wr.has("get")?"has"!==e||wr.has("has")||(c(),i(f,wr,"has",Le([])),gr.defineProperty(window.Map.prototype,"has",{value:l(d,(function(e){const t=i(p,wr,"has");for(const{needleRegex:n,retVal:r,stackNeedles:o}of t)if("string"==typeof e||"number"==typeof e){const t=e.toString();if(n.test(t)&&$t(o,a))return a("success",`Map.has returned ${r} for key: ${t}\nFILTER: map-override ${h}`),r}return o(d,this,arguments)}))}),a("info","Wrapped Map.prototype.has"),u()):(c(),i(f,wr,"get",Le([])),gr.defineProperty(window.Map.prototype,"get",{value:l(p,(function(e){const t=i(p,wr,"get");for(const{needleRegex:n,retVal:r,stackNeedles:o}of t)if("string"==typeof e||"number"==typeof e){const t=e.toString();if(n.test(t)&&$t(o,a))return a("success",`Map.get returned ${r} for key: ${t}\nFILTER: map-override ${h}`),r}return o(p,this,arguments)}))}),a("info","Wrapped Map.prototype.get"),u()):(c(),i(f,wr,"set",Le([])),gr.defineProperty(window.Map.prototype,"set",{value:l(f,(function(e,t){const n=i(p,wr,"set");for(const{needleRegex:e,pathSegments:r,stackNeedles:o}of n)if(mr(t,e,r)&&$t(o,a))return a("success",`Map.set is ignored for value matching needle: ${e}\nFILTER: map-override ${h}`),this;return o(f,this,arguments)}))}),a("info","Wrapped Map.prototype.set"),u());const g=Xe(t);let y=[];r&&(y=r.split("."));let w=[];s&&(w=s.split(",").map((e=>e.trim())));const m=i(p,wr,e);let v;"get"===e?v=""===n?void 0:n:"has"===e&&(v="true"===n),m.push({needleRegex:g,retVal:v,pathSegments:y,stackNeedles:w}),i(f,wr,e,m)},"override-property-read":function(e,t,n){if(!e)throw new vr("[override-property-read snippet]: No property to override.");if(void 0===t)throw new vr("[override-property-read snippet]: No value to override with.");const r=Ke(arguments);let o=qe("override-property-read");const{mark:s,end:i}=Fe("override-property-read");let a=Et(t);o("info",`Overriding ${e}.`);const c=!("false"===n);s(),dt(window,e,{get:()=>(o("success",`${e} override done.`,"\nFILTER: override-property-read",r),a),set(){}},c),i()},"prevent-listener":function(e,t,n){if(!e)throw new br("[prevent-listener snippet]: No event type.");if(!kr){kr=new Er;let e=qe("[prevent]");const{mark:t,end:n}=Fe("prevent-listener");$r.defineProperty(xr,"addEventListener",{value:l(jr,(function(r,s){t();for(let{evt:t,handlers:n,selectors:o}of kr.values()){if(!t.test(r))continue;let a=this instanceof Element;for(let l=0;l<n.length;l++){const u=n[l],f=o[l];if(!f||a&&Le(this).matches(f)){if(u){const t=function(){try{const e=String("function"==typeof s?s:s.handleEvent);return u.test(e)}catch(t){return e("error","Error while trying to stringify listener: ",t),!1}};if(!function(){try{const e=i(Tr,"function"==typeof s?s:s.handleEvent);return u.test(e)}catch(t){return e("error","Error while trying to stringify listener: ",t),!1}}()&&!t())continue}return void(He()&&(Sr.groupCollapsed("DEBUG [prevent] was successful",`\nFILTER: prevent-listener ${c}`),e("success",`type: ${r} matching ${t}`),e("success","handler:",s),u&&e("success",`matching ${u}`),f&&e("success","on element: ",this,` matching ${f}`),e("success","was prevented from being added"),Sr.groupEnd()))}}}return n(),o(jr,this,arguments)}))}),e("info","Wrapped addEventListener")}const r=Ke(arguments);kr.has(e)||kr.set(e,{evt:Xe(e),handlers:[],selectors:[],formattedArgs:r});let{handlers:s,selectors:a,formattedArgs:c}=kr.get(e);s.push(t?Xe(t):null),a.push(n)},"replace-fetch-response":function(e,t="",n=null){const r=Ke(arguments),o=qe("replace-fetch-response"),{mark:s,end:i}=Fe("replace-fetch-response");if(!e)return void o("error","The parameter 'search' is required");if(!Or){const e=e=>{s();return Le(e).clone().text().then((t=>{let n=Le(t);for(const[e,{replacement:r,needle:s,formattedArgs:i}]of Or){if(s){if(!Xe(s).test(n)){He()&&(console.groupCollapsed(`DEBUG [replace-fetch-response] warn: '${s}' not found in fetch response`),o("warn",`${n}`),console.groupEnd());continue}He()&&(console.groupCollapsed(`DEBUG [replace-fetch-response] success: '${s}' found in fetch response`),o("info",`${n}`),console.groupEnd())}n=n.replace(e,r),He()&&n.toString()!==t.toString()&&(console.groupCollapsed(`DEBUG [replace-fetch-response] success: '${e}' replaced with '${r}' in fetch response`,`\nFILTER: replace-fetch-response ${i}`),o("success",`${n}`),console.groupEnd())}if(n.toString()===t.toString())return e;const r=new Wr(n.toString(),{status:e.status,statusText:e.statusText,headers:e.headers});return Cr.defineProperties(r,{ok:{value:e.ok},redirected:{value:e.redirected},type:{value:e.type},url:{value:e.url}}),i(),r}))};Or=new Nr,o("info","Network API proxied"),a=e,Pr.push(a),Ar()}var a;const c=Xe(e),l=new Ir(c,"g");Or.set(l,{replacement:t,needle:n,formattedArgs:r})},"replace-outbound-value":function(e,t="",n="",r="",s="",i=""){if(!e)throw new Fr("[replace-outbound-value snippet]: Missing method path.");let a=qe("replace-outbound-value");const{mark:c,end:u}=Fe("replace-outbound-value");function f(e,t,n,r){if("base64"===r)try{if(function(e){try{if(""===e)return!1;const t=Hr(e),n=zr(t),r=Le(e).replace(/=+$/,"").toString();return Le(n).replace(/=+$/,"").toString()===r}catch(e){return!1}}(e)){const r=Hr(e);a("info",`Decoded base64 content: ${r}`);const o=t?Le(r).replace(t,n).toString():r;a("info",o!==r?`Modified decoded content: ${o}`:"Decoded content was not modified");const s=zr(o);return a("info",`Re-encoded to base64: ${s}`),s}a("info",`Content is plain text: ${e}`);const r=t?Le(e).replace(t,n).toString():e;a("info",r!==e?`Modified plain text content: ${r}`:"Plain text content was not modified");const o=zr(r);return a("info",`Encoded to base64: ${o}`),o}catch(t){return a("info",`Error processing base64 content: ${t.message}`),e}return t?Le(e).replace(t,n).toString():e}function p(e,t,n,r,o,s){const i=n?new Br(Xe(n),"g"):null;if(t.length&&"object"==typeof e&&null!==e){const c=n?function(e,t,n,r,o){if(!t.length)return e;let s=e;for(let n=0;n<t.length-1;n++){if(!s||"object"!=typeof s)return a("info",`Cannot navigate to path: property '${t[n]}' not found`),e;s=s[t[n]]}const i=t[t.length-1];if(!s||"object"!=typeof s||!(i in s))return a("info",`Target property '${i}' not found at path`),e;const c=s[i];if("string"!=typeof c)return a("info","Property at path is not a string: "+typeof c),e;const l=f(c,n,r,o);if(l!==c){const n=JSON.parse(JSON.stringify(e));let r=n;for(let e=0;e<t.length-1;e++)r=r[t[e]];return r[i]=l,a("info",`Replaced value at path '${t.join(".")}': '${c}' -> '${l}'`),n}return e}(e,t,i,r,o):e;return c!==e&&a("success",`Replaced outbound value\nFILTER: replace-outbound-value ${s}`),c}if("string"==typeof e){n||a("info",`Original text content: ${e}`);const t=n?f(e,i,r,o):e;return t!==e&&a("success",`Replaced outbound value: ${t} \nFILTER: replace-outbound-value ${s}`),t}return e}Ke(arguments),c();const d=function(e,t){let n=e,r=Le(t).split(".");for(let e=0;e<r.length-1;e++){let t=r[e];if(!n||"object"!=typeof n&&"function"!=typeof n)return{base:n,prop:t,remainingPath:r.slice(e).join("."),success:!1};n=n[t]}return{base:n,prop:r[r.length-1],success:!0}}(window,e);if(!d.success)return a("error",`Could not reach the end of the prop chain: ${e}. Remaining path: ${d.remainingPath}`),void u();const{base:h,prop:g}=d,y=h[g];if(!y||"function"!=typeof y)return a("error",`Could not retrieve the method: ${e}`),void u();let w=[];s&&(w=Le(s).split("."));let m=[];i&&(m=Le(i).split(",").map((e=>e.trim())));let v=!1;Dr.defineProperty(h,g,{value:l(y,(function(){if(v)return o(y,this,arguments);v=!0;const e=o(y,this,arguments);if(m.length&&!$t(m,a))return v=!1,e;if(e&&"function"==typeof e.then)return a("info","Method returned a Promise, modifying resolved value"),v=!1,e.then((e=>{const o="object"==typeof e?JSON.stringify(e):e;return a("info",`Promise resolved with value: ${o}`),p(e,w,t,n,r,s)})).catch((e=>{throw a("info",`Promise rejected: ${e.message}`),e}));const i=p(e,w,t,n,r,s);return v=!1,i}))}),a("info",`Wrapped ${e}`),u()},"replace-xhr-response":function(e,t="",n=null){const r=Ke(arguments),o=qe("replace-xhr-response"),{mark:s,end:i}=Fe("replace-xhr-response");if(!e)return void o("error","The parameter 'pattern' is required");Ur||(Ur=new Gr,qr=new Map,o("info","XMLHttpRequest proxied"),window.XMLHttpRequest=class extends Jr{open(e,t,...n){const r={method:e,url:t};return Ur.set(this,r),super.open(e,t,...n)}send(...e){return super.send(...e)}get response(){const e=super.response,t=Ur.get(this);if(void 0===t)return e;s();const n="string"==typeof e?e.length:void 0;if(t.lastResponseLength!==n&&(t.response=void 0,t.lastResponseLength=n),void 0!==t.response)return t.response;if("string"!=typeof e)return t.response=e;let r=e;for(const[t,{replacement:n,needle:s,formattedArgs:i}]of qr){if(s){if(!Xe(s).test(r)){He()&&(console.groupCollapsed(`DEBUG [replace-xhr-response] warn: '${s}' not found in XHR response`),o("warn",r),console.groupEnd());continue}He()&&(console.groupCollapsed(`DEBUG [replace-xhr-response] success: '${s}' found in XHR response`),o("info",r),console.groupEnd())}r=Le(r).replace(t,n).toString(),He()&&e.toString()!==r.toString()&&(console.groupCollapsed(`DEBUG [replace-xhr-response] success: '${t}' replaced with '${n}' in XHR response`,`\nFILTER: replace-xhr-response ${i}`),o("success",r),console.groupEnd())}return i(),t.response=r.toString()}get responseText(){const e=this.response;return"string"!=typeof e?super.responseText:e}});const a=Xe(e),c=new Vr(a,"g");qr.set(c,{replacement:t,needle:n,formattedArgs:r})},"strip-fetch-query-parameter":function(e,t=null){const n=Ke(arguments),r=qe("strip-fetch-query-parameter"),{mark:o,end:s}=Fe("strip-fetch-query-parameter"),i=e=>{o();for(let[t,n]of Xr.entries()){const{reg:o,args:s}=n;o&&!o.test(e)||Kr(e.searchParams,t)&&(r("success",`${t} has been stripped from url ${e}`,`\nFILTER: strip-fetch-query-parameter ${s}`),_r(e.searchParams,t))}s()};var a;Xr||(Xr=new Map,a=i,Lr.push(a),Ar()),Xr.set(e,{reg:t&&Xe(t),args:n})},trace:function(...e){o(Ue,null,e)}}; const snippets=Yr; 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; }