diff --git a/CHANGELOG.md b/CHANGELOG.md index db0f28137..dc357956e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,34 @@ # Scriptlets and Redirect Resources Changelog -## [Unreleased] +## Unreleased 1.8.x ### Changed - add decimal delay matching for `prevent-setInterval` and `prevent-setTimeout` [#247](https://github.com/AdguardTeam/Scriptlets/issues/247) +### Fixed + +- `prevent-xhr` and `trusted-replace-xhr-response` closure bug on multiple requests [#261](https://github.com/AdguardTeam/Scriptlets/issues/261) + +## Unreleased 1.7.x + +### Fixed + +- `prevent-addEventListener` and `log-addEventListener` loosing context when encountering already bound `.addEventListener` + +## v1.7.14 + +### Added + +* `set-constant` ADG→UBO conversion for [`emptyArr` and `emptyObj`](https://github.com/uBlockOrigin/uBlock-issues/issues/2411) + + +## v1.7.13 + +### Fixed + +* `isEmptyObject` helper not counting `prototype` as an object property + ## v1.7.10 ### Added @@ -24,24 +47,24 @@ ### Added - [Trusted scriptlets](./README.md#trusted-scriptlets) with extended capabilities: - - trusted-click-element [#23](https://github.com/AdguardTeam/Scriptlets/issues/23) - - trusted-replace-xhr-response [#202](https://github.com/AdguardTeam/Scriptlets/issues/202) - - trusted-replace-fetch-response - - trusted-set-local-storage-item - - trusted-set-cookie + - `trusted-click-element` [#23](https://github.com/AdguardTeam/Scriptlets/issues/23) + - `trusted-replace-xhr-response` [#202](https://github.com/AdguardTeam/Scriptlets/issues/202) + - `trusted-replace-fetch-response` + - `trusted-set-local-storage-item` + - `trusted-set-cookie` - Scriptlets: - - xml-prune [#249](https://github.com/AdguardTeam/Scriptlets/issues/249) + - `xml-prune` [#249](https://github.com/AdguardTeam/Scriptlets/issues/249) ### Changed - Scriptlets: - - prevent-element-src-loading [#228](https://github.com/AdguardTeam/Scriptlets/issues/228) - - prevent-fetch [#216](https://github.com/AdguardTeam/Scriptlets/issues/216) - - abort-on-stack-trace [#201](https://github.com/AdguardTeam/Scriptlets/issues/201) - - abort-current-inline-script [#251](https://github.com/AdguardTeam/Scriptlets/issues/251) - - set-cookie & set-cookie-reload + - `prevent-element-src-loading` [#228](https://github.com/AdguardTeam/Scriptlets/issues/228) + - `prevent-fetch` [#216](https://github.com/AdguardTeam/Scriptlets/issues/216) + - `abort-on-stack-trace` [#201](https://github.com/AdguardTeam/Scriptlets/issues/201) + - `abort-current-inline-script` [#251](https://github.com/AdguardTeam/Scriptlets/issues/251) + - `set-cookie` & `set-cookie-reload` - Redirects: - - google-ima3 [#255](https://github.com/AdguardTeam/Scriptlets/issues/255) - - metrika-yandex-tag [#254](https://github.com/AdguardTeam/Scriptlets/issues/254) - - googlesyndication-adsbygoogle [#252](https://github.com/AdguardTeam/Scriptlets/issues/252) + - `google-ima3` [#255](https://github.com/AdguardTeam/Scriptlets/issues/255) + - `metrika-yandex-tag` [#254](https://github.com/AdguardTeam/Scriptlets/issues/254) + - `googlesyndication-adsbygoogle` [#252](https://github.com/AdguardTeam/Scriptlets/issues/252) diff --git a/README.md b/README.md index af622964c..403f1c1e9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# AdGuard Scriptlets and Redirect resources +# AdGuard Scriptlets and Redirect Resources AdGuard's Scriptlets and Redirect resources library which provides extended capabilities for content blocking. @@ -161,9 +161,10 @@ And also there is a module at `dist/scriptlets.js` which has been exported to a ```javascript /** - * Returns scriptlet code + * Returns scriptlet code by param * @param {Source} source - * @returns {string} + * @returns {string|null} scriptlet code + * @throws on unknown scriptlet name */ scriptlets.invoke(source); ``` diff --git a/dist/build.txt b/dist/build.txt index f8ffb3589..72708e251 100644 --- a/dist/build.txt +++ b/dist/build.txt @@ -1 +1 @@ -version=1.7.10 \ No newline at end of file +version=1.7.14 \ No newline at end of file diff --git a/dist/redirect-files/prevent-popads-net.js b/dist/redirect-files/prevent-popads-net.js index d10412560..d42129f8f 100644 --- a/dist/redirect-files/prevent-popads-net.js +++ b/dist/redirect-files/prevent-popads-net.js @@ -33,7 +33,7 @@ }; } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function hit(source) { if (source.verbose !== true) { diff --git a/dist/redirects.json b/dist/redirects.json index 0f177f90b..5619c0402 100644 --- a/dist/redirects.json +++ b/dist/redirects.json @@ -362,7 +362,7 @@ ], "isBlocking": false, "contentType": "application/javascript;base64", - "content": "IWZ1bmN0aW9uKHNvdXJjZSxhcmdzKXtjb25zdCB1cGRhdGVkQXJncz1hcmdzP1tdLmNvbmNhdChzb3VyY2UpLmNvbmNhdChhcmdzKTpbc291cmNlXTt0cnl7KGZ1bmN0aW9uKHNvdXJjZSl7dmFyIHJpZD1NYXRoLnJhbmRvbSgpLnRvU3RyaW5nKDM2KS5zdWJzdHIoMiw5KSx0aHJvd0Vycm9yPWZ1bmN0aW9uKCl7dGhyb3cgbmV3IFJlZmVyZW5jZUVycm9yKHJpZCl9O2RlbGV0ZSB3aW5kb3cuUG9wQWRzLGRlbGV0ZSB3aW5kb3cucG9wbnMsT2JqZWN0LmRlZmluZVByb3BlcnRpZXMod2luZG93LHtQb3BBZHM6e3NldDp0aHJvd0Vycm9yfSxwb3Buczp7c2V0OnRocm93RXJyb3J9fSksd2luZG93Lm9uZXJyb3I9ZnVuY3Rpb24ocmlkKXt2YXIgbmF0aXZlT25FcnJvcj13aW5kb3cub25lcnJvcjtyZXR1cm4gZnVuY3Rpb24oZXJyb3Ipe2lmKCJzdHJpbmciPT10eXBlb2YgZXJyb3ImJi0xIT09ZXJyb3IuaW5kZXhPZihyaWQpKXJldHVybiEwO2lmKG5hdGl2ZU9uRXJyb3IgaW5zdGFuY2VvZiBGdW5jdGlvbil7Zm9yKHZhciBfbGVuPWFyZ3VtZW50cy5sZW5ndGgsYXJncz1uZXcgQXJyYXkoX2xlbj4xP19sZW4tMTowKSxfa2V5PTE7X2tleTxfbGVuO19rZXkrKylhcmdzW19rZXktMV09YXJndW1lbnRzW19rZXldO3JldHVybiBuYXRpdmVPbkVycm9yLmFwcGx5KHRoaXMsW2Vycm9yXS5jb25jYXQoYXJncykpfXJldHVybiExfX0ocmlkKS5iaW5kKCksZnVuY3Rpb24oc291cmNlKXtpZighMD09PXNvdXJjZS52ZXJib3NlKXt0cnl7dmFyIGxvZz1jb25zb2xlLmxvZy5iaW5kKGNvbnNvbGUpLHRyYWNlPWNvbnNvbGUudHJhY2UuYmluZChjb25zb2xlKSxwcmVmaXg9c291cmNlLnJ1bGVUZXh0fHwiIjtpZihzb3VyY2UuZG9tYWluTmFtZSl7dmFyIHJ1bGVTdGFydEluZGV4LEFHX1NDUklQVExFVF9NQVJLRVI9IiMlIy8vIixVQk9fU0NSSVBUTEVUX01BUktFUj0iIyMranMiO3NvdXJjZS5ydWxlVGV4dC5pbmRleE9mKEFHX1NDUklQVExFVF9NQVJLRVIpPi0xP3J1bGVTdGFydEluZGV4PXNvdXJjZS5ydWxlVGV4dC5pbmRleE9mKEFHX1NDUklQVExFVF9NQVJLRVIpOnNvdXJjZS5ydWxlVGV4dC5pbmRleE9mKFVCT19TQ1JJUFRMRVRfTUFSS0VSKT4tMSYmKHJ1bGVTdGFydEluZGV4PXNvdXJjZS5ydWxlVGV4dC5pbmRleE9mKFVCT19TQ1JJUFRMRVRfTUFSS0VSKSk7dmFyIHJ1bGVQYXJ0PXNvdXJjZS5ydWxlVGV4dC5zbGljZShydWxlU3RhcnRJbmRleCk7cHJlZml4PSIiLmNvbmNhdChzb3VyY2UuZG9tYWluTmFtZSkuY29uY2F0KHJ1bGVQYXJ0KX1sb2coIiIuY29uY2F0KHByZWZpeCwiIHRyYWNlIHN0YXJ0IikpLHRyYWNlJiZ0cmFjZSgpLGxvZygiIi5jb25jYXQocHJlZml4LCIgdHJhY2UgZW5kIikpfWNhdGNoKGUpe30iZnVuY3Rpb24iPT10eXBlb2Ygd2luZG93Ll9fZGVidWcmJndpbmRvdy5fX2RlYnVnKHNvdXJjZSl9fShzb3VyY2UpfSkuYXBwbHkodGhpcyx1cGRhdGVkQXJncyl9Y2F0Y2goZSl7Y29uc29sZS5sb2coZSl9fSh7bmFtZToicHJldmVudC1wb3BhZHMtbmV0IixhcmdzOltdfSxbXSk7" + "content": "IWZ1bmN0aW9uKHNvdXJjZSxhcmdzKXtjb25zdCB1cGRhdGVkQXJncz1hcmdzP1tdLmNvbmNhdChzb3VyY2UpLmNvbmNhdChhcmdzKTpbc291cmNlXTt0cnl7KGZ1bmN0aW9uKHNvdXJjZSl7dmFyIHJpZD1NYXRoLnJhbmRvbSgpLnRvU3RyaW5nKDM2KS5zbGljZSgyLDkpLHRocm93RXJyb3I9ZnVuY3Rpb24oKXt0aHJvdyBuZXcgUmVmZXJlbmNlRXJyb3IocmlkKX07ZGVsZXRlIHdpbmRvdy5Qb3BBZHMsZGVsZXRlIHdpbmRvdy5wb3BucyxPYmplY3QuZGVmaW5lUHJvcGVydGllcyh3aW5kb3cse1BvcEFkczp7c2V0OnRocm93RXJyb3J9LHBvcG5zOntzZXQ6dGhyb3dFcnJvcn19KSx3aW5kb3cub25lcnJvcj1mdW5jdGlvbihyaWQpe3ZhciBuYXRpdmVPbkVycm9yPXdpbmRvdy5vbmVycm9yO3JldHVybiBmdW5jdGlvbihlcnJvcil7aWYoInN0cmluZyI9PXR5cGVvZiBlcnJvciYmLTEhPT1lcnJvci5pbmRleE9mKHJpZCkpcmV0dXJuITA7aWYobmF0aXZlT25FcnJvciBpbnN0YW5jZW9mIEZ1bmN0aW9uKXtmb3IodmFyIF9sZW49YXJndW1lbnRzLmxlbmd0aCxhcmdzPW5ldyBBcnJheShfbGVuPjE/X2xlbi0xOjApLF9rZXk9MTtfa2V5PF9sZW47X2tleSsrKWFyZ3NbX2tleS0xXT1hcmd1bWVudHNbX2tleV07cmV0dXJuIG5hdGl2ZU9uRXJyb3IuYXBwbHkodGhpcyxbZXJyb3JdLmNvbmNhdChhcmdzKSl9cmV0dXJuITF9fShyaWQpLmJpbmQoKSxmdW5jdGlvbihzb3VyY2Upe2lmKCEwPT09c291cmNlLnZlcmJvc2Upe3RyeXt2YXIgbG9nPWNvbnNvbGUubG9nLmJpbmQoY29uc29sZSksdHJhY2U9Y29uc29sZS50cmFjZS5iaW5kKGNvbnNvbGUpLHByZWZpeD1zb3VyY2UucnVsZVRleHR8fCIiO2lmKHNvdXJjZS5kb21haW5OYW1lKXt2YXIgcnVsZVN0YXJ0SW5kZXgsQUdfU0NSSVBUTEVUX01BUktFUj0iIyUjLy8iLFVCT19TQ1JJUFRMRVRfTUFSS0VSPSIjIytqcyI7c291cmNlLnJ1bGVUZXh0LmluZGV4T2YoQUdfU0NSSVBUTEVUX01BUktFUik+LTE/cnVsZVN0YXJ0SW5kZXg9c291cmNlLnJ1bGVUZXh0LmluZGV4T2YoQUdfU0NSSVBUTEVUX01BUktFUik6c291cmNlLnJ1bGVUZXh0LmluZGV4T2YoVUJPX1NDUklQVExFVF9NQVJLRVIpPi0xJiYocnVsZVN0YXJ0SW5kZXg9c291cmNlLnJ1bGVUZXh0LmluZGV4T2YoVUJPX1NDUklQVExFVF9NQVJLRVIpKTt2YXIgcnVsZVBhcnQ9c291cmNlLnJ1bGVUZXh0LnNsaWNlKHJ1bGVTdGFydEluZGV4KTtwcmVmaXg9IiIuY29uY2F0KHNvdXJjZS5kb21haW5OYW1lKS5jb25jYXQocnVsZVBhcnQpfWxvZygiIi5jb25jYXQocHJlZml4LCIgdHJhY2Ugc3RhcnQiKSksdHJhY2UmJnRyYWNlKCksbG9nKCIiLmNvbmNhdChwcmVmaXgsIiB0cmFjZSBlbmQiKSl9Y2F0Y2goZSl7fSJmdW5jdGlvbiI9PXR5cGVvZiB3aW5kb3cuX19kZWJ1ZyYmd2luZG93Ll9fZGVidWcoc291cmNlKX19KHNvdXJjZSl9KS5hcHBseSh0aGlzLHVwZGF0ZWRBcmdzKX1jYXRjaChlKXtjb25zb2xlLmxvZyhlKX19KHtuYW1lOiJwcmV2ZW50LXBvcGFkcy1uZXQiLGFyZ3M6W119LFtdKTs=" }, { "title": "scorecardresearch-beacon", diff --git a/dist/redirects.yml b/dist/redirects.yml index d5034c12b..465f04b2c 100644 --- a/dist/redirects.yml +++ b/dist/redirects.yml @@ -1,6 +1,6 @@ # # AdGuard Scriptlets (Redirects Source) -# Version 1.7.10 +# Version 1.7.14 # - title: 1x1-transparent.gif description: |- @@ -3388,7 +3388,7 @@ }; } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function hit(source) { if (source.verbose !== true) { diff --git a/dist/scriptlets.corelibs.json b/dist/scriptlets.corelibs.json index 87db1b9ca..5ae3c7334 100644 --- a/dist/scriptlets.corelibs.json +++ b/dist/scriptlets.corelibs.json @@ -1,5 +1,5 @@ { - "version": "1.7.10", + "version": "1.7.14", "scriptlets": [ { "names": [ @@ -18,7 +18,7 @@ "ubo-aopr", "abp-abort-on-property-read" ], - "scriptlet": "function abortOnPropertyRead(source,args){function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property){if(property){var rid=Math.random().toString(36).substr(2,9),abort=function(){throw function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source),new ReferenceError(rid)};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;chain?Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}}):function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{get:abort,set:function(){}})}(window,property),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind()}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function abortOnPropertyRead(source,args){function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length&&!obj.prototype)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property){if(property){var rid=Math.random().toString(36).slice(2,9),abort=function(){throw function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source),new ReferenceError(rid)};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;chain?Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}}):function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{get:abort,set:function(){}})}(window,property),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind()}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ @@ -31,7 +31,7 @@ "ubo-aopw", "abp-abort-on-property-write" ], - "scriptlet": "function abortOnPropertyWrite(source,args){function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property){if(property){var rid=Math.random().toString(36).substr(2,9),abort=function(){throw function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source),new ReferenceError(rid)};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;chain?Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}}):function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{set:abort})}(window,property),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind()}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function abortOnPropertyWrite(source,args){function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length&&!obj.prototype)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property){if(property){var rid=Math.random().toString(36).slice(2,9),abort=function(){throw function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source),new ReferenceError(rid)};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;chain?Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}}):function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{set:abort})}(window,property),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind()}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ @@ -98,7 +98,7 @@ "ubo-acis", "abp-abort-current-inline-script" ], - "scriptlet": "function abortCurrentInlineScript(source,args){function randomId(){return Math.random().toString(36).substr(2,9)}function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property,search){var searchRegexp=function(){var input=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(\".?\");if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}(search),rid=randomId(),getCurrentScript=function(){if(\"currentScript\"in document)return document.currentScript;var scripts=document.getElementsByTagName(\"script\");return scripts[scripts.length-1]},ourScript=getCurrentScript(),abort=function(){var scriptEl=getCurrentScript();if(scriptEl){var str,prefix,content=scriptEl.textContent;try{content=Object.getOwnPropertyDescriptor(Node.prototype,\"textContent\").get.call(scriptEl)}catch(e){}if(0===content.length&&void 0!==scriptEl.src&&(prefix=\"data:text/javascript;base64,\",(str=scriptEl.src)&&0===str.indexOf(prefix))){var encodedContent=scriptEl.src.slice(\"data:text/javascript;base64,\".length);content=window.atob(encodedContent)}if(scriptEl instanceof HTMLScriptElement&&content.length>0&&scriptEl!==ourScript&&searchRegexp.test(content))throw function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source),new ReferenceError(rid)}};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;if(base instanceof Object!=0||null!==base)if(chain)Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}});else{var currentValue=base[prop],origDescriptor=Object.getOwnPropertyDescriptor(base,prop);origDescriptor instanceof Object!=0&&origDescriptor.get instanceof Function!=0||(currentValue=base[prop],origDescriptor=void 0);var descriptorWrapper=Object.assign({isAbortingSuspended:!1,isolateCallback:function(cb){this.isAbortingSuspended=!0;try{for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];var result=cb.apply(void 0,args);return this.isAbortingSuspended=!1,result}catch(_unused){var rid=randomId();throw this.isAbortingSuspended=!1,new ReferenceError(rid)}}},{currentValue:currentValue,get:function(){return this.isAbortingSuspended||this.isolateCallback(abort),origDescriptor instanceof Object?origDescriptor.get.call(base):this.currentValue},set:function(newValue){this.isAbortingSuspended||this.isolateCallback(abort),origDescriptor instanceof Object?origDescriptor.set.call(base,newValue):this.currentValue=newValue}});!function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{get:function(){return descriptorWrapper.get.call(descriptorWrapper)},set:function(newValue){descriptorWrapper.set.call(descriptorWrapper,newValue)}})}else{var props=property.split(\".\"),propIndex=props.indexOf(prop),baseName=props[propIndex-1],message=\"The scriptlet had been executed before the \".concat(baseName,\" was loaded.\");!function(source,message){(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}(source,message)}}(window,property),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind()}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function abortCurrentInlineScript(source,args){function randomId(){return Math.random().toString(36).slice(2,9)}function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length&&!obj.prototype)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property,search){var searchRegexp=function(){var input=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(\".?\");if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}(search),rid=randomId(),getCurrentScript=function(){if(\"currentScript\"in document)return document.currentScript;var scripts=document.getElementsByTagName(\"script\");return scripts[scripts.length-1]},ourScript=getCurrentScript(),abort=function(){var scriptEl=getCurrentScript();if(scriptEl){var str,prefix,content=scriptEl.textContent;try{content=Object.getOwnPropertyDescriptor(Node.prototype,\"textContent\").get.call(scriptEl)}catch(e){}if(0===content.length&&void 0!==scriptEl.src&&(prefix=\"data:text/javascript;base64,\",(str=scriptEl.src)&&0===str.indexOf(prefix))){var encodedContent=scriptEl.src.slice(\"data:text/javascript;base64,\".length);content=window.atob(encodedContent)}if(scriptEl instanceof HTMLScriptElement&&content.length>0&&scriptEl!==ourScript&&searchRegexp.test(content))throw function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source),new ReferenceError(rid)}};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;if(base instanceof Object!=0||null!==base)if(chain)Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}});else{var currentValue=base[prop],origDescriptor=Object.getOwnPropertyDescriptor(base,prop);origDescriptor instanceof Object!=0&&origDescriptor.get instanceof Function!=0||(currentValue=base[prop],origDescriptor=void 0);var descriptorWrapper=Object.assign({isAbortingSuspended:!1,isolateCallback:function(cb){this.isAbortingSuspended=!0;try{for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];var result=cb.apply(void 0,args);return this.isAbortingSuspended=!1,result}catch(_unused){var rid=randomId();throw this.isAbortingSuspended=!1,new ReferenceError(rid)}}},{currentValue:currentValue,get:function(){return this.isAbortingSuspended||this.isolateCallback(abort),origDescriptor instanceof Object?origDescriptor.get.call(base):this.currentValue},set:function(newValue){this.isAbortingSuspended||this.isolateCallback(abort),origDescriptor instanceof Object?origDescriptor.set.call(base,newValue):this.currentValue=newValue}});!function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{get:function(){return descriptorWrapper.get.call(descriptorWrapper)},set:function(newValue){descriptorWrapper.set.call(descriptorWrapper,newValue)}})}else{var props=property.split(\".\"),propIndex=props.indexOf(prop),baseName=props[propIndex-1],message=\"The scriptlet had been executed before the \".concat(baseName,\" was loaded.\");!function(source,message){(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}(source,message)}}(window,property),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind()}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ @@ -111,7 +111,7 @@ "ubo-set", "abp-override-property-read" ], - "scriptlet": "function setConstant(source,args){function noopFunc(){}function trueFunc(){return!0}function falseFunc(){return!1}function noopPromiseReject(){return Promise.reject()}function noopPromiseResolve(){var responseBody=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"{}\",responseUrl=arguments.length>1&&void 0!==arguments[1]?arguments[1]:\"\",responseType=arguments.length>2&&void 0!==arguments[2]?arguments[2]:\"default\";if(\"undefined\"!=typeof Response){var response=new Response(responseBody,{status:200,statusText:\"OK\"});return Object.defineProperties(response,{url:{value:responseUrl},type:{value:responseType}}),Promise.resolve(response)}}function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&isEmptyObject(base)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}function isEmptyObject(obj){return 0===Object.keys(obj).length}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property,value,stack){if(property&&function(stackMatch,stackTrace){if(!stackMatch||\"\"===stackMatch)return!0;if(function(stackMatch,stackTrace){var INLINE_SCRIPT_STRING=\"inlineScript\",INJECTED_SCRIPT_STRING=\"injectedScript\",INJECTED_SCRIPT_MARKER=\"\",isInlineScript=function(stackMatch){return stackMatch.indexOf(INLINE_SCRIPT_STRING)>-1},isInjectedScript=function(stackMatch){return stackMatch.indexOf(INJECTED_SCRIPT_STRING)>-1};if(!isInlineScript(stackMatch)&&!isInjectedScript(stackMatch))return!1;var documentURL=window.location.href,pos=documentURL.indexOf(\"#\");-1!==pos&&(documentURL=documentURL.slice(0,pos));var stackLines=stackTrace.split(\"\\n\").slice(2).map((function(line){return line.trim()})).map((function(line){var stack,getStackTraceURL=/(.*?@)?(\\S+)(:\\d+):\\d+\\)?$/.exec(line);if(getStackTraceURL){var stackURL=getStackTraceURL[2];if(startsWith(stackURL,\"(\")&&(stackURL=stackURL.slice(1)),startsWith(stackURL,INJECTED_SCRIPT_MARKER)){stackURL=INJECTED_SCRIPT_STRING;var stackFunction=void 0!==getStackTraceURL[1]?getStackTraceURL[1].slice(0,-1):line.slice(0,getStackTraceURL.index).trim();startsWith(stackFunction,\"at\")&&(stackFunction=stackFunction.slice(2).trim()),stack=\"\".concat(stackFunction,\" \").concat(stackURL).trim()}else stack=stackURL}else stack=line;return stack}));if(stackLines)for(var index=0;index0&&void 0!==arguments[0]?arguments[0]:\"\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(\".?\");if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}(stackMatch),refinedStackTrace=stackTrace.split(\"\\n\").slice(2).map((function(line){return line.trim()})).join(\"\\n\");return Object.getOwnPropertyDescriptor(RegExp.prototype,\"test\").value.call(stackRegexp,refinedStackTrace)}(stack,(new Error).stack)){var constantValue,num;if(\"undefined\"===value)constantValue=void 0;else if(\"false\"===value)constantValue=!1;else if(\"true\"===value)constantValue=!0;else if(\"null\"===value)constantValue=null;else if(\"emptyArr\"===value)constantValue=[];else if(\"emptyObj\"===value)constantValue={};else if(\"noopFunc\"===value)constantValue=noopFunc;else if(\"trueFunc\"===value)constantValue=trueFunc;else if(\"falseFunc\"===value)constantValue=falseFunc;else if(\"noopPromiseResolve\"===value)constantValue=noopPromiseResolve;else if(\"noopPromiseReject\"===value)constantValue=noopPromiseReject;else if(/^\\d+$/.test(value)){if(num=constantValue=parseFloat(value),(Number.isNaN||window.isNaN)(num))return;if(Math.abs(constantValue)>32767)return}else if(\"-1\"===value)constantValue=-1;else if(\"\"===value)constantValue=\"\";else if(\"yes\"===value)constantValue=\"yes\";else{if(\"no\"!==value)return;constantValue=\"no\"}var canceled=!1,mustCancel=function(value){return canceled||(canceled=void 0!==value&&void 0!==constantValue&&typeof value!=typeof constantValue&&null!==value)},trapProp=function(base,prop,configurable,handler){if(!handler.init(base[prop]))return!1;var prevSetter,origDescriptor=Object.getOwnPropertyDescriptor(base,prop);if(origDescriptor instanceof Object){if(!origDescriptor.configurable){var message=\"Property '\".concat(prop,\"' is not configurable\");return function(source,message){(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}(source,message),!1}base[prop]=constantValue,origDescriptor.set instanceof Function&&(prevSetter=origDescriptor.set)}return Object.defineProperty(base,prop,{configurable:configurable,get:function(){return handler.get()},set:function(a){void 0!==prevSetter&&prevSetter(a),handler.set(a)}}),!0};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain,inChainPropHandler={factValue:void 0,init:function(a){return this.factValue=a,!0},get:function(){return this.factValue},set:function(a){this.factValue!==a&&(this.factValue=a,a instanceof Object&&setChainPropAccess(a,chain))}},endPropHandler={init:function(a){return!mustCancel(a)},get:function(){return constantValue},set:function(a){mustCancel(a)&&(constantValue=a)}};if(chain)if(void 0===base||null!==base[prop]){(base instanceof Object||\"object\"==typeof base)&&isEmptyObject(base)&&trapProp(base,prop,!0,inChainPropHandler);var propValue=owner[prop];(propValue instanceof Object||\"object\"==typeof propValue&&null!==propValue)&&setChainPropAccess(propValue,chain),trapProp(base,prop,!0,inChainPropHandler)}else trapProp(base,prop,!0,inChainPropHandler);else trapProp(base,prop,!1,endPropHandler)&&function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source)}(window,property)}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function setConstant(source,args){function noopFunc(){}function trueFunc(){return!0}function falseFunc(){return!1}function noopPromiseReject(){return Promise.reject()}function noopPromiseResolve(){var responseBody=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"{}\",responseUrl=arguments.length>1&&void 0!==arguments[1]?arguments[1]:\"\",responseType=arguments.length>2&&void 0!==arguments[2]?arguments[2]:\"default\";if(\"undefined\"!=typeof Response){var response=new Response(responseBody,{status:200,statusText:\"OK\"});return Object.defineProperties(response,{url:{value:responseUrl},type:{value:responseType}}),Promise.resolve(response)}}function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&isEmptyObject(base)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}function isEmptyObject(obj){return 0===Object.keys(obj).length&&!obj.prototype}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property,value,stack){if(property&&function(stackMatch,stackTrace){if(!stackMatch||\"\"===stackMatch)return!0;if(function(stackMatch,stackTrace){var INLINE_SCRIPT_STRING=\"inlineScript\",INJECTED_SCRIPT_STRING=\"injectedScript\",INJECTED_SCRIPT_MARKER=\"\",isInlineScript=function(stackMatch){return stackMatch.indexOf(INLINE_SCRIPT_STRING)>-1},isInjectedScript=function(stackMatch){return stackMatch.indexOf(INJECTED_SCRIPT_STRING)>-1};if(!isInlineScript(stackMatch)&&!isInjectedScript(stackMatch))return!1;var documentURL=window.location.href,pos=documentURL.indexOf(\"#\");-1!==pos&&(documentURL=documentURL.slice(0,pos));var stackLines=stackTrace.split(\"\\n\").slice(2).map((function(line){return line.trim()})).map((function(line){var stack,getStackTraceURL=/(.*?@)?(\\S+)(:\\d+):\\d+\\)?$/.exec(line);if(getStackTraceURL){var stackURL=getStackTraceURL[2];if(startsWith(stackURL,\"(\")&&(stackURL=stackURL.slice(1)),startsWith(stackURL,INJECTED_SCRIPT_MARKER)){stackURL=INJECTED_SCRIPT_STRING;var stackFunction=void 0!==getStackTraceURL[1]?getStackTraceURL[1].slice(0,-1):line.slice(0,getStackTraceURL.index).trim();startsWith(stackFunction,\"at\")&&(stackFunction=stackFunction.slice(2).trim()),stack=\"\".concat(stackFunction,\" \").concat(stackURL).trim()}else stack=stackURL}else stack=line;return stack}));if(stackLines)for(var index=0;index0&&void 0!==arguments[0]?arguments[0]:\"\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(\".?\");if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}(stackMatch),refinedStackTrace=stackTrace.split(\"\\n\").slice(2).map((function(line){return line.trim()})).join(\"\\n\");return Object.getOwnPropertyDescriptor(RegExp.prototype,\"test\").value.call(stackRegexp,refinedStackTrace)}(stack,(new Error).stack)){var constantValue,num;if(\"undefined\"===value)constantValue=void 0;else if(\"false\"===value)constantValue=!1;else if(\"true\"===value)constantValue=!0;else if(\"null\"===value)constantValue=null;else if(\"emptyArr\"===value)constantValue=[];else if(\"emptyObj\"===value)constantValue={};else if(\"noopFunc\"===value)constantValue=noopFunc;else if(\"trueFunc\"===value)constantValue=trueFunc;else if(\"falseFunc\"===value)constantValue=falseFunc;else if(\"noopPromiseResolve\"===value)constantValue=noopPromiseResolve;else if(\"noopPromiseReject\"===value)constantValue=noopPromiseReject;else if(/^\\d+$/.test(value)){if(num=constantValue=parseFloat(value),(Number.isNaN||window.isNaN)(num))return;if(Math.abs(constantValue)>32767)return}else if(\"-1\"===value)constantValue=-1;else if(\"\"===value)constantValue=\"\";else if(\"yes\"===value)constantValue=\"yes\";else{if(\"no\"!==value)return;constantValue=\"no\"}var canceled=!1,mustCancel=function(value){return canceled||(canceled=void 0!==value&&void 0!==constantValue&&typeof value!=typeof constantValue&&null!==value)},trapProp=function(base,prop,configurable,handler){if(!handler.init(base[prop]))return!1;var prevSetter,origDescriptor=Object.getOwnPropertyDescriptor(base,prop);if(origDescriptor instanceof Object){if(!origDescriptor.configurable){var message=\"Property '\".concat(prop,\"' is not configurable\");return function(source,message){(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}(source,message),!1}base[prop]=constantValue,origDescriptor.set instanceof Function&&(prevSetter=origDescriptor.set)}return Object.defineProperty(base,prop,{configurable:configurable,get:function(){return handler.get()},set:function(a){void 0!==prevSetter&&prevSetter(a),handler.set(a)}}),!0};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain,inChainPropHandler={factValue:void 0,init:function(a){return this.factValue=a,!0},get:function(){return this.factValue},set:function(a){this.factValue!==a&&(this.factValue=a,a instanceof Object&&setChainPropAccess(a,chain))}},endPropHandler={init:function(a){return!mustCancel(a)},get:function(){return constantValue},set:function(a){mustCancel(a)&&(constantValue=a)}};if(chain)if(void 0===base||null!==base[prop]){(base instanceof Object||\"object\"==typeof base)&&isEmptyObject(base)&&trapProp(base,prop,!0,inChainPropHandler);var propValue=owner[prop];(propValue instanceof Object||\"object\"==typeof propValue&&null!==propValue)&&setChainPropAccess(propValue,chain),trapProp(base,prop,!0,inChainPropHandler)}else trapProp(base,prop,!0,inChainPropHandler);else trapProp(base,prop,!1,endPropHandler)&&function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source)}(window,property)}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ @@ -165,7 +165,7 @@ "ubo-addEventListener-logger", "ubo-aell" ], - "scriptlet": "function logAddEventListener(source,args){function hit(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex;source.ruleText.indexOf(\"#%#//\")>-1?ruleStartIndex=source.ruleText.indexOf(\"#%#//\"):source.ruleText.indexOf(\"##+js\")>-1&&(ruleStartIndex=source.ruleText.indexOf(\"##+js\"));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}function validateType(type){return void 0!==type}function validateListener(listener){return void 0!==listener&&(\"function\"==typeof listener||\"object\"==typeof listener&&null!==listener&&\"function\"==typeof listener.handleEvent)}function listenerToString(listener){return\"function\"==typeof listener?listener.toString():listener.handleEvent.toString()}function convertTypeToString(value){return void 0===value?\"undefined\":\"object\"==typeof value?null===value?\"null\":objectToString(value):value.toString()}function logMessage(source,message){var forced=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(forced||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}function objectToString(obj){return function(obj){return 0===Object.keys(obj).length}(obj)?\"{}\":(object=obj,keys=Object.keys(object),entries=[],keys.forEach((function(key){return entries.push([key,object[key]])})),entries).map((function(pair){var key=pair[0],value=pair[1],recordValueStr=value;return value instanceof Object&&(recordValueStr=\"{ \".concat(objectToString(value),\" }\")),\"\".concat(key,':\"').concat(recordValueStr,'\"')})).join(\" \");var object,keys,entries}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source){var nativeAddEventListener=window.EventTarget.prototype.addEventListener;function addEventListenerWrapper(type,listener){if(validateType(type)&&validateListener(listener)){var _message='addEventListener(\"'.concat(type,'\", ').concat(listenerToString(listener),\")\");logMessage(source,_message,!0),hit(source)}var message=\"Invalid event type or listener passed to addEventListener:\\ntype: \".concat(convertTypeToString(type),\"\\nlistener: \").concat(convertTypeToString(listener));logMessage(source,message,!0);for(var _len=arguments.length,args=new Array(_len>2?_len-2:0),_key=2;_key<_len;_key++)args[_key-2]=arguments[_key];return nativeAddEventListener.apply(this,[type,listener].concat(args))}var descriptor={configurable:!0,set:function(){},get:function(){return addEventListenerWrapper}};Object.defineProperty(window.EventTarget.prototype,\"addEventListener\",descriptor),Object.defineProperty(window,\"addEventListener\",descriptor),Object.defineProperty(document,\"addEventListener\",descriptor)}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function logAddEventListener(source,args){function hit(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex;source.ruleText.indexOf(\"#%#//\")>-1?ruleStartIndex=source.ruleText.indexOf(\"#%#//\"):source.ruleText.indexOf(\"##+js\")>-1&&(ruleStartIndex=source.ruleText.indexOf(\"##+js\"));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}function validateType(type){return void 0!==type}function validateListener(listener){return void 0!==listener&&(\"function\"==typeof listener||\"object\"==typeof listener&&null!==listener&&\"function\"==typeof listener.handleEvent)}function listenerToString(listener){return\"function\"==typeof listener?listener.toString():listener.handleEvent.toString()}function convertTypeToString(value){return void 0===value?\"undefined\":\"object\"==typeof value?null===value?\"null\":objectToString(value):value.toString()}function logMessage(source,message){var forced=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(forced||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}function objectToString(obj){return function(obj){return 0===Object.keys(obj).length&&!obj.prototype}(obj)?\"{}\":(object=obj,keys=Object.keys(object),entries=[],keys.forEach((function(key){return entries.push([key,object[key]])})),entries).map((function(pair){var key=pair[0],value=pair[1],recordValueStr=value;return value instanceof Object&&(recordValueStr=\"{ \".concat(objectToString(value),\" }\")),\"\".concat(key,':\"').concat(recordValueStr,'\"')})).join(\" \");var object,keys,entries}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source){var nativeAddEventListener=window.EventTarget.prototype.addEventListener;function addEventListenerWrapper(type,listener){if(validateType(type)&&validateListener(listener)){var _message='addEventListener(\"'.concat(type,'\", ').concat(listenerToString(listener),\")\");logMessage(source,_message,!0),hit(source)}var message=\"Invalid event type or listener passed to addEventListener:\\ntype: \".concat(convertTypeToString(type),\"\\nlistener: \").concat(convertTypeToString(listener));logMessage(source,message,!0);for(var _len=arguments.length,args=new Array(_len>2?_len-2:0),_key=2;_key<_len;_key++)args[_key-2]=arguments[_key];return nativeAddEventListener.apply(this,[type,listener].concat(args))}var descriptor={configurable:!0,set:function(){},get:function(){return addEventListenerWrapper}};Object.defineProperty(window.EventTarget.prototype,\"addEventListener\",descriptor),Object.defineProperty(window,\"addEventListener\",descriptor),Object.defineProperty(document,\"addEventListener\",descriptor)}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ @@ -227,7 +227,7 @@ "ubo-popads.net.js", "ubo-popads.net" ], - "scriptlet": "function preventPopadsNet(source,args){var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source){var rid=Math.random().toString(36).substr(2,9),throwError=function(){throw new ReferenceError(rid)};delete window.PopAds,delete window.popns,Object.defineProperties(window,{PopAds:{set:throwError},popns:{set:throwError}}),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind(),function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source)}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function preventPopadsNet(source,args){var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source){var rid=Math.random().toString(36).slice(2,9),throwError=function(){throw new ReferenceError(rid)};delete window.PopAds,delete window.popns,Object.defineProperties(window,{PopAds:{set:throwError},popns:{set:throwError}}),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind(),function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source)}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ @@ -242,19 +242,19 @@ "names": [ "debug-on-property-read" ], - "scriptlet": "function debugOnPropertyRead(source,args){function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}function noopFunc(){}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property){if(property){var rid=Math.random().toString(36).substr(2,9),abort=function(){!function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source);debugger};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;chain?Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}}):function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{get:abort,set:noopFunc})}(window,property),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind()}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function debugOnPropertyRead(source,args){function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length&&!obj.prototype)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}function noopFunc(){}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property){if(property){var rid=Math.random().toString(36).slice(2,9),abort=function(){!function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source);debugger};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;chain?Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}}):function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{get:abort,set:noopFunc})}(window,property),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind()}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ "debug-on-property-write" ], - "scriptlet": "function debugOnPropertyWrite(source,args){function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property){if(property){var rid=Math.random().toString(36).substr(2,9),abort=function(){!function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source);debugger};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;chain?Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}}):function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{set:abort})}(window,property),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind()}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function debugOnPropertyWrite(source,args){function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length&&!obj.prototype)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property){if(property){var rid=Math.random().toString(36).slice(2,9),abort=function(){!function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source);debugger};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;chain?Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}}):function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{set:abort})}(window,property),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind()}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ "debug-current-inline-script" ], - "scriptlet": "function debugCurrentInlineScript(source,args){function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property,search){var searchRegexp=function(){var input=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(\".?\");if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}(search),rid=Math.random().toString(36).substr(2,9),getCurrentScript=function(){if(\"currentScript\"in document)return document.currentScript;var scripts=document.getElementsByTagName(\"script\");return scripts[scripts.length-1]},ourScript=getCurrentScript(),abort=function(){var scriptEl=getCurrentScript();if(scriptEl){var content=scriptEl.textContent;try{content=Object.getOwnPropertyDescriptor(Node.prototype,\"textContent\").get.call(scriptEl)}catch(e){}if(scriptEl instanceof HTMLScriptElement&&content.length>0&&scriptEl!==ourScript&&searchRegexp.test(content)){!function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source);debugger}}};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;if(base instanceof Object!=0||null!==base)if(chain)Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}});else{var currentValue=base[prop];!function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{set:function(value){abort(),currentValue=value},get:function(){return abort(),currentValue}})}else{var props=property.split(\".\"),propIndex=props.indexOf(prop),baseName=props[propIndex-1];!function(source,message){(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}(\"The scriptlet had been executed before the \".concat(baseName,\" was loaded.\"),source.verbose)}}(window,property),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind()}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function debugCurrentInlineScript(source,args){function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length&&!obj.prototype)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property,search){var searchRegexp=function(){var input=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(\".?\");if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}(search),rid=Math.random().toString(36).slice(2,9),getCurrentScript=function(){if(\"currentScript\"in document)return document.currentScript;var scripts=document.getElementsByTagName(\"script\");return scripts[scripts.length-1]},ourScript=getCurrentScript(),abort=function(){var scriptEl=getCurrentScript();if(scriptEl){var content=scriptEl.textContent;try{content=Object.getOwnPropertyDescriptor(Node.prototype,\"textContent\").get.call(scriptEl)}catch(e){}if(scriptEl instanceof HTMLScriptElement&&content.length>0&&scriptEl!==ourScript&&searchRegexp.test(content)){!function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source);debugger}}};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;if(base instanceof Object!=0||null!==base)if(chain)Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}});else{var currentValue=base[prop];!function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{set:function(value){abort(),currentValue=value},get:function(){return abort(),currentValue}})}else{var props=property.split(\".\"),propIndex=props.indexOf(prop),baseName=props[propIndex-1];!function(source,message){(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}(\"The scriptlet had been executed before the \".concat(baseName,\" was loaded.\"),source.verbose)}}(window,property),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind()}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ @@ -334,7 +334,7 @@ "ubo-json-prune", "abp-json-prune" ], - "scriptlet": "function jsonPrune(source,args){function getWildcardPropertyInChain(base,chain){var lookThrough=arguments.length>2&&void 0!==arguments[2]&&arguments[2],output=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],pos=chain.indexOf(\".\");if(-1===pos){if(\"*\"===chain||\"[]\"===chain)for(var key in base)Object.prototype.hasOwnProperty.call(base,key)&&output.push({base:base,prop:key});else output.push({base:base,prop:chain});return output}var prop=chain.slice(0,pos),shouldLookThrough=\"[]\"===prop&&Array.isArray(base)||\"*\"===prop&&base instanceof Object;if(shouldLookThrough){var nextProp=chain.slice(pos+1),baseKeys=Object.keys(base);baseKeys.forEach((function(key){getWildcardPropertyInChain(base[key],nextProp,lookThrough,output)}))}var nextBase=base[prop];return chain=chain.slice(pos+1),void 0!==nextBase&&getWildcardPropertyInChain(nextBase,chain,lookThrough,output),output}function logMessage(source,message){var forced=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(forced||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}function objectToString(obj){return function(obj){return 0===Object.keys(obj).length}(obj)?\"{}\":(object=obj,keys=Object.keys(object),entries=[],keys.forEach((function(key){return entries.push([key,object[key]])})),entries).map((function(pair){var key=pair[0],value=pair[1],recordValueStr=value;return value instanceof Object&&(recordValueStr=\"{ \".concat(objectToString(value),\" }\")),\"\".concat(key,':\"').concat(recordValueStr,'\"')})).join(\" \");var object,keys,entries}function toRegExp(){var input=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\",DEFAULT_VALUE=\".?\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(DEFAULT_VALUE);if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,propsToRemove,requiredInitialProps,stack){if(!stack||function(stackMatch,stackTrace){if(!stackMatch||\"\"===stackMatch)return!0;if(function(stackMatch,stackTrace){var INLINE_SCRIPT_STRING=\"inlineScript\",INJECTED_SCRIPT_STRING=\"injectedScript\",INJECTED_SCRIPT_MARKER=\"\",isInlineScript=function(stackMatch){return stackMatch.indexOf(INLINE_SCRIPT_STRING)>-1},isInjectedScript=function(stackMatch){return stackMatch.indexOf(INJECTED_SCRIPT_STRING)>-1};if(!isInlineScript(stackMatch)&&!isInjectedScript(stackMatch))return!1;var documentURL=window.location.href,pos=documentURL.indexOf(\"#\");-1!==pos&&(documentURL=documentURL.slice(0,pos));var stackLines=stackTrace.split(\"\\n\").slice(2).map((function(line){return line.trim()})).map((function(line){var stack,getStackTraceURL=/(.*?@)?(\\S+)(:\\d+):\\d+\\)?$/.exec(line);if(getStackTraceURL){var stackURL=getStackTraceURL[2];if(startsWith(stackURL,\"(\")&&(stackURL=stackURL.slice(1)),startsWith(stackURL,INJECTED_SCRIPT_MARKER)){stackURL=INJECTED_SCRIPT_STRING;var stackFunction=void 0!==getStackTraceURL[1]?getStackTraceURL[1].slice(0,-1):line.slice(0,getStackTraceURL.index).trim();startsWith(stackFunction,\"at\")&&(stackFunction=stackFunction.slice(2).trim()),stack=\"\".concat(stackFunction,\" \").concat(stackURL).trim()}else stack=stackURL}else stack=line;return stack}));if(stackLines)for(var index=0;index0){var rootString=JSON.stringify(root);if(toRegExp(requiredPaths.join(\"\")).test(rootString))return logMessage(source,\"\".concat(window.location.hostname,\" \").concat(objectToString(root)),!0),!1}for(var i=0;i-1||requiredPath.indexOf(\"*.\")>-1||requiredPath.indexOf(\".*\")>-1||requiredPath.indexOf(\".[].\")>-1||requiredPath.indexOf(\"[].\")>-1||requiredPath.indexOf(\".[]\")>-1,details=getWildcardPropertyInChain(root,requiredPath,hasWildcard);shouldProcess=!hasWildcard;for(var _i=0;_i-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source))}))}))}catch(e){logMessage(source,e)}return root},nativeJSONParse=JSON.parse,jsonParseWrapper=function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];var root=nativeJSONParse.apply(JSON,args);return jsonPruner(root)};jsonParseWrapper.toString=nativeJSONParse.toString.bind(nativeJSONParse),JSON.parse=jsonParseWrapper;var nativeResponseJson=Response.prototype.json;\"undefined\"!=typeof Response&&(Response.prototype.json=function(){return nativeResponseJson.apply(this).then((function(obj){return jsonPruner(obj)}))})}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function jsonPrune(source,args){function getWildcardPropertyInChain(base,chain){var lookThrough=arguments.length>2&&void 0!==arguments[2]&&arguments[2],output=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],pos=chain.indexOf(\".\");if(-1===pos){if(\"*\"===chain||\"[]\"===chain)for(var key in base)Object.prototype.hasOwnProperty.call(base,key)&&output.push({base:base,prop:key});else output.push({base:base,prop:chain});return output}var prop=chain.slice(0,pos),shouldLookThrough=\"[]\"===prop&&Array.isArray(base)||\"*\"===prop&&base instanceof Object;if(shouldLookThrough){var nextProp=chain.slice(pos+1),baseKeys=Object.keys(base);baseKeys.forEach((function(key){getWildcardPropertyInChain(base[key],nextProp,lookThrough,output)}))}var nextBase=base[prop];return chain=chain.slice(pos+1),void 0!==nextBase&&getWildcardPropertyInChain(nextBase,chain,lookThrough,output),output}function logMessage(source,message){var forced=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(forced||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}function objectToString(obj){return function(obj){return 0===Object.keys(obj).length&&!obj.prototype}(obj)?\"{}\":(object=obj,keys=Object.keys(object),entries=[],keys.forEach((function(key){return entries.push([key,object[key]])})),entries).map((function(pair){var key=pair[0],value=pair[1],recordValueStr=value;return value instanceof Object&&(recordValueStr=\"{ \".concat(objectToString(value),\" }\")),\"\".concat(key,':\"').concat(recordValueStr,'\"')})).join(\" \");var object,keys,entries}function toRegExp(){var input=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\",DEFAULT_VALUE=\".?\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(DEFAULT_VALUE);if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,propsToRemove,requiredInitialProps,stack){if(!stack||function(stackMatch,stackTrace){if(!stackMatch||\"\"===stackMatch)return!0;if(function(stackMatch,stackTrace){var INLINE_SCRIPT_STRING=\"inlineScript\",INJECTED_SCRIPT_STRING=\"injectedScript\",INJECTED_SCRIPT_MARKER=\"\",isInlineScript=function(stackMatch){return stackMatch.indexOf(INLINE_SCRIPT_STRING)>-1},isInjectedScript=function(stackMatch){return stackMatch.indexOf(INJECTED_SCRIPT_STRING)>-1};if(!isInlineScript(stackMatch)&&!isInjectedScript(stackMatch))return!1;var documentURL=window.location.href,pos=documentURL.indexOf(\"#\");-1!==pos&&(documentURL=documentURL.slice(0,pos));var stackLines=stackTrace.split(\"\\n\").slice(2).map((function(line){return line.trim()})).map((function(line){var stack,getStackTraceURL=/(.*?@)?(\\S+)(:\\d+):\\d+\\)?$/.exec(line);if(getStackTraceURL){var stackURL=getStackTraceURL[2];if(startsWith(stackURL,\"(\")&&(stackURL=stackURL.slice(1)),startsWith(stackURL,INJECTED_SCRIPT_MARKER)){stackURL=INJECTED_SCRIPT_STRING;var stackFunction=void 0!==getStackTraceURL[1]?getStackTraceURL[1].slice(0,-1):line.slice(0,getStackTraceURL.index).trim();startsWith(stackFunction,\"at\")&&(stackFunction=stackFunction.slice(2).trim()),stack=\"\".concat(stackFunction,\" \").concat(stackURL).trim()}else stack=stackURL}else stack=line;return stack}));if(stackLines)for(var index=0;index0){var rootString=JSON.stringify(root);if(toRegExp(requiredPaths.join(\"\")).test(rootString))return logMessage(source,\"\".concat(window.location.hostname,\" \").concat(objectToString(root)),!0),!1}for(var i=0;i-1||requiredPath.indexOf(\"*.\")>-1||requiredPath.indexOf(\".*\")>-1||requiredPath.indexOf(\".[].\")>-1||requiredPath.indexOf(\"[].\")>-1||requiredPath.indexOf(\".[]\")>-1,details=getWildcardPropertyInChain(root,requiredPath,hasWildcard);shouldProcess=!hasWildcard;for(var _i=0;_i-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source))}))}))}catch(e){logMessage(source,e)}return root},nativeJSONParse=JSON.parse,jsonParseWrapper=function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];var root=nativeJSONParse.apply(JSON,args);return jsonPruner(root)};jsonParseWrapper.toString=nativeJSONParse.toString.bind(nativeJSONParse),JSON.parse=jsonParseWrapper;var nativeResponseJson=Response.prototype.json;\"undefined\"!=typeof Response&&(Response.prototype.json=function(){return nativeResponseJson.apply(this).then((function(obj){return jsonPruner(obj)}))})}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ @@ -379,7 +379,7 @@ "ubo-no-fetch-if.js", "ubo-no-fetch-if" ], - "scriptlet": "function preventFetch(source,args){function hit(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex;source.ruleText.indexOf(\"#%#//\")>-1?ruleStartIndex=source.ruleText.indexOf(\"#%#//\"):source.ruleText.indexOf(\"##+js\")>-1&&(ruleStartIndex=source.ruleText.indexOf(\"##+js\"));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}function getFetchData(args){var fetchUrl,fetchInit,entries,request,fetchPropsObj={};if(args[0]instanceof Request){var requestData=(request=args[0],entries=[\"url\",\"method\",\"headers\",\"body\",\"mode\",\"credentials\",\"cache\",\"redirect\",\"referrer\",\"referrerPolicy\",\"integrity\",\"keepalive\",\"signal\"].map((function(key){return[key,request[key]]})),entries.reduce((function(acc,el){var key=el[0],value=el[1];return acc[key]=value,acc}),{}));fetchUrl=requestData.url,fetchInit=requestData}else fetchUrl=args[0],fetchInit=args[1];return fetchPropsObj.url=fetchUrl,fetchInit instanceof Object&&Object.keys(fetchInit).forEach((function(prop){fetchPropsObj[prop]=fetchInit[prop]})),fetchPropsObj}function objectToString(obj){return function(obj){return 0===Object.keys(obj).length}(obj)?\"{}\":(object=obj,keys=Object.keys(object),entries=[],keys.forEach((function(key){return entries.push([key,object[key]])})),entries).map((function(pair){var key=pair[0],value=pair[1],recordValueStr=value;return value instanceof Object&&(recordValueStr=\"{ \".concat(objectToString(value),\" }\")),\"\".concat(key,':\"').concat(recordValueStr,'\"')})).join(\" \");var object,keys,entries}function noopPromiseResolve(){var responseBody=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"{}\",responseUrl=arguments.length>1&&void 0!==arguments[1]?arguments[1]:\"\",responseType=arguments.length>2&&void 0!==arguments[2]?arguments[2]:\"default\";if(\"undefined\"!=typeof Response){var response=new Response(responseBody,{status:200,statusText:\"OK\"});return Object.defineProperties(response,{url:{value:responseUrl},type:{value:responseType}}),Promise.resolve(response)}}function matchRequestProps(source,propsToMatch,requestData){if(\"\"===propsToMatch||\"*\"===propsToMatch)return!0;var isMatched,PROPS_DIVIDER,PAIRS_MARKER,LEGAL_MATCH_PROPS,propsObj,data,parsedData=(PROPS_DIVIDER=\" \",PAIRS_MARKER=\":\",LEGAL_MATCH_PROPS=[\"url\",\"method\",\"headers\",\"body\",\"mode\",\"credentials\",\"cache\",\"redirect\",\"referrer\",\"referrerPolicy\",\"integrity\",\"keepalive\",\"signal\"],propsObj={},propsToMatch.split(PROPS_DIVIDER).forEach((function(prop){var dividerInd=prop.indexOf(PAIRS_MARKER),key=prop.slice(0,dividerInd);if(-1!==LEGAL_MATCH_PROPS.indexOf(key)){var value=prop.slice(dividerInd+1);propsObj[key]=value}else propsObj.url=prop})),propsObj);if(data=parsedData,Object.values(data).every((function(value){return function(input){var isValid,FORWARD_SLASH=\"/\",str=function(str){return str.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}(input);input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH&&(str=input.slice(1,-1));try{isValid=new RegExp(str),isValid=!0}catch(e){isValid=!1}return isValid}(value)}))){var matchData=function(data){var matchData={};return Object.keys(data).forEach((function(key){matchData[key]=function(){var input=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\",DEFAULT_VALUE=\".?\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(DEFAULT_VALUE);if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}(data[key])})),matchData}(parsedData);isMatched=Object.keys(matchData).every((function(matchKey){var matchValue=matchData[matchKey];return Object.prototype.hasOwnProperty.call(requestData,matchKey)&&matchValue.test(requestData[matchKey])}))}else logMessage(source,\"Invalid parameter: \".concat(propsToMatch)),isMatched=!1;return isMatched}function logMessage(source,message){var forced=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(forced||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,propsToMatch){var responseBody=arguments.length>2&&void 0!==arguments[2]?arguments[2]:\"emptyObj\",responseType=arguments.length>3&&void 0!==arguments[3]?arguments[3]:\"default\";if(\"undefined\"!=typeof fetch&&\"undefined\"!=typeof Proxy&&\"undefined\"!=typeof Response){var strResponseBody;if(\"\"===responseBody||\"emptyObj\"===responseBody)strResponseBody=\"{}\";else{if(\"emptyArr\"!==responseBody)return;strResponseBody=\"[]\"}if(\"default\"===responseType||\"opaque\"===responseType){var handlerWrapper=function(target,thisArg,args){var fetchData=getFetchData(args);return void 0===propsToMatch?(logMessage(source,\"fetch( \".concat(objectToString(fetchData),\" )\"),!0),hit(source),Reflect.apply(target,thisArg,args)):matchRequestProps(source,propsToMatch,fetchData)?(hit(source),noopPromiseResolve(strResponseBody,fetchData.url,responseType)):Reflect.apply(target,thisArg,args)};fetch=new Proxy(fetch,{apply:handlerWrapper})}else logMessage(source,\"Invalid parameter: \".concat(responseType))}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function preventFetch(source,args){function hit(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex;source.ruleText.indexOf(\"#%#//\")>-1?ruleStartIndex=source.ruleText.indexOf(\"#%#//\"):source.ruleText.indexOf(\"##+js\")>-1&&(ruleStartIndex=source.ruleText.indexOf(\"##+js\"));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}function getFetchData(args){var fetchUrl,fetchInit,entries,request,fetchPropsObj={};if(args[0]instanceof Request){var requestData=(request=args[0],entries=[\"url\",\"method\",\"headers\",\"body\",\"mode\",\"credentials\",\"cache\",\"redirect\",\"referrer\",\"referrerPolicy\",\"integrity\",\"keepalive\",\"signal\"].map((function(key){return[key,request[key]]})),entries.reduce((function(acc,el){var key=el[0],value=el[1];return acc[key]=value,acc}),{}));fetchUrl=requestData.url,fetchInit=requestData}else fetchUrl=args[0],fetchInit=args[1];return fetchPropsObj.url=fetchUrl,fetchInit instanceof Object&&Object.keys(fetchInit).forEach((function(prop){fetchPropsObj[prop]=fetchInit[prop]})),fetchPropsObj}function objectToString(obj){return function(obj){return 0===Object.keys(obj).length&&!obj.prototype}(obj)?\"{}\":(object=obj,keys=Object.keys(object),entries=[],keys.forEach((function(key){return entries.push([key,object[key]])})),entries).map((function(pair){var key=pair[0],value=pair[1],recordValueStr=value;return value instanceof Object&&(recordValueStr=\"{ \".concat(objectToString(value),\" }\")),\"\".concat(key,':\"').concat(recordValueStr,'\"')})).join(\" \");var object,keys,entries}function noopPromiseResolve(){var responseBody=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"{}\",responseUrl=arguments.length>1&&void 0!==arguments[1]?arguments[1]:\"\",responseType=arguments.length>2&&void 0!==arguments[2]?arguments[2]:\"default\";if(\"undefined\"!=typeof Response){var response=new Response(responseBody,{status:200,statusText:\"OK\"});return Object.defineProperties(response,{url:{value:responseUrl},type:{value:responseType}}),Promise.resolve(response)}}function matchRequestProps(source,propsToMatch,requestData){if(\"\"===propsToMatch||\"*\"===propsToMatch)return!0;var isMatched,PROPS_DIVIDER,PAIRS_MARKER,LEGAL_MATCH_PROPS,propsObj,data,parsedData=(PROPS_DIVIDER=\" \",PAIRS_MARKER=\":\",LEGAL_MATCH_PROPS=[\"url\",\"method\",\"headers\",\"body\",\"mode\",\"credentials\",\"cache\",\"redirect\",\"referrer\",\"referrerPolicy\",\"integrity\",\"keepalive\",\"signal\"],propsObj={},propsToMatch.split(PROPS_DIVIDER).forEach((function(prop){var dividerInd=prop.indexOf(PAIRS_MARKER),key=prop.slice(0,dividerInd);if(-1!==LEGAL_MATCH_PROPS.indexOf(key)){var value=prop.slice(dividerInd+1);propsObj[key]=value}else propsObj.url=prop})),propsObj);if(data=parsedData,Object.values(data).every((function(value){return function(input){var isValid,FORWARD_SLASH=\"/\",str=function(str){return str.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}(input);input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH&&(str=input.slice(1,-1));try{isValid=new RegExp(str),isValid=!0}catch(e){isValid=!1}return isValid}(value)}))){var matchData=function(data){var matchData={};return Object.keys(data).forEach((function(key){matchData[key]=function(){var input=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\",DEFAULT_VALUE=\".?\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(DEFAULT_VALUE);if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}(data[key])})),matchData}(parsedData);isMatched=Object.keys(matchData).every((function(matchKey){var matchValue=matchData[matchKey];return Object.prototype.hasOwnProperty.call(requestData,matchKey)&&matchValue.test(requestData[matchKey])}))}else logMessage(source,\"Invalid parameter: \".concat(propsToMatch)),isMatched=!1;return isMatched}function logMessage(source,message){var forced=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(forced||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,propsToMatch){var responseBody=arguments.length>2&&void 0!==arguments[2]?arguments[2]:\"emptyObj\",responseType=arguments.length>3&&void 0!==arguments[3]?arguments[3]:\"default\";if(\"undefined\"!=typeof fetch&&\"undefined\"!=typeof Proxy&&\"undefined\"!=typeof Response){var strResponseBody;if(\"\"===responseBody||\"emptyObj\"===responseBody)strResponseBody=\"{}\";else{if(\"emptyArr\"!==responseBody)return;strResponseBody=\"[]\"}if(\"default\"===responseType||\"opaque\"===responseType){var handlerWrapper=function(target,thisArg,args){var fetchData=getFetchData(args);return void 0===propsToMatch?(logMessage(source,\"fetch( \".concat(objectToString(fetchData),\" )\"),!0),hit(source),Reflect.apply(target,thisArg,args)):matchRequestProps(source,propsToMatch,fetchData)?(hit(source),noopPromiseResolve(strResponseBody,fetchData.url,responseType)):Reflect.apply(target,thisArg,args)};fetch=new Proxy(fetch,{apply:handlerWrapper})}else logMessage(source,\"Invalid parameter: \".concat(responseType))}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ @@ -404,13 +404,13 @@ "ubo-aost", "abp-abort-on-stack-trace" ], - "scriptlet": "function abortOnStackTrace(source,args){function randomId(){return Math.random().toString(36).substr(2,9)}function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}function matchStackTrace(stackMatch,stackTrace){if(!stackMatch||\"\"===stackMatch)return!0;if(function(stackMatch,stackTrace){var INLINE_SCRIPT_STRING=\"inlineScript\",INJECTED_SCRIPT_STRING=\"injectedScript\",INJECTED_SCRIPT_MARKER=\"\",isInlineScript=function(stackMatch){return stackMatch.indexOf(INLINE_SCRIPT_STRING)>-1},isInjectedScript=function(stackMatch){return stackMatch.indexOf(INJECTED_SCRIPT_STRING)>-1};if(!isInlineScript(stackMatch)&&!isInjectedScript(stackMatch))return!1;var documentURL=window.location.href,pos=documentURL.indexOf(\"#\");-1!==pos&&(documentURL=documentURL.slice(0,pos));var stackSteps=stackTrace.split(\"\\n\").slice(2).map((function(line){return line.trim()})),stackLines=stackSteps.map((function(line){var stack,getStackTraceURL=/(.*?@)?(\\S+)(:\\d+):\\d+\\)?$/.exec(line);if(getStackTraceURL){var stackURL=getStackTraceURL[2];if(startsWith(stackURL,\"(\")&&(stackURL=stackURL.slice(1)),startsWith(stackURL,INJECTED_SCRIPT_MARKER)){stackURL=INJECTED_SCRIPT_STRING;var stackFunction=void 0!==getStackTraceURL[1]?getStackTraceURL[1].slice(0,-1):line.slice(0,getStackTraceURL.index).trim();startsWith(stackFunction,\"at\")&&(stackFunction=stackFunction.slice(2).trim()),stack=\"\".concat(stackFunction,\" \").concat(stackURL).trim()}else stack=stackURL}else stack=line;return stack}));if(stackLines)for(var index=0;index0&&void 0!==arguments[0]?arguments[0]:\"\",DEFAULT_VALUE=\".?\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(DEFAULT_VALUE);if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}(stackMatch),refinedStackTrace=stackTrace.split(\"\\n\").slice(2).map((function(line){return line.trim()})).join(\"\\n\");return Object.getOwnPropertyDescriptor(RegExp.prototype,\"test\").value.call(stackRegexp,refinedStackTrace)}function startsWith(str,prefix){return!!str&&0===str.indexOf(prefix)}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property,stack){if(property&&stack){var rid=randomId(),abort=function(){throw function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source),new ReferenceError(rid)};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;if(chain)Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}});else if(stack.match(/^(inlineScript|injectedScript)$/)||function(input){var isValid,FORWARD_SLASH=\"/\",str=function(str){return str.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}(input);input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH&&(str=input.slice(1,-1));try{isValid=new RegExp(str),isValid=!0}catch(e){isValid=!1}return isValid}(stack)){var descriptorWrapper=Object.assign({isAbortingSuspended:!1,isolateCallback:function(cb){this.isAbortingSuspended=!0;try{for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];var result=cb.apply(void 0,args);return this.isAbortingSuspended=!1,result}catch(_unused){var rid=randomId();throw this.isAbortingSuspended=!1,new ReferenceError(rid)}}},{value:base[prop],get:function(){return!this.isAbortingSuspended&&this.isolateCallback(matchStackTrace,stack,(new Error).stack)&&abort(),this.value},set:function(newValue){!this.isAbortingSuspended&&this.isolateCallback(matchStackTrace,stack,(new Error).stack)&&abort(),this.value=newValue}});!function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{get:function(){return descriptorWrapper.get.call(descriptorWrapper)},set:function(newValue){descriptorWrapper.set.call(descriptorWrapper,newValue)}})}else!function(source,message){(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}(source,\"Invalid parameter: \".concat(stack))}(window,property),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind()}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function abortOnStackTrace(source,args){function randomId(){return Math.random().toString(36).slice(2,9)}function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length&&!obj.prototype)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}function matchStackTrace(stackMatch,stackTrace){if(!stackMatch||\"\"===stackMatch)return!0;if(function(stackMatch,stackTrace){var INLINE_SCRIPT_STRING=\"inlineScript\",INJECTED_SCRIPT_STRING=\"injectedScript\",INJECTED_SCRIPT_MARKER=\"\",isInlineScript=function(stackMatch){return stackMatch.indexOf(INLINE_SCRIPT_STRING)>-1},isInjectedScript=function(stackMatch){return stackMatch.indexOf(INJECTED_SCRIPT_STRING)>-1};if(!isInlineScript(stackMatch)&&!isInjectedScript(stackMatch))return!1;var documentURL=window.location.href,pos=documentURL.indexOf(\"#\");-1!==pos&&(documentURL=documentURL.slice(0,pos));var stackSteps=stackTrace.split(\"\\n\").slice(2).map((function(line){return line.trim()})),stackLines=stackSteps.map((function(line){var stack,getStackTraceURL=/(.*?@)?(\\S+)(:\\d+):\\d+\\)?$/.exec(line);if(getStackTraceURL){var stackURL=getStackTraceURL[2];if(startsWith(stackURL,\"(\")&&(stackURL=stackURL.slice(1)),startsWith(stackURL,INJECTED_SCRIPT_MARKER)){stackURL=INJECTED_SCRIPT_STRING;var stackFunction=void 0!==getStackTraceURL[1]?getStackTraceURL[1].slice(0,-1):line.slice(0,getStackTraceURL.index).trim();startsWith(stackFunction,\"at\")&&(stackFunction=stackFunction.slice(2).trim()),stack=\"\".concat(stackFunction,\" \").concat(stackURL).trim()}else stack=stackURL}else stack=line;return stack}));if(stackLines)for(var index=0;index0&&void 0!==arguments[0]?arguments[0]:\"\",DEFAULT_VALUE=\".?\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(DEFAULT_VALUE);if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}(stackMatch),refinedStackTrace=stackTrace.split(\"\\n\").slice(2).map((function(line){return line.trim()})).join(\"\\n\");return Object.getOwnPropertyDescriptor(RegExp.prototype,\"test\").value.call(stackRegexp,refinedStackTrace)}function startsWith(str,prefix){return!!str&&0===str.indexOf(prefix)}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property,stack){if(property&&stack){var rid=randomId(),abort=function(){throw function(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex,AG_SCRIPTLET_MARKER=\"#%#//\",UBO_SCRIPTLET_MARKER=\"##+js\";source.ruleText.indexOf(AG_SCRIPTLET_MARKER)>-1?ruleStartIndex=source.ruleText.indexOf(AG_SCRIPTLET_MARKER):source.ruleText.indexOf(UBO_SCRIPTLET_MARKER)>-1&&(ruleStartIndex=source.ruleText.indexOf(UBO_SCRIPTLET_MARKER));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}(source),new ReferenceError(rid)};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;if(chain)Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}});else if(stack.match(/^(inlineScript|injectedScript)$/)||function(input){var isValid,FORWARD_SLASH=\"/\",str=function(str){return str.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}(input);input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH&&(str=input.slice(1,-1));try{isValid=new RegExp(str),isValid=!0}catch(e){isValid=!1}return isValid}(stack)){var descriptorWrapper=Object.assign({isAbortingSuspended:!1,isolateCallback:function(cb){this.isAbortingSuspended=!0;try{for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];var result=cb.apply(void 0,args);return this.isAbortingSuspended=!1,result}catch(_unused){var rid=randomId();throw this.isAbortingSuspended=!1,new ReferenceError(rid)}}},{value:base[prop],get:function(){return!this.isAbortingSuspended&&this.isolateCallback(matchStackTrace,stack,(new Error).stack)&&abort(),this.value},set:function(newValue){!this.isAbortingSuspended&&this.isolateCallback(matchStackTrace,stack,(new Error).stack)&&abort(),this.value=newValue}});!function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{get:function(){return descriptorWrapper.get.call(descriptorWrapper)},set:function(newValue){descriptorWrapper.set.call(descriptorWrapper,newValue)}})}else!function(source,message){(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}(source,\"Invalid parameter: \".concat(stack))}(window,property),window.onerror=function(rid){var nativeOnError=window.onerror;return function(error){if(\"string\"==typeof error&&-1!==error.indexOf(rid))return!0;if(nativeOnError instanceof Function){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return nativeOnError.apply(this,[error].concat(args))}return!1}}(rid).bind()}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ "log-on-stack-trace" ], - "scriptlet": "function logOnStacktrace(source,args){function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}function hit(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex;source.ruleText.indexOf(\"#%#//\")>-1?ruleStartIndex=source.ruleText.indexOf(\"#%#//\"):source.ruleText.indexOf(\"##+js\")>-1&&(ruleStartIndex=source.ruleText.indexOf(\"##+js\"));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}function logMessage(source,message){var forced=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(forced||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property){if(property){var refineStackTrace=function(stackString){var logInfoArray=stackString.split(\"\\n\").slice(2).map((function(line){return line.replace(/ {4}at /,\"\")})).map((function(line){var funcName,funcFullPath,reg=/\\(([^\\)]+)\\)/,regFirefox=/(.*?@)(\\S+)(:\\d+):\\d+\\)?$/;return line.match(reg)?(funcName=line.split(\" \").slice(0,-1).join(\" \"),funcFullPath=line.match(reg)[1]):line.match(regFirefox)?(funcName=line.split(\"@\").slice(0,-1).join(\" \"),funcFullPath=line.match(regFirefox)[2]):(funcName=\"function name is not available\",funcFullPath=line),[funcName,funcFullPath]})),logInfoObject={};return logInfoArray.forEach((function(pair){logInfoObject[pair[0]]=pair[1]})),logInfoObject};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;if(chain)Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}});else{var value=base[prop];!function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{get:function(){return hit(source),logMessage(source,\"Get \".concat(prop),!0),console.table(refineStackTrace((new Error).stack)),value},set:function(newValue){hit(source),logMessage(source,\"Set \".concat(prop),!0),console.table(refineStackTrace((new Error).stack)),value=newValue}})}}(window,property)}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function logOnStacktrace(source,args){function getPropertyInChain(base,chain){var pos=chain.indexOf(\".\");if(-1===pos)return{base:base,prop:chain};var prop=chain.slice(0,pos);if(null===base)return{base:base,prop:prop,chain:chain};var obj,nextBase=base[prop];return chain=chain.slice(pos+1),(base instanceof Object||\"object\"==typeof base)&&(obj=base,0===Object.keys(obj).length&&!obj.prototype)||null===nextBase?{base:base,prop:prop,chain:chain}:void 0!==nextBase?getPropertyInChain(nextBase,chain):(Object.defineProperty(base,prop,{configurable:!0}),{base:base,prop:prop,chain:chain})}function hit(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex;source.ruleText.indexOf(\"#%#//\")>-1?ruleStartIndex=source.ruleText.indexOf(\"#%#//\"):source.ruleText.indexOf(\"##+js\")>-1&&(ruleStartIndex=source.ruleText.indexOf(\"##+js\"));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}function logMessage(source,message){var forced=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(forced||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,property){if(property){var refineStackTrace=function(stackString){var logInfoArray=stackString.split(\"\\n\").slice(2).map((function(line){return line.replace(/ {4}at /,\"\")})).map((function(line){var funcName,funcFullPath,reg=/\\(([^\\)]+)\\)/,regFirefox=/(.*?@)(\\S+)(:\\d+):\\d+\\)?$/;return line.match(reg)?(funcName=line.split(\" \").slice(0,-1).join(\" \"),funcFullPath=line.match(reg)[1]):line.match(regFirefox)?(funcName=line.split(\"@\").slice(0,-1).join(\" \"),funcFullPath=line.match(regFirefox)[2]):(funcName=\"function name is not available\",funcFullPath=line),[funcName,funcFullPath]})),logInfoObject={};return logInfoArray.forEach((function(pair){logInfoObject[pair[0]]=pair[1]})),logInfoObject};!function setChainPropAccess(owner,property){var chainInfo=getPropertyInChain(owner,property),base=chainInfo.base,prop=chainInfo.prop,chain=chainInfo.chain;if(chain)Object.defineProperty(owner,prop,{get:function(){return base},set:function(a){base=a,a instanceof Object&&setChainPropAccess(a,chain)}});else{var value=base[prop];!function(object,property,descriptor){var currentDescriptor=Object.getOwnPropertyDescriptor(object,property);if(currentDescriptor&&!currentDescriptor.configurable)return!1;Object.defineProperty(object,property,descriptor)}(base,prop,{get:function(){return hit(source),logMessage(source,\"Get \".concat(prop),!0),console.table(refineStackTrace((new Error).stack)),value},set:function(newValue){hit(source),logMessage(source,\"Set \".concat(prop),!0),console.table(refineStackTrace((new Error).stack)),value=newValue}})}}(window,property)}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ @@ -419,7 +419,7 @@ "ubo-no-xhr-if.js", "ubo-no-xhr-if" ], - "scriptlet": "function preventXHR(source,args){function hit(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex;source.ruleText.indexOf(\"#%#//\")>-1?ruleStartIndex=source.ruleText.indexOf(\"#%#//\"):source.ruleText.indexOf(\"##+js\")>-1&&(ruleStartIndex=source.ruleText.indexOf(\"##+js\"));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}function logMessage(source,message){var forced=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(forced||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}function objectToString(obj){return function(obj){return 0===Object.keys(obj).length}(obj)?\"{}\":(object=obj,keys=Object.keys(object),entries=[],keys.forEach((function(key){return entries.push([key,object[key]])})),entries).map((function(pair){var key=pair[0],value=pair[1],recordValueStr=value;return value instanceof Object&&(recordValueStr=\"{ \".concat(objectToString(value),\" }\")),\"\".concat(key,':\"').concat(recordValueStr,'\"')})).join(\" \");var object,keys,entries}function getNumberFromString(rawString){var num,parsedDelay=parseInt(rawString,10);return num=parsedDelay,(Number.isNaN||window.isNaN)(num)?null:parsedDelay}function nativeIsFinite(num){return(Number.isFinite||window.isFinite)(num)}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,propsToMatch,customResponseText){if(\"undefined\"!=typeof Proxy){var responseUrl,shouldPrevent=!1,response=\"\",responseText=\"\",openHandler={apply:function(target,thisArg,args){var xhrData={method:args[0],url:args[1]};return responseUrl=xhrData.url,void 0===propsToMatch?(logMessage(source,\"xhr( \".concat(objectToString(xhrData),\" )\"),!0),hit(source)):shouldPrevent=function(source,propsToMatch,requestData){if(\"\"===propsToMatch||\"*\"===propsToMatch)return!0;var isMatched,PROPS_DIVIDER,PAIRS_MARKER,LEGAL_MATCH_PROPS,propsObj,data,parsedData=(PROPS_DIVIDER=\" \",PAIRS_MARKER=\":\",LEGAL_MATCH_PROPS=[\"url\",\"method\",\"headers\",\"body\",\"mode\",\"credentials\",\"cache\",\"redirect\",\"referrer\",\"referrerPolicy\",\"integrity\",\"keepalive\",\"signal\"],propsObj={},propsToMatch.split(PROPS_DIVIDER).forEach((function(prop){var dividerInd=prop.indexOf(PAIRS_MARKER),key=prop.slice(0,dividerInd);if(-1!==LEGAL_MATCH_PROPS.indexOf(key)){var value=prop.slice(dividerInd+1);propsObj[key]=value}else propsObj.url=prop})),propsObj);if(data=parsedData,Object.values(data).every((function(value){return function(input){var isValid,FORWARD_SLASH=\"/\",str=function(str){return str.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}(input);input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH&&(str=input.slice(1,-1));try{isValid=new RegExp(str),isValid=!0}catch(e){isValid=!1}return isValid}(value)}))){var matchData=function(data){var matchData={};return Object.keys(data).forEach((function(key){matchData[key]=function(){var input=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(\".?\");if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}(data[key])})),matchData}(parsedData);isMatched=Object.keys(matchData).every((function(matchKey){var matchValue=matchData[matchKey];return Object.prototype.hasOwnProperty.call(requestData,matchKey)&&matchValue.test(requestData[matchKey])}))}else logMessage(source,\"Invalid parameter: \".concat(propsToMatch)),isMatched=!1;return isMatched}(source,propsToMatch,xhrData),Reflect.apply(target,thisArg,args)}},sendHandler={apply:function(target,thisArg,args){if(!shouldPrevent)return Reflect.apply(target,thisArg,args);if(\"blob\"===thisArg.responseType&&(response=new Blob),\"arraybuffer\"===thisArg.responseType&&(response=new ArrayBuffer),customResponseText){var randomText=function(customResponseText){var customResponse=customResponseText;if(\"true\"===customResponse)return Math.random().toString(36).slice(-10);if(customResponse=customResponse.replace(\"length:\",\"\"),!/^\\d+-\\d+$/.test(customResponse))return null;var min,max,rangeMin=getNumberFromString(customResponse.split(\"-\")[0]),rangeMax=getNumberFromString(customResponse.split(\"-\")[1]);if(!nativeIsFinite(rangeMin)||!nativeIsFinite(rangeMax))return null;if(rangeMin>rangeMax){var temp=rangeMin;rangeMin=rangeMax,rangeMax=temp}return rangeMax>5e5?null:function(length){for(var result=\"\",characters=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+=~\",charactersLength=characters.length,i=0;i-1?ruleStartIndex=source.ruleText.indexOf(\"#%#//\"):source.ruleText.indexOf(\"##+js\")>-1&&(ruleStartIndex=source.ruleText.indexOf(\"##+js\"));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}function logMessage(source,message){var forced=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(forced||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}function objectToString(obj){return function(obj){return 0===Object.keys(obj).length&&!obj.prototype}(obj)?\"{}\":(object=obj,keys=Object.keys(object),entries=[],keys.forEach((function(key){return entries.push([key,object[key]])})),entries).map((function(pair){var key=pair[0],value=pair[1],recordValueStr=value;return value instanceof Object&&(recordValueStr=\"{ \".concat(objectToString(value),\" }\")),\"\".concat(key,':\"').concat(recordValueStr,'\"')})).join(\" \");var object,keys,entries}function getNumberFromString(rawString){var num,parsedDelay=parseInt(rawString,10);return num=parsedDelay,(Number.isNaN||window.isNaN)(num)?null:parsedDelay}function nativeIsFinite(num){return(Number.isFinite||window.isFinite)(num)}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,propsToMatch,customResponseText){if(\"undefined\"!=typeof Proxy){var responseUrl,shouldPrevent=!1,response=\"\",responseText=\"\",openHandler={apply:function(target,thisArg,args){var xhrData={method:args[0],url:args[1]};return responseUrl=xhrData.url,void 0===propsToMatch?(logMessage(source,\"xhr( \".concat(objectToString(xhrData),\" )\"),!0),hit(source)):shouldPrevent=function(source,propsToMatch,requestData){if(\"\"===propsToMatch||\"*\"===propsToMatch)return!0;var isMatched,PROPS_DIVIDER,PAIRS_MARKER,LEGAL_MATCH_PROPS,propsObj,data,parsedData=(PROPS_DIVIDER=\" \",PAIRS_MARKER=\":\",LEGAL_MATCH_PROPS=[\"url\",\"method\",\"headers\",\"body\",\"mode\",\"credentials\",\"cache\",\"redirect\",\"referrer\",\"referrerPolicy\",\"integrity\",\"keepalive\",\"signal\"],propsObj={},propsToMatch.split(PROPS_DIVIDER).forEach((function(prop){var dividerInd=prop.indexOf(PAIRS_MARKER),key=prop.slice(0,dividerInd);if(-1!==LEGAL_MATCH_PROPS.indexOf(key)){var value=prop.slice(dividerInd+1);propsObj[key]=value}else propsObj.url=prop})),propsObj);if(data=parsedData,Object.values(data).every((function(value){return function(input){var isValid,FORWARD_SLASH=\"/\",str=function(str){return str.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}(input);input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH&&(str=input.slice(1,-1));try{isValid=new RegExp(str),isValid=!0}catch(e){isValid=!1}return isValid}(value)}))){var matchData=function(data){var matchData={};return Object.keys(data).forEach((function(key){matchData[key]=function(){var input=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(\".?\");if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}(data[key])})),matchData}(parsedData);isMatched=Object.keys(matchData).every((function(matchKey){var matchValue=matchData[matchKey];return Object.prototype.hasOwnProperty.call(requestData,matchKey)&&matchValue.test(requestData[matchKey])}))}else logMessage(source,\"Invalid parameter: \".concat(propsToMatch)),isMatched=!1;return isMatched}(source,propsToMatch,xhrData),Reflect.apply(target,thisArg,args)}},sendHandler={apply:function(target,thisArg,args){if(!shouldPrevent)return Reflect.apply(target,thisArg,args);if(\"blob\"===thisArg.responseType&&(response=new Blob),\"arraybuffer\"===thisArg.responseType&&(response=new ArrayBuffer),customResponseText){var randomText=function(customResponseText){var customResponse=customResponseText;if(\"true\"===customResponse)return Math.random().toString(36).slice(-10);if(customResponse=customResponse.replace(\"length:\",\"\"),!/^\\d+-\\d+$/.test(customResponse))return null;var min,max,rangeMin=getNumberFromString(customResponse.split(\"-\")[0]),rangeMax=getNumberFromString(customResponse.split(\"-\")[1]);if(!nativeIsFinite(rangeMin)||!nativeIsFinite(rangeMax))return null;if(rangeMin>rangeMax){var temp=rangeMin;rangeMin=rangeMax,rangeMax=temp}return rangeMax>5e5?null:function(length){for(var result=\"\",characters=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+=~\",charactersLength=characters.length,i=0;i-1?ruleStartIndex=source.ruleText.indexOf(\"#%#//\"):source.ruleText.indexOf(\"##+js\")>-1&&(ruleStartIndex=source.ruleText.indexOf(\"##+js\"));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}function logMessage(source,message){var forced=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(forced||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}function toRegExp(){var input=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\",DEFAULT_VALUE=\".?\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(DEFAULT_VALUE);if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}function objectToString(obj){return function(obj){return 0===Object.keys(obj).length}(obj)?\"{}\":(object=obj,keys=Object.keys(object),entries=[],keys.forEach((function(key){return entries.push([key,object[key]])})),entries).map((function(pair){var key=pair[0],value=pair[1],recordValueStr=value;return value instanceof Object&&(recordValueStr=\"{ \".concat(objectToString(value),\" }\")),\"\".concat(key,':\"').concat(recordValueStr,'\"')})).join(\" \");var object,keys,entries}function matchRequestProps(source,propsToMatch,requestData){if(\"\"===propsToMatch||\"*\"===propsToMatch)return!0;var isMatched,PROPS_DIVIDER,PAIRS_MARKER,LEGAL_MATCH_PROPS,propsObj,data,parsedData=(PROPS_DIVIDER=\" \",PAIRS_MARKER=\":\",LEGAL_MATCH_PROPS=[\"url\",\"method\",\"headers\",\"body\",\"mode\",\"credentials\",\"cache\",\"redirect\",\"referrer\",\"referrerPolicy\",\"integrity\",\"keepalive\",\"signal\"],propsObj={},propsToMatch.split(PROPS_DIVIDER).forEach((function(prop){var dividerInd=prop.indexOf(PAIRS_MARKER),key=prop.slice(0,dividerInd);if(-1!==LEGAL_MATCH_PROPS.indexOf(key)){var value=prop.slice(dividerInd+1);propsObj[key]=value}else propsObj.url=prop})),propsObj);if(data=parsedData,Object.values(data).every((function(value){return function(input){var isValid,FORWARD_SLASH=\"/\",str=function(str){return str.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}(input);input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH&&(str=input.slice(1,-1));try{isValid=new RegExp(str),isValid=!0}catch(e){isValid=!1}return isValid}(value)}))){var matchData=function(data){var matchData={};return Object.keys(data).forEach((function(key){matchData[key]=toRegExp(data[key])})),matchData}(parsedData);isMatched=Object.keys(matchData).every((function(matchKey){var matchValue=matchData[matchKey];return Object.prototype.hasOwnProperty.call(requestData,matchKey)&&matchValue.test(requestData[matchKey])}))}else logMessage(source,\"Invalid parameter: \".concat(propsToMatch)),isMatched=!1;return isMatched}function getXhrData(method,url,async,user,password){return{method:method,url:url,async:async,user:user,password:password}}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source){var pattern=arguments.length>1&&void 0!==arguments[1]?arguments[1]:\"\",replacement=arguments.length>2&&void 0!==arguments[2]?arguments[2]:\"\",propsToMatch=arguments.length>3&&void 0!==arguments[3]?arguments[3]:\"\";if(\"undefined\"!=typeof Proxy)if(\"\"!==pattern||\"\"===replacement){var xhrData,shouldLog=\"\"===pattern&&\"\"===replacement,nativeOpen=window.XMLHttpRequest.prototype.open,nativeSend=window.XMLHttpRequest.prototype.send,shouldReplace=!1,requestHeaders=[],openWrapper=function(target,thisArg,args){if(xhrData=getXhrData.apply(null,args),shouldLog){var _message=\"xhr( \".concat(objectToString(xhrData),\" )\");return logMessage(source,_message,!0),hit(source),Reflect.apply(target,thisArg,args)}if(shouldReplace=matchRequestProps(source,propsToMatch,xhrData)){var setRequestHeaderHandler={apply:function(target,thisArg,args){return requestHeaders.push(args),Reflect.apply(target,thisArg,args)}};thisArg.setRequestHeader=new Proxy(thisArg.setRequestHeader,setRequestHeaderHandler)}return Reflect.apply(target,thisArg,args)},sendWrapper=function(target,thisArg,args){if(!shouldReplace)return Reflect.apply(target,thisArg,args);var forgedRequest=new XMLHttpRequest;forgedRequest.addEventListener(\"readystatechange\",(function(){if(4===forgedRequest.readyState){var readyState=forgedRequest.readyState,response=forgedRequest.response,responseText=forgedRequest.responseText,responseURL=forgedRequest.responseURL,responseXML=forgedRequest.responseXML,status=forgedRequest.status,statusText=forgedRequest.statusText,content=responseText||response;if(\"string\"==typeof content){var patternRegexp=\"*\"===pattern?/(\\n|.)*/:toRegExp(pattern),modifiedContent=content.replace(patternRegexp,replacement);Object.defineProperties(thisArg,{readyState:{value:readyState},response:{value:modifiedContent},responseText:{value:modifiedContent},responseURL:{value:responseURL},responseXML:{value:responseXML},status:{value:status},statusText:{value:statusText}}),setTimeout((function(){var stateEvent=new Event(\"readystatechange\");thisArg.dispatchEvent(stateEvent);var loadEvent=new Event(\"load\");thisArg.dispatchEvent(loadEvent);var loadEndEvent=new Event(\"loadend\");thisArg.dispatchEvent(loadEndEvent)}),1),hit(source)}}})),nativeOpen.apply(forgedRequest,[xhrData.method,xhrData.url]),requestHeaders.forEach((function(header){var name=header[0],value=header[1];forgedRequest.setRequestHeader(name,value)})),requestHeaders=[];try{nativeSend.call(forgedRequest,args)}catch(_unused){return Reflect.apply(target,thisArg,args)}},openHandler={apply:openWrapper},sendHandler={apply:sendWrapper};XMLHttpRequest.prototype.open=new Proxy(XMLHttpRequest.prototype.open,openHandler),XMLHttpRequest.prototype.send=new Proxy(XMLHttpRequest.prototype.send,sendHandler)}else{logMessage(source,\"Pattern argument should not be empty string.\")}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function trustedReplaceXhrResponse(source,args){function hit(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex;source.ruleText.indexOf(\"#%#//\")>-1?ruleStartIndex=source.ruleText.indexOf(\"#%#//\"):source.ruleText.indexOf(\"##+js\")>-1&&(ruleStartIndex=source.ruleText.indexOf(\"##+js\"));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}function logMessage(source,message){var forced=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(forced||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}function toRegExp(){var input=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\",DEFAULT_VALUE=\".?\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(DEFAULT_VALUE);if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}function objectToString(obj){return function(obj){return 0===Object.keys(obj).length&&!obj.prototype}(obj)?\"{}\":(object=obj,keys=Object.keys(object),entries=[],keys.forEach((function(key){return entries.push([key,object[key]])})),entries).map((function(pair){var key=pair[0],value=pair[1],recordValueStr=value;return value instanceof Object&&(recordValueStr=\"{ \".concat(objectToString(value),\" }\")),\"\".concat(key,':\"').concat(recordValueStr,'\"')})).join(\" \");var object,keys,entries}function matchRequestProps(source,propsToMatch,requestData){if(\"\"===propsToMatch||\"*\"===propsToMatch)return!0;var isMatched,PROPS_DIVIDER,PAIRS_MARKER,LEGAL_MATCH_PROPS,propsObj,data,parsedData=(PROPS_DIVIDER=\" \",PAIRS_MARKER=\":\",LEGAL_MATCH_PROPS=[\"url\",\"method\",\"headers\",\"body\",\"mode\",\"credentials\",\"cache\",\"redirect\",\"referrer\",\"referrerPolicy\",\"integrity\",\"keepalive\",\"signal\"],propsObj={},propsToMatch.split(PROPS_DIVIDER).forEach((function(prop){var dividerInd=prop.indexOf(PAIRS_MARKER),key=prop.slice(0,dividerInd);if(-1!==LEGAL_MATCH_PROPS.indexOf(key)){var value=prop.slice(dividerInd+1);propsObj[key]=value}else propsObj.url=prop})),propsObj);if(data=parsedData,Object.values(data).every((function(value){return function(input){var isValid,FORWARD_SLASH=\"/\",str=function(str){return str.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}(input);input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH&&(str=input.slice(1,-1));try{isValid=new RegExp(str),isValid=!0}catch(e){isValid=!1}return isValid}(value)}))){var matchData=function(data){var matchData={};return Object.keys(data).forEach((function(key){matchData[key]=toRegExp(data[key])})),matchData}(parsedData);isMatched=Object.keys(matchData).every((function(matchKey){var matchValue=matchData[matchKey];return Object.prototype.hasOwnProperty.call(requestData,matchKey)&&matchValue.test(requestData[matchKey])}))}else logMessage(source,\"Invalid parameter: \".concat(propsToMatch)),isMatched=!1;return isMatched}function getXhrData(method,url,async,user,password){return{method:method,url:url,async:async,user:user,password:password}}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source){var pattern=arguments.length>1&&void 0!==arguments[1]?arguments[1]:\"\",replacement=arguments.length>2&&void 0!==arguments[2]?arguments[2]:\"\",propsToMatch=arguments.length>3&&void 0!==arguments[3]?arguments[3]:\"\";if(\"undefined\"!=typeof Proxy)if(\"\"!==pattern||\"\"===replacement){var xhrData,shouldLog=\"\"===pattern&&\"\"===replacement,nativeOpen=window.XMLHttpRequest.prototype.open,nativeSend=window.XMLHttpRequest.prototype.send,shouldReplace=!1,requestHeaders=[],openWrapper=function(target,thisArg,args){if(xhrData=getXhrData.apply(null,args),shouldLog){var _message=\"xhr( \".concat(objectToString(xhrData),\" )\");return logMessage(source,_message,!0),hit(source),Reflect.apply(target,thisArg,args)}if(shouldReplace=matchRequestProps(source,propsToMatch,xhrData)){var setRequestHeaderHandler={apply:function(target,thisArg,args){return requestHeaders.push(args),Reflect.apply(target,thisArg,args)}};thisArg.setRequestHeader=new Proxy(thisArg.setRequestHeader,setRequestHeaderHandler)}return Reflect.apply(target,thisArg,args)},sendWrapper=function(target,thisArg,args){if(!shouldReplace)return Reflect.apply(target,thisArg,args);var forgedRequest=new XMLHttpRequest;forgedRequest.addEventListener(\"readystatechange\",(function(){if(4===forgedRequest.readyState){var readyState=forgedRequest.readyState,response=forgedRequest.response,responseText=forgedRequest.responseText,responseURL=forgedRequest.responseURL,responseXML=forgedRequest.responseXML,status=forgedRequest.status,statusText=forgedRequest.statusText,content=responseText||response;if(\"string\"==typeof content){var patternRegexp=\"*\"===pattern?/(\\n|.)*/:toRegExp(pattern),modifiedContent=content.replace(patternRegexp,replacement);Object.defineProperties(thisArg,{readyState:{value:readyState},response:{value:modifiedContent},responseText:{value:modifiedContent},responseURL:{value:responseURL},responseXML:{value:responseXML},status:{value:status},statusText:{value:statusText}}),setTimeout((function(){var stateEvent=new Event(\"readystatechange\");thisArg.dispatchEvent(stateEvent);var loadEvent=new Event(\"load\");thisArg.dispatchEvent(loadEvent);var loadEndEvent=new Event(\"loadend\");thisArg.dispatchEvent(loadEndEvent)}),1),hit(source)}}})),nativeOpen.apply(forgedRequest,[xhrData.method,xhrData.url]),requestHeaders.forEach((function(header){var name=header[0],value=header[1];forgedRequest.setRequestHeader(name,value)})),requestHeaders=[];try{nativeSend.call(forgedRequest,args)}catch(_unused){return Reflect.apply(target,thisArg,args)}},openHandler={apply:openWrapper},sendHandler={apply:sendWrapper};XMLHttpRequest.prototype.open=new Proxy(XMLHttpRequest.prototype.open,openHandler),XMLHttpRequest.prototype.send=new Proxy(XMLHttpRequest.prototype.send,sendHandler)}else{logMessage(source,\"Pattern argument should not be empty string.\")}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ @@ -483,7 +483,7 @@ "names": [ "trusted-replace-fetch-response" ], - "scriptlet": "function trustedReplaceFetchResponse(source,args){function hit(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex;source.ruleText.indexOf(\"#%#//\")>-1?ruleStartIndex=source.ruleText.indexOf(\"#%#//\"):source.ruleText.indexOf(\"##+js\")>-1&&(ruleStartIndex=source.ruleText.indexOf(\"##+js\"));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}function logMessage(source,message){var forced=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(forced||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}function getFetchData(args){var fetchUrl,fetchInit,entries,request,fetchPropsObj={};if(args[0]instanceof Request){var requestData=(request=args[0],entries=[\"url\",\"method\",\"headers\",\"body\",\"mode\",\"credentials\",\"cache\",\"redirect\",\"referrer\",\"referrerPolicy\",\"integrity\",\"keepalive\",\"signal\"].map((function(key){return[key,request[key]]})),entries.reduce((function(acc,el){var key=el[0],value=el[1];return acc[key]=value,acc}),{}));fetchUrl=requestData.url,fetchInit=requestData}else fetchUrl=args[0],fetchInit=args[1];return fetchPropsObj.url=fetchUrl,fetchInit instanceof Object&&Object.keys(fetchInit).forEach((function(prop){fetchPropsObj[prop]=fetchInit[prop]})),fetchPropsObj}function objectToString(obj){return function(obj){return 0===Object.keys(obj).length}(obj)?\"{}\":(object=obj,keys=Object.keys(object),entries=[],keys.forEach((function(key){return entries.push([key,object[key]])})),entries).map((function(pair){var key=pair[0],value=pair[1],recordValueStr=value;return value instanceof Object&&(recordValueStr=\"{ \".concat(objectToString(value),\" }\")),\"\".concat(key,':\"').concat(recordValueStr,'\"')})).join(\" \");var object,keys,entries}function matchRequestProps(source,propsToMatch,requestData){if(\"\"===propsToMatch||\"*\"===propsToMatch)return!0;var isMatched,PROPS_DIVIDER,PAIRS_MARKER,LEGAL_MATCH_PROPS,propsObj,data,parsedData=(PROPS_DIVIDER=\" \",PAIRS_MARKER=\":\",LEGAL_MATCH_PROPS=[\"url\",\"method\",\"headers\",\"body\",\"mode\",\"credentials\",\"cache\",\"redirect\",\"referrer\",\"referrerPolicy\",\"integrity\",\"keepalive\",\"signal\"],propsObj={},propsToMatch.split(PROPS_DIVIDER).forEach((function(prop){var dividerInd=prop.indexOf(PAIRS_MARKER),key=prop.slice(0,dividerInd);if(-1!==LEGAL_MATCH_PROPS.indexOf(key)){var value=prop.slice(dividerInd+1);propsObj[key]=value}else propsObj.url=prop})),propsObj);if(data=parsedData,Object.values(data).every((function(value){return function(input){var isValid,FORWARD_SLASH=\"/\",str=function(str){return str.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}(input);input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH&&(str=input.slice(1,-1));try{isValid=new RegExp(str),isValid=!0}catch(e){isValid=!1}return isValid}(value)}))){var matchData=function(data){var matchData={};return Object.keys(data).forEach((function(key){matchData[key]=toRegExp(data[key])})),matchData}(parsedData);isMatched=Object.keys(matchData).every((function(matchKey){var matchValue=matchData[matchKey];return Object.prototype.hasOwnProperty.call(requestData,matchKey)&&matchValue.test(requestData[matchKey])}))}else logMessage(source,\"Invalid parameter: \".concat(propsToMatch)),isMatched=!1;return isMatched}function toRegExp(){var input=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\",DEFAULT_VALUE=\".?\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(DEFAULT_VALUE);if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source){var pattern=arguments.length>1&&void 0!==arguments[1]?arguments[1]:\"\",replacement=arguments.length>2&&void 0!==arguments[2]?arguments[2]:\"\",propsToMatch=arguments.length>3&&void 0!==arguments[3]?arguments[3]:\"\";if(\"undefined\"!=typeof fetch&&\"undefined\"!=typeof Proxy&&\"undefined\"!=typeof Response)if(\"\"!==pattern||\"\"===replacement){var fetchData,shouldLog=\"\"===pattern&&\"\"===replacement,nativeFetch=fetch,handlerWrapper=function(target,thisArg,args){return fetchData=getFetchData(args),shouldLog?(logMessage(source,\"fetch( \".concat(objectToString(fetchData),\" )\"),!0),hit(source),Reflect.apply(target,thisArg,args)):matchRequestProps(source,propsToMatch,fetchData)?nativeFetch.apply(null,args).then((function(response){return response.text().then((function(bodyText){var patternRegexp=\"*\"===pattern?/(\\n|.)*/:toRegExp(pattern),modifiedTextContent=bodyText.replace(patternRegexp,replacement),forgedResponse=function(response,textContent){var bodyUsed=response.bodyUsed,headers=response.headers,ok=response.ok,redirected=response.redirected,status=response.status,statusText=response.statusText,type=response.type,url=response.url,forgedResponse=new Response(textContent,{status:status,statusText:statusText,headers:headers});return Object.defineProperties(forgedResponse,{url:{value:url},type:{value:type},ok:{value:ok},bodyUsed:{value:bodyUsed},redirected:{value:redirected}}),forgedResponse}(response,modifiedTextContent);return hit(source),forgedResponse})).catch((function(){var fetchDataStr=objectToString(fetchData),message=\"Response body can't be converted to text: \".concat(fetchDataStr);return logMessage(source,message),Reflect.apply(target,thisArg,args)}))})).catch((function(){return Reflect.apply(target,thisArg,args)})):Reflect.apply(target,thisArg,args)};fetch=new Proxy(fetch,{apply:handlerWrapper})}else logMessage(source,\"Pattern argument should not be empty string.\")}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function trustedReplaceFetchResponse(source,args){function hit(source){if(!0===source.verbose){try{var log=console.log.bind(console),trace=console.trace.bind(console),prefix=source.ruleText||\"\";if(source.domainName){var ruleStartIndex;source.ruleText.indexOf(\"#%#//\")>-1?ruleStartIndex=source.ruleText.indexOf(\"#%#//\"):source.ruleText.indexOf(\"##+js\")>-1&&(ruleStartIndex=source.ruleText.indexOf(\"##+js\"));var rulePart=source.ruleText.slice(ruleStartIndex);prefix=\"\".concat(source.domainName).concat(rulePart)}log(\"\".concat(prefix,\" trace start\")),trace&&trace(),log(\"\".concat(prefix,\" trace end\"))}catch(e){}\"function\"==typeof window.__debug&&window.__debug(source)}}function logMessage(source,message){var forced=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(forced||source.verbose)&&console.log(\"\".concat(source.name,\": \").concat(message))}function getFetchData(args){var fetchUrl,fetchInit,entries,request,fetchPropsObj={};if(args[0]instanceof Request){var requestData=(request=args[0],entries=[\"url\",\"method\",\"headers\",\"body\",\"mode\",\"credentials\",\"cache\",\"redirect\",\"referrer\",\"referrerPolicy\",\"integrity\",\"keepalive\",\"signal\"].map((function(key){return[key,request[key]]})),entries.reduce((function(acc,el){var key=el[0],value=el[1];return acc[key]=value,acc}),{}));fetchUrl=requestData.url,fetchInit=requestData}else fetchUrl=args[0],fetchInit=args[1];return fetchPropsObj.url=fetchUrl,fetchInit instanceof Object&&Object.keys(fetchInit).forEach((function(prop){fetchPropsObj[prop]=fetchInit[prop]})),fetchPropsObj}function objectToString(obj){return function(obj){return 0===Object.keys(obj).length&&!obj.prototype}(obj)?\"{}\":(object=obj,keys=Object.keys(object),entries=[],keys.forEach((function(key){return entries.push([key,object[key]])})),entries).map((function(pair){var key=pair[0],value=pair[1],recordValueStr=value;return value instanceof Object&&(recordValueStr=\"{ \".concat(objectToString(value),\" }\")),\"\".concat(key,':\"').concat(recordValueStr,'\"')})).join(\" \");var object,keys,entries}function matchRequestProps(source,propsToMatch,requestData){if(\"\"===propsToMatch||\"*\"===propsToMatch)return!0;var isMatched,PROPS_DIVIDER,PAIRS_MARKER,LEGAL_MATCH_PROPS,propsObj,data,parsedData=(PROPS_DIVIDER=\" \",PAIRS_MARKER=\":\",LEGAL_MATCH_PROPS=[\"url\",\"method\",\"headers\",\"body\",\"mode\",\"credentials\",\"cache\",\"redirect\",\"referrer\",\"referrerPolicy\",\"integrity\",\"keepalive\",\"signal\"],propsObj={},propsToMatch.split(PROPS_DIVIDER).forEach((function(prop){var dividerInd=prop.indexOf(PAIRS_MARKER),key=prop.slice(0,dividerInd);if(-1!==LEGAL_MATCH_PROPS.indexOf(key)){var value=prop.slice(dividerInd+1);propsObj[key]=value}else propsObj.url=prop})),propsObj);if(data=parsedData,Object.values(data).every((function(value){return function(input){var isValid,FORWARD_SLASH=\"/\",str=function(str){return str.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}(input);input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH&&(str=input.slice(1,-1));try{isValid=new RegExp(str),isValid=!0}catch(e){isValid=!1}return isValid}(value)}))){var matchData=function(data){var matchData={};return Object.keys(data).forEach((function(key){matchData[key]=toRegExp(data[key])})),matchData}(parsedData);isMatched=Object.keys(matchData).every((function(matchKey){var matchValue=matchData[matchKey];return Object.prototype.hasOwnProperty.call(requestData,matchKey)&&matchValue.test(requestData[matchKey])}))}else logMessage(source,\"Invalid parameter: \".concat(propsToMatch)),isMatched=!1;return isMatched}function toRegExp(){var input=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\",DEFAULT_VALUE=\".?\",FORWARD_SLASH=\"/\";if(\"\"===input)return new RegExp(DEFAULT_VALUE);if(input[0]===FORWARD_SLASH&&input[input.length-1]===FORWARD_SLASH)return new RegExp(input.slice(1,-1));var escaped=input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(escaped)}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source){var pattern=arguments.length>1&&void 0!==arguments[1]?arguments[1]:\"\",replacement=arguments.length>2&&void 0!==arguments[2]?arguments[2]:\"\",propsToMatch=arguments.length>3&&void 0!==arguments[3]?arguments[3]:\"\";if(\"undefined\"!=typeof fetch&&\"undefined\"!=typeof Proxy&&\"undefined\"!=typeof Response)if(\"\"!==pattern||\"\"===replacement){var fetchData,shouldLog=\"\"===pattern&&\"\"===replacement,nativeFetch=fetch,handlerWrapper=function(target,thisArg,args){return fetchData=getFetchData(args),shouldLog?(logMessage(source,\"fetch( \".concat(objectToString(fetchData),\" )\"),!0),hit(source),Reflect.apply(target,thisArg,args)):matchRequestProps(source,propsToMatch,fetchData)?nativeFetch.apply(null,args).then((function(response){return response.text().then((function(bodyText){var patternRegexp=\"*\"===pattern?/(\\n|.)*/:toRegExp(pattern),modifiedTextContent=bodyText.replace(patternRegexp,replacement),forgedResponse=function(response,textContent){var bodyUsed=response.bodyUsed,headers=response.headers,ok=response.ok,redirected=response.redirected,status=response.status,statusText=response.statusText,type=response.type,url=response.url,forgedResponse=new Response(textContent,{status:status,statusText:statusText,headers:headers});return Object.defineProperties(forgedResponse,{url:{value:url},type:{value:type},ok:{value:ok},bodyUsed:{value:bodyUsed},redirected:{value:redirected}}),forgedResponse}(response,modifiedTextContent);return hit(source),forgedResponse})).catch((function(){var fetchDataStr=objectToString(fetchData),message=\"Response body can't be converted to text: \".concat(fetchDataStr);return logMessage(source,message),Reflect.apply(target,thisArg,args)}))})).catch((function(){return Reflect.apply(target,thisArg,args)})):Reflect.apply(target,thisArg,args)};fetch=new Proxy(fetch,{apply:handlerWrapper})}else logMessage(source,\"Pattern argument should not be empty string.\")}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ diff --git a/dist/scriptlets.js b/dist/scriptlets.js index 60a95a88a..fcf4e4200 100644 --- a/dist/scriptlets.js +++ b/dist/scriptlets.js @@ -1,7 +1,7 @@ /** * AdGuard Scriptlets - * Version 1.7.10 + * Version 1.7.14 */ (function () { @@ -111,7 +111,7 @@ * @returns {boolean} */ var isEmptyObject = function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; }; /** @@ -1587,7 +1587,7 @@ * Generate random six symbols id */ function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } /** @@ -2018,7 +2018,7 @@ * * 3. Click multiple elements by selector with a delay * ``` - * example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"], button[name='check"], input[type="submit"][value="akkoord"]', '', '500') + * example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"], button[name="check"], input[type="submit"][value="akkoord"]', '', '500') * ``` * * 4. Match cookies by keys using regex and string @@ -7886,7 +7886,11 @@ var ADG_XHR_TYPE = 'xmlhttprequest'; var ADG_SET_CONSTANT_NAME = 'set-constant'; var ADG_SET_CONSTANT_EMPTY_STRING = ''; + var ADG_SET_CONSTANT_EMPTY_ARRAY = 'emptyArr'; + var ADG_SET_CONSTANT_EMPTY_OBJECT = 'emptyObj'; var UBO_SET_CONSTANT_EMPTY_STRING = '\'\''; + var UBO_SET_CONSTANT_EMPTY_ARRAY = '[]'; + var UBO_SET_CONSTANT_EMPTY_OBJECT = '{}'; var ADG_PREVENT_FETCH_NAME = 'prevent-fetch'; var ADG_PREVENT_FETCH_EMPTY_STRING = ''; var ADG_PREVENT_FETCH_WILDCARD = '*'; @@ -8078,9 +8082,16 @@ parsedName = _parseRule.name, parsedParams = _parseRule.args; var preparedParams; + if (parsedName === ADG_SET_CONSTANT_NAME // https://github.com/AdguardTeam/FiltersCompiler/issues/102 - if (parsedName === ADG_SET_CONSTANT_NAME && parsedParams[1] === ADG_SET_CONSTANT_EMPTY_STRING) { + && parsedParams[1] === ADG_SET_CONSTANT_EMPTY_STRING) { preparedParams = [parsedParams[0], UBO_SET_CONSTANT_EMPTY_STRING]; + } else if (parsedName === ADG_SET_CONSTANT_NAME + // https://github.com/uBlockOrigin/uBlock-issues/issues/2411 + && parsedParams[1] === ADG_SET_CONSTANT_EMPTY_ARRAY) { + preparedParams = [parsedParams[0], UBO_SET_CONSTANT_EMPTY_ARRAY]; + } else if (parsedName === ADG_SET_CONSTANT_NAME && parsedParams[1] === ADG_SET_CONSTANT_EMPTY_OBJECT) { + preparedParams = [parsedParams[0], UBO_SET_CONSTANT_EMPTY_OBJECT]; } else if (parsedName === ADG_PREVENT_FETCH_NAME // https://github.com/AdguardTeam/Scriptlets/issues/109 && (parsedParams[0] === ADG_PREVENT_FETCH_WILDCARD || parsedParams[0] === ADG_PREVENT_FETCH_EMPTY_STRING)) { @@ -13799,7 +13810,7 @@ window.onerror = createOnErrorHandler(rid).bind(); } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function setPropertyAccess(object, property, descriptor) { var currentDescriptor = Object.getOwnPropertyDescriptor(object, property); @@ -13921,7 +13932,7 @@ } } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getDescriptorAddon() { return { @@ -13989,7 +14000,7 @@ window.onerror = createOnErrorHandler(rid).bind(); } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function setPropertyAccess(object, property, descriptor) { var currentDescriptor = Object.getOwnPropertyDescriptor(object, property); @@ -14089,7 +14100,7 @@ } } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } var updatedArgs = args ? [].concat(source).concat(args) : [source]; try { @@ -14136,7 +14147,7 @@ window.onerror = createOnErrorHandler(rid).bind(); } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function setPropertyAccess(object, property, descriptor) { var currentDescriptor = Object.getOwnPropertyDescriptor(object, property); @@ -14236,7 +14247,7 @@ } } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } var updatedArgs = args ? [].concat(source).concat(args) : [source]; try { @@ -14307,7 +14318,7 @@ window.onerror = createOnErrorHandler(rid).bind(); } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function setPropertyAccess(object, property, descriptor) { var currentDescriptor = Object.getOwnPropertyDescriptor(object, property); @@ -14477,7 +14488,7 @@ return new RegExp(escaped); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getNativeRegexpTest() { return Object.getOwnPropertyDescriptor(RegExp.prototype, "test").value; @@ -14843,7 +14854,7 @@ window.onerror = createOnErrorHandler(rid).bind(); } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function setPropertyAccess(object, property, descriptor) { var currentDescriptor = Object.getOwnPropertyDescriptor(object, property); @@ -14962,7 +14973,7 @@ } } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } var updatedArgs = args ? [].concat(source).concat(args) : [source]; try { @@ -15010,7 +15021,7 @@ window.onerror = createOnErrorHandler(rid).bind(); } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function setPropertyAccess(object, property, descriptor) { var currentDescriptor = Object.getOwnPropertyDescriptor(object, property); @@ -15111,7 +15122,7 @@ } function noopFunc() {} function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } var updatedArgs = args ? [].concat(source).concat(args) : [source]; try { @@ -15158,7 +15169,7 @@ window.onerror = createOnErrorHandler(rid).bind(); } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function setPropertyAccess(object, property, descriptor) { var currentDescriptor = Object.getOwnPropertyDescriptor(object, property); @@ -15258,7 +15269,7 @@ } } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } var updatedArgs = args ? [].concat(source).concat(args) : [source]; try { @@ -15829,7 +15840,7 @@ return new RegExp(escaped); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getObjectEntries(object) { var keys = Object.keys(object); @@ -16018,7 +16029,7 @@ }).join(" "); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getObjectEntries(object) { var keys = Object.keys(object); @@ -16259,7 +16270,7 @@ } } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } var updatedArgs = args ? [].concat(source).concat(args) : [source]; try { @@ -17296,7 +17307,7 @@ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getRequestData(request) { var requestInitOptions = getRequestProps(); @@ -17399,7 +17410,7 @@ }; } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function hit(source) { if (source.verbose !== true) { @@ -18577,7 +18588,7 @@ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getObjectEntries(object) { var keys = Object.keys(object); @@ -19687,7 +19698,7 @@ return native(num); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getNativeRegexpTest() { return Object.getOwnPropertyDescriptor(RegExp.prototype, "test").value; @@ -20725,7 +20736,7 @@ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getRequestData(request) { var requestInitOptions = getRequestProps(); @@ -21051,7 +21062,7 @@ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getObjectEntries(object) { var keys = Object.keys(object); diff --git a/dist/umd/scriptlets.umd.js b/dist/umd/scriptlets.umd.js index bbdb310af..5aa51a875 100644 --- a/dist/umd/scriptlets.umd.js +++ b/dist/umd/scriptlets.umd.js @@ -1,7 +1,7 @@ /** * AdGuard Scriptlets - * Version 1.7.10 + * Version 1.7.14 */ (function (factory) { @@ -113,7 +113,7 @@ * @returns {boolean} */ var isEmptyObject = function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; }; /** @@ -1589,7 +1589,7 @@ * Generate random six symbols id */ function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } /** @@ -2020,7 +2020,7 @@ * * 3. Click multiple elements by selector with a delay * ``` - * example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"], button[name='check"], input[type="submit"][value="akkoord"]', '', '500') + * example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"], button[name="check"], input[type="submit"][value="akkoord"]', '', '500') * ``` * * 4. Match cookies by keys using regex and string @@ -7888,7 +7888,11 @@ var ADG_XHR_TYPE = 'xmlhttprequest'; var ADG_SET_CONSTANT_NAME = 'set-constant'; var ADG_SET_CONSTANT_EMPTY_STRING = ''; + var ADG_SET_CONSTANT_EMPTY_ARRAY = 'emptyArr'; + var ADG_SET_CONSTANT_EMPTY_OBJECT = 'emptyObj'; var UBO_SET_CONSTANT_EMPTY_STRING = '\'\''; + var UBO_SET_CONSTANT_EMPTY_ARRAY = '[]'; + var UBO_SET_CONSTANT_EMPTY_OBJECT = '{}'; var ADG_PREVENT_FETCH_NAME = 'prevent-fetch'; var ADG_PREVENT_FETCH_EMPTY_STRING = ''; var ADG_PREVENT_FETCH_WILDCARD = '*'; @@ -8080,9 +8084,16 @@ parsedName = _parseRule.name, parsedParams = _parseRule.args; var preparedParams; + if (parsedName === ADG_SET_CONSTANT_NAME // https://github.com/AdguardTeam/FiltersCompiler/issues/102 - if (parsedName === ADG_SET_CONSTANT_NAME && parsedParams[1] === ADG_SET_CONSTANT_EMPTY_STRING) { + && parsedParams[1] === ADG_SET_CONSTANT_EMPTY_STRING) { preparedParams = [parsedParams[0], UBO_SET_CONSTANT_EMPTY_STRING]; + } else if (parsedName === ADG_SET_CONSTANT_NAME + // https://github.com/uBlockOrigin/uBlock-issues/issues/2411 + && parsedParams[1] === ADG_SET_CONSTANT_EMPTY_ARRAY) { + preparedParams = [parsedParams[0], UBO_SET_CONSTANT_EMPTY_ARRAY]; + } else if (parsedName === ADG_SET_CONSTANT_NAME && parsedParams[1] === ADG_SET_CONSTANT_EMPTY_OBJECT) { + preparedParams = [parsedParams[0], UBO_SET_CONSTANT_EMPTY_OBJECT]; } else if (parsedName === ADG_PREVENT_FETCH_NAME // https://github.com/AdguardTeam/Scriptlets/issues/109 && (parsedParams[0] === ADG_PREVENT_FETCH_WILDCARD || parsedParams[0] === ADG_PREVENT_FETCH_EMPTY_STRING)) { @@ -13801,7 +13812,7 @@ window.onerror = createOnErrorHandler(rid).bind(); } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function setPropertyAccess(object, property, descriptor) { var currentDescriptor = Object.getOwnPropertyDescriptor(object, property); @@ -13923,7 +13934,7 @@ } } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getDescriptorAddon() { return { @@ -13991,7 +14002,7 @@ window.onerror = createOnErrorHandler(rid).bind(); } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function setPropertyAccess(object, property, descriptor) { var currentDescriptor = Object.getOwnPropertyDescriptor(object, property); @@ -14091,7 +14102,7 @@ } } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } var updatedArgs = args ? [].concat(source).concat(args) : [source]; try { @@ -14138,7 +14149,7 @@ window.onerror = createOnErrorHandler(rid).bind(); } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function setPropertyAccess(object, property, descriptor) { var currentDescriptor = Object.getOwnPropertyDescriptor(object, property); @@ -14238,7 +14249,7 @@ } } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } var updatedArgs = args ? [].concat(source).concat(args) : [source]; try { @@ -14309,7 +14320,7 @@ window.onerror = createOnErrorHandler(rid).bind(); } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function setPropertyAccess(object, property, descriptor) { var currentDescriptor = Object.getOwnPropertyDescriptor(object, property); @@ -14479,7 +14490,7 @@ return new RegExp(escaped); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getNativeRegexpTest() { return Object.getOwnPropertyDescriptor(RegExp.prototype, "test").value; @@ -14845,7 +14856,7 @@ window.onerror = createOnErrorHandler(rid).bind(); } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function setPropertyAccess(object, property, descriptor) { var currentDescriptor = Object.getOwnPropertyDescriptor(object, property); @@ -14964,7 +14975,7 @@ } } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } var updatedArgs = args ? [].concat(source).concat(args) : [source]; try { @@ -15012,7 +15023,7 @@ window.onerror = createOnErrorHandler(rid).bind(); } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function setPropertyAccess(object, property, descriptor) { var currentDescriptor = Object.getOwnPropertyDescriptor(object, property); @@ -15113,7 +15124,7 @@ } function noopFunc() {} function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } var updatedArgs = args ? [].concat(source).concat(args) : [source]; try { @@ -15160,7 +15171,7 @@ window.onerror = createOnErrorHandler(rid).bind(); } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function setPropertyAccess(object, property, descriptor) { var currentDescriptor = Object.getOwnPropertyDescriptor(object, property); @@ -15260,7 +15271,7 @@ } } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } var updatedArgs = args ? [].concat(source).concat(args) : [source]; try { @@ -15831,7 +15842,7 @@ return new RegExp(escaped); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getObjectEntries(object) { var keys = Object.keys(object); @@ -16020,7 +16031,7 @@ }).join(" "); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getObjectEntries(object) { var keys = Object.keys(object); @@ -16261,7 +16272,7 @@ } } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } var updatedArgs = args ? [].concat(source).concat(args) : [source]; try { @@ -17298,7 +17309,7 @@ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getRequestData(request) { var requestInitOptions = getRequestProps(); @@ -17401,7 +17412,7 @@ }; } function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } function hit(source) { if (source.verbose !== true) { @@ -18579,7 +18590,7 @@ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getObjectEntries(object) { var keys = Object.keys(object); @@ -19689,7 +19700,7 @@ return native(num); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getNativeRegexpTest() { return Object.getOwnPropertyDescriptor(RegExp.prototype, "test").value; @@ -20727,7 +20738,7 @@ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getRequestData(request) { var requestInitOptions = getRequestProps(); @@ -21053,7 +21064,7 @@ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } function isEmptyObject(obj) { - return Object.keys(obj).length === 0; + return Object.keys(obj).length === 0 && !obj.prototype; } function getObjectEntries(object) { var keys = Object.keys(object); diff --git a/src/helpers/compatibility-redirects.js b/src/helpers/compatibility-redirects.js index abce2dc02..6fc846200 100644 --- a/src/helpers/compatibility-redirects.js +++ b/src/helpers/compatibility-redirects.js @@ -71,6 +71,11 @@ const redirects = [ adg: 'googletagmanager-gtm', ubo: 'google-analytics_ga.js', }, + { + // https://github.com/AdguardTeam/Scriptlets/issues/260 + adg: 'googletagmanager-gtm', + ubo: 'googletagmanager_gtm.js', + }, { adg: 'googletagservices-gpt', ubo: 'googletagservices_gpt.js', diff --git a/src/helpers/converter.js b/src/helpers/converter.js index 9f5318a9b..6dafe9962 100644 --- a/src/helpers/converter.js +++ b/src/helpers/converter.js @@ -42,7 +42,11 @@ const ADG_XHR_TYPE = 'xmlhttprequest'; const ADG_SET_CONSTANT_NAME = 'set-constant'; const ADG_SET_CONSTANT_EMPTY_STRING = ''; +const ADG_SET_CONSTANT_EMPTY_ARRAY = 'emptyArr'; +const ADG_SET_CONSTANT_EMPTY_OBJECT = 'emptyObj'; const UBO_SET_CONSTANT_EMPTY_STRING = '\'\''; +const UBO_SET_CONSTANT_EMPTY_ARRAY = '[]'; +const UBO_SET_CONSTANT_EMPTY_OBJECT = '{}'; const ADG_PREVENT_FETCH_NAME = 'prevent-fetch'; const ADG_PREVENT_FETCH_EMPTY_STRING = ''; @@ -246,10 +250,17 @@ export const convertAdgScriptletToUbo = (rule) => { const { name: parsedName, args: parsedParams } = parseRule(rule); let preparedParams; - // https://github.com/AdguardTeam/FiltersCompiler/issues/102 if (parsedName === ADG_SET_CONSTANT_NAME + // https://github.com/AdguardTeam/FiltersCompiler/issues/102 && parsedParams[1] === ADG_SET_CONSTANT_EMPTY_STRING) { preparedParams = [parsedParams[0], UBO_SET_CONSTANT_EMPTY_STRING]; + } else if (parsedName === ADG_SET_CONSTANT_NAME + // https://github.com/uBlockOrigin/uBlock-issues/issues/2411 + && parsedParams[1] === ADG_SET_CONSTANT_EMPTY_ARRAY) { + preparedParams = [parsedParams[0], UBO_SET_CONSTANT_EMPTY_ARRAY]; + } else if (parsedName === ADG_SET_CONSTANT_NAME + && parsedParams[1] === ADG_SET_CONSTANT_EMPTY_OBJECT) { + preparedParams = [parsedParams[0], UBO_SET_CONSTANT_EMPTY_OBJECT]; } else if (parsedName === ADG_PREVENT_FETCH_NAME // https://github.com/AdguardTeam/Scriptlets/issues/109 && (parsedParams[0] === ADG_PREVENT_FETCH_WILDCARD diff --git a/src/helpers/object-utils.js b/src/helpers/object-utils.js index 847afe3a6..89a7a9b71 100644 --- a/src/helpers/object-utils.js +++ b/src/helpers/object-utils.js @@ -35,7 +35,7 @@ export const getObjectFromEntries = (entries) => { * @param {Object} obj * @returns {boolean} */ -export const isEmptyObject = (obj) => Object.keys(obj).length === 0; +export const isEmptyObject = (obj) => Object.keys(obj).length === 0 && !obj.prototype; /** * Checks whether the obj is an empty object diff --git a/src/helpers/random-id.js b/src/helpers/random-id.js index 3d5f89622..288d7339a 100644 --- a/src/helpers/random-id.js +++ b/src/helpers/random-id.js @@ -1,6 +1,6 @@ /** - * Generate random six symbols id + * Generate random seven symbols id */ export function randomId() { - return Math.random().toString(36).substr(2, 9); + return Math.random().toString(36).slice(2, 9); } diff --git a/src/scriptlets/index.js b/src/scriptlets/index.js index 69aba887f..c3d618e8d 100644 --- a/src/scriptlets/index.js +++ b/src/scriptlets/index.js @@ -29,16 +29,24 @@ import { getScriptletFunction } from '../../tmp/scriptlets-func'; * Returns scriptlet code by param * @param {Source} source * @returns {string|null} scriptlet code + * @throws on unknown scriptlet name */ function getScriptletCode(source) { if (!validator.isValidScriptletName(source.name)) { return null; } - const scriptletFunction = getScriptletFunction(source.name).toString(); + const scriptletFunction = getScriptletFunction(source.name); + // In case isValidScriptletName check will pass invalid scriptlet name, + // for example when there is a bad alias + if (typeof scriptletFunction !== 'function') { + throw new Error(`Error: cannot invoke scriptlet with name: '${source.name}'`); + } + const scriptletFunctionString = scriptletFunction.toString(); + const result = source.engine === 'corelibs' || source.engine === 'test' - ? wrapInNonameFunc(scriptletFunction) - : passSourceAndProps(source, scriptletFunction); + ? wrapInNonameFunc(scriptletFunctionString) + : passSourceAndProps(source, scriptletFunctionString); return result; } diff --git a/src/scriptlets/log-addEventListener.js b/src/scriptlets/log-addEventListener.js index 0d30a86f5..61bf49ecd 100644 --- a/src/scriptlets/log-addEventListener.js +++ b/src/scriptlets/log-addEventListener.js @@ -41,7 +41,13 @@ type: ${convertTypeToString(type)} listener: ${convertTypeToString(listener)}`; logMessage(source, message, true); - return nativeAddEventListener.apply(this, [type, listener, ...args]); + // Avoid illegal invocations due to lost context + // https://github.com/AdguardTeam/Scriptlets/issues/271 + let context = this; + if (this && this.constructor?.name === 'Window' && this !== window) { + context = window; + } + return nativeAddEventListener.apply(context, [type, listener, ...args]); } const descriptor = { diff --git a/src/scriptlets/prevent-addEventListener.js b/src/scriptlets/prevent-addEventListener.js index 78b6bb08d..b821bb229 100644 --- a/src/scriptlets/prevent-addEventListener.js +++ b/src/scriptlets/prevent-addEventListener.js @@ -63,7 +63,13 @@ export function preventAddEventListener(source, typeSearch, listenerSearch) { return undefined; } - return nativeAddEventListener.apply(this, [type, listener, ...args]); + // Avoid illegal invocations due to lost context + // https://github.com/AdguardTeam/Scriptlets/issues/271 + let context = this; + if (this && this.constructor?.name === 'Window' && this !== window) { + context = window; + } + return nativeAddEventListener.apply(context, [type, listener, ...args]); } const descriptor = { diff --git a/src/scriptlets/prevent-element-src-loading.js b/src/scriptlets/prevent-element-src-loading.js index ea5b1a6c6..c3c52bac8 100644 --- a/src/scriptlets/prevent-element-src-loading.js +++ b/src/scriptlets/prevent-element-src-loading.js @@ -61,7 +61,13 @@ export function preventElementSrcLoading(source, tagName, match) { const hasTrustedTypes = window.trustedTypes && typeof window.trustedTypes.createPolicy === 'function'; let policy; if (hasTrustedTypes) { - policy = window.trustedTypes.createPolicy('mock', { + // The name for the trusted-types policy should only be 'AGPolicy',because corelibs can + // allow our policy if the server has restricted the creation of a trusted-types policy with + // the directive 'Content-Security-Policy: trusted-types ;`. + // If such a header is presented in the server response, corelibs adds permission to create + // the 'AGPolicy' policy with the 'allow-duplicates' option to prevent errors. + // See AG-18204 for details. + policy = window.trustedTypes.createPolicy('AGPolicy', { createScriptURL: (arg) => arg, }); } diff --git a/src/scriptlets/prevent-xhr.js b/src/scriptlets/prevent-xhr.js index 4147da97e..39e115c17 100644 --- a/src/scriptlets/prevent-xhr.js +++ b/src/scriptlets/prevent-xhr.js @@ -96,7 +96,6 @@ export function preventXHR(source, propsToMatch, customResponseText) { return; } - let shouldPrevent = false; let response = ''; let responseText = ''; let responseUrl; @@ -111,15 +110,15 @@ export function preventXHR(source, propsToMatch, customResponseText) { // Log if no propsToMatch given logMessage(source, `xhr( ${objectToString(xhrData)} )`, true); hit(source); - } else { - shouldPrevent = matchRequestProps(source, propsToMatch, xhrData); + } else if (matchRequestProps(source, propsToMatch, xhrData)) { + thisArg.shouldBePrevented = true; } return Reflect.apply(target, thisArg, args); }; const sendWrapper = (target, thisArg, args) => { - if (!shouldPrevent) { + if (!thisArg.shouldBePrevented) { return Reflect.apply(target, thisArg, args); } diff --git a/src/scriptlets/trusted-click-element.js b/src/scriptlets/trusted-click-element.js index 871b5712a..927fddf5f 100644 --- a/src/scriptlets/trusted-click-element.js +++ b/src/scriptlets/trusted-click-element.js @@ -38,7 +38,7 @@ import { * * 3. Click multiple elements by selector with a delay * ``` - * example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"], button[name='check"], input[type="submit"][value="akkoord"]', '', '500') + * example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"], button[name="check"], input[type="submit"][value="akkoord"]', '', '500') * ``` * * 4. Match cookies by keys using regex and string diff --git a/src/scriptlets/trusted-replace-xhr-response.js b/src/scriptlets/trusted-replace-xhr-response.js index 5279cead9..9eaccd88a 100644 --- a/src/scriptlets/trusted-replace-xhr-response.js +++ b/src/scriptlets/trusted-replace-xhr-response.js @@ -90,9 +90,7 @@ export function trustedReplaceXhrResponse(source, pattern = '', replacement = '' const nativeOpen = window.XMLHttpRequest.prototype.open; const nativeSend = window.XMLHttpRequest.prototype.send; - let shouldReplace = false; let xhrData; - let requestHeaders = []; const openWrapper = (target, thisArg, args) => { // eslint-disable-next-line prefer-spread @@ -106,13 +104,16 @@ export function trustedReplaceXhrResponse(source, pattern = '', replacement = '' return Reflect.apply(target, thisArg, args); } - shouldReplace = matchRequestProps(source, propsToMatch, xhrData); + if (matchRequestProps(source, propsToMatch, xhrData)) { + thisArg.shouldBePrevented = true; + } // Trap setRequestHeader of target xhr object to mimic request headers later - if (shouldReplace) { + if (thisArg.shouldBePrevented) { + thisArg.collectedHeaders = []; const setRequestHeaderWrapper = (target, thisArg, args) => { // Collect headers - requestHeaders.push(args); + thisArg.collectedHeaders.push(args); return Reflect.apply(target, thisArg, args); }; @@ -129,7 +130,7 @@ export function trustedReplaceXhrResponse(source, pattern = '', replacement = '' }; const sendWrapper = (target, thisArg, args) => { - if (!shouldReplace) { + if (!thisArg.shouldBePrevented) { return Reflect.apply(target, thisArg, args); } @@ -197,13 +198,13 @@ export function trustedReplaceXhrResponse(source, pattern = '', replacement = '' // Mimic request headers before sending // setRequestHeader can only be called on open request objects - requestHeaders.forEach((header) => { + thisArg.collectedHeaders.forEach((header) => { const name = header[0]; const value = header[1]; forgedRequest.setRequestHeader(name, value); }); - requestHeaders = []; + thisArg.collectedHeaders = []; try { nativeSend.call(forgedRequest, args); diff --git a/tests/helpers/index.test.js b/tests/helpers/index.test.js index d5adb43a6..dc518e42a 100644 --- a/tests/helpers/index.test.js +++ b/tests/helpers/index.test.js @@ -3,3 +3,4 @@ import './match-stack.test'; import './noop.test'; import './number-utils.test'; import './string-utils.test'; +import './object-utils.test'; diff --git a/tests/helpers/object-utils.test.js b/tests/helpers/object-utils.test.js new file mode 100644 index 000000000..441ae062d --- /dev/null +++ b/tests/helpers/object-utils.test.js @@ -0,0 +1,26 @@ +import { isEmptyObject } from '../../src/helpers'; + +const { test, module } = QUnit; +const name = 'scriptlets-redirects helpers'; + +module(name); + +test('Test isEmptyObject works for different inputs', async (assert) => { + const emptyObj = {}; + const obj = { a: 1 }; + const emptyArr = []; + const arr = [1, 2, 3]; + function func() {} + + assert.ok(isEmptyObject(emptyObj), 'empty object returns true'); + assert.ok(isEmptyObject(emptyArr), 'empty array returns true'); + + assert.notOk(isEmptyObject(obj), 'non-empty object returns false'); + assert.notOk(isEmptyObject(arr), 'non-empty array returns false'); + + assert.notOk(isEmptyObject(EventTarget)); + assert.notOk(isEmptyObject(Array)); + assert.notOk(isEmptyObject(Object)); + assert.notOk(isEmptyObject(Function)); + assert.notOk(isEmptyObject(func)); +}); diff --git a/tests/lib-tests/index.test.js b/tests/lib-tests/index.test.js index 97aa3a78b..d36386554 100644 --- a/tests/lib-tests/index.test.js +++ b/tests/lib-tests/index.test.js @@ -246,6 +246,16 @@ test('Test SCRIPTLET converting - ADG -> UBO', (assert) => { inputAdg = 'example.com#%#//scriptlet(\'close-window\')'; expectedUbo = 'example.com##+js(window-close-if)'; assert.strictEqual(convertAdgScriptletToUbo(inputAdg), expectedUbo); + + // emptyArr as set-constant parameter + inputAdg = "example.org#%#//scriptlet('set-constant', 'adUnits', 'emptyArr')"; + expectedUbo = 'example.org##+js(set-constant, adUnits, [])'; + assert.strictEqual(convertAdgScriptletToUbo(inputAdg), expectedUbo); + + // emptyObj as set-constant parameter + inputAdg = "example.org#%#//scriptlet('set-constant', 'adUnits', 'emptyObj')"; + expectedUbo = 'example.org##+js(set-constant, adUnits, {})'; + assert.strictEqual(convertAdgScriptletToUbo(inputAdg), expectedUbo); }); test('Test $redirect validation', (assert) => { @@ -428,6 +438,10 @@ test('Test REDIRECT-RULE converting - UBO -> ADG', (assert) => { uboRule = '||googlesyndication.com^$script,redirect-rule=googlesyndication_adsbygoogle.js,domain=darmowa-tv.ws'; expectedAdgRule = '||googlesyndication.com^$script,redirect-rule=googlesyndication-adsbygoogle,domain=darmowa-tv.ws'; assert.strictEqual(convertRedirectToAdg(uboRule), expectedAdgRule); + + uboRule = '||googletagmanager.com/gtag/js$script,redirect-rule=googletagmanager_gtm.js'; + expectedAdgRule = '||googletagmanager.com/gtag/js$script,redirect-rule=googletagmanager-gtm'; + assert.strictEqual(convertRedirectToAdg(uboRule), expectedAdgRule); }); test('Test REDIRECT converting - ABP -> ADG', (assert) => { diff --git a/tests/scriptlets/prevent-xhr.test.js b/tests/scriptlets/prevent-xhr.test.js index 3672ad50e..91dc1585e 100644 --- a/tests/scriptlets/prevent-xhr.test.js +++ b/tests/scriptlets/prevent-xhr.test.js @@ -159,7 +159,7 @@ if (isSupported) { xhr.send(); }); - test('Args, method matched, randomize response text, rangeMin equal to rangeMax (length:100-100)', async (assert) => { + test('Args, method matched, randomize response text, rangeMin === rangeMax (length:100-100)', async (assert) => { const METHOD = 'GET'; const URL = `${FETCH_OBJECTS_PATH}/test01.json`; const MATCH_DATA = ['method:GET', 'length:100-100']; @@ -203,7 +203,7 @@ if (isSupported) { xhr.send(); }); - test('Empty arg, prevent all, do not randomize response text - limit range (rangeMin + rangeMax - length:8888888888888888-99999999999999999999999)', async (assert) => { + test('Empty arg, prevent all, dont randomize response - limit range (rangeMin+rangeMax-length)', async (assert) => { const METHOD = 'GET'; const URL = `${FETCH_OBJECTS_PATH}/test01.json`; const MATCH_DATA = ['', 'length:8888888888888888-99999999999999999999999']; @@ -224,7 +224,7 @@ if (isSupported) { xhr.send(); }); - test('Empty arg, prevent all, do not randomize response text - limit range (rangeMax - length:10000-600000)', async (assert) => { + test('Empty arg, prevent all, dont randomize response text - limit range (rangeMax - length)', async (assert) => { const METHOD = 'GET'; const URL = `${FETCH_OBJECTS_PATH}/test01.json`; const MATCH_DATA = ['', 'length:10000-600000']; @@ -286,7 +286,7 @@ if (isSupported) { xhr.send(); }); - test('Empty arg, prevent all, do not randomize response text - invalid argument (length:test-30000)', async (assert) => { + test('Empty arg, prevent all, dont randomize response - invalid argument (length:test-30000)', async (assert) => { const METHOD = 'GET'; const URL = `${FETCH_OBJECTS_PATH}/test01.json`; const MATCH_DATA = ['', 'length:test-30000']; @@ -346,7 +346,7 @@ if (isSupported) { xhr.send(); }); - test('Empty arg, prevent all, do not randomize response text - invalid argument (length:123-345-450)', async (assert) => { + test('Empty arg, prevent all, dont randomize response - invalid argument (length:123-345-450)', async (assert) => { const METHOD = 'GET'; const URL = `${FETCH_OBJECTS_PATH}/test01.json`; const MATCH_DATA = ['', 'length:123-345-450']; @@ -366,7 +366,7 @@ if (isSupported) { xhr.send(); }); - test('Empty arg, prevent all, do not randomize response text - invalid argument (length:123---450)', async (assert) => { + test('Empty arg, prevent all, dont randomize response - invalid argument (length:123---450)', async (assert) => { const METHOD = 'GET'; const URL = `${FETCH_OBJECTS_PATH}/test01.json`; const MATCH_DATA = ['', 'length:123---450']; @@ -386,7 +386,7 @@ if (isSupported) { xhr.send(); }); - test('Empty arg, prevent all, do not randomize response text - invalid argument (length::123-450)', async (assert) => { + test('Empty arg, prevent all, dont randomize response - invalid argument (length::123-450)', async (assert) => { const METHOD = 'GET'; const URL = `${FETCH_OBJECTS_PATH}/test01.json`; const MATCH_DATA = ['', 'length::123-450']; @@ -588,6 +588,44 @@ if (isSupported) { }; xhr.send(); }); + + // https://github.com/AdguardTeam/Scriptlets/issues/261 + test('Works correctly with different parallel XHR requests', async (assert) => { + const METHOD = 'GET'; + const URL_TO_BLOCK = `${FETCH_OBJECTS_PATH}/test01.json`; + const URL_TO_PASS = `${FETCH_OBJECTS_PATH}/test02.json`; + const MATCH_DATA = ['test01.json']; + + runScriptlet(name, MATCH_DATA); + + const done1 = assert.async(); + const done2 = assert.async(); + + const xhr1 = new XMLHttpRequest(); + const xhr2 = new XMLHttpRequest(); + + xhr1.open(METHOD, URL_TO_PASS); + xhr2.open(METHOD, URL_TO_BLOCK); + + xhr1.onload = () => { + assert.strictEqual(xhr1.readyState, 4, 'Response done'); + assert.ok(xhr1.response, 'Response data exists'); + assert.strictEqual(window.hit, undefined, 'hit should not fire'); + done1(); + }; + + xhr2.onload = () => { + assert.strictEqual(xhr2.readyState, 4, 'Response done'); + assert.strictEqual(typeof xhr2.responseText, 'string', 'Response text mocked'); + assert.strictEqual(window.hit, 'FIRED', 'hit function fired'); + clearGlobalProps('hit'); + done2(); + }; + + xhr1.send(); + // use timeout to avoid hit collisions + setTimeout(() => xhr2.send(), 1); + }); } else { test('unsupported', (assert) => { assert.ok(true, 'Browser does not support it'); diff --git a/tests/scriptlets/trusted-replace-xhr-response.test.js b/tests/scriptlets/trusted-replace-xhr-response.test.js index 47ebdb38e..92ff21717 100644 --- a/tests/scriptlets/trusted-replace-xhr-response.test.js +++ b/tests/scriptlets/trusted-replace-xhr-response.test.js @@ -194,6 +194,47 @@ if (isSupported) { done3(); }); }); + + test('Works correctly with different parallel XHR requests', async (assert) => { + const URL_TO_PASS = `${FETCH_OBJECTS_PATH}/test02.json`; + const INTACT_RESPONSE_PART = 'test'; + + const METHOD = 'GET'; + const URL_TO_BLOCK = `${FETCH_OBJECTS_PATH}/test01.json`; + const PATTERN = '*'; + const REPLACEMENT = ''; + const MATCH_DATA = [PATTERN, REPLACEMENT, 'test01']; + + runScriptlet(name, MATCH_DATA); + + const done1 = assert.async(); + const done2 = assert.async(); + + const xhr1 = new XMLHttpRequest(); + const xhr2 = new XMLHttpRequest(); + + xhr1.open(METHOD, URL_TO_PASS); + xhr2.open(METHOD, URL_TO_BLOCK); + + xhr1.onload = () => { + assert.strictEqual(xhr1.readyState, 4, 'Response done'); + assert.ok(xhr1.response.includes(INTACT_RESPONSE_PART), 'Response is intact'); + assert.strictEqual(window.hit, undefined, 'hit should not fire'); + done1(); + }; + + xhr2.onload = () => { + assert.strictEqual(xhr2.readyState, 4, 'Response done'); + assert.ok(xhr2.response === '', 'Response has been removed'); + + assert.strictEqual(window.hit, 'FIRED', 'hit function fired'); + done2(); + }; + + xhr1.send(); + // use timeout to avoid hit collisions + setTimeout(() => xhr2.send(), 1); + }); } else { test('unsupported', (assert) => { assert.ok(true, 'Browser does not support it'); diff --git a/wiki/about-trusted-scriptlets.md b/wiki/about-trusted-scriptlets.md index 57e270970..6747fc54a 100644 --- a/wiki/about-trusted-scriptlets.md +++ b/wiki/about-trusted-scriptlets.md @@ -35,7 +35,7 @@ example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', '', ' 3. Click multiple elements by selector with a delay ``` -example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"], button[name='check"], input[type="submit"][value="akkoord"]', '', '500') +example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"], button[name="check"], input[type="submit"][value="akkoord"]', '', '500') ``` 4. Match cookies by keys using regex and string