diff --git a/CHANGELOG.md b/CHANGELOG.md index f3fa0d13d..5ee0cd960 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,11 +14,23 @@ - `prevent-xhr` and `trusted-replace-xhr-response` closure bug on multiple requests [#261](https://github.com/AdguardTeam/Scriptlets/issues/261) -## Unreleased 1.7.x +## v1.7.20 + +### Added + +- `isBlocking()` method for Redirects class +- `file` field for redirect type + +### Fixed + +- Redirects types. + +## v1.7.19 ### Fixed - `prevent-addEventListener` and `log-addEventListener` loosing context when encountering already bound `.addEventListener` +- `google-ima3` conversion ## v1.7.14 diff --git a/README.md b/README.md index 403f1c1e9..a475d7503 100644 --- a/README.md +++ b/README.md @@ -427,6 +427,11 @@ const redirects = new Redirects(rawYaml) */ const redirect = redirect.getRedirect('noopjs'); +/** + * Check if redirect is blocking, e.g. click2load.html + */ +const isBlocking = redirect.isBlocking('click2load.html'); + /** * Redirect - object with following props * { diff --git a/dist/build.txt b/dist/build.txt index 72708e251..6492cbe8f 100644 --- a/dist/build.txt +++ b/dist/build.txt @@ -1 +1 @@ -version=1.7.14 \ No newline at end of file +version=1.7.20 \ No newline at end of file diff --git a/dist/redirects.json b/dist/redirects.json index 5619c0402..cc277e504 100644 --- a/dist/redirects.json +++ b/dist/redirects.json @@ -226,7 +226,10 @@ }, { "title": "google-ima3", - "aliases": [], + "aliases": [ + "ubo-google-ima.js", + "google-ima.js" + ], "isBlocking": false, "contentType": "application/javascript;base64", "content": "IWZ1bmN0aW9uKHNvdXJjZSxhcmdzKXtmdW5jdGlvbiBub29wRnVuYygpe31mdW5jdGlvbiBsb2dNZXNzYWdlKHNvdXJjZSxtZXNzYWdlKXt2YXIgZm9yY2VkPWFyZ3VtZW50cy5sZW5ndGg+MiYmdm9pZCAwIT09YXJndW1lbnRzWzJdJiZhcmd1bWVudHNbMl07KGZvcmNlZHx8c291cmNlLnZlcmJvc2UpJiZjb25zb2xlLmxvZygiIi5jb25jYXQoc291cmNlLm5hbWUsIjogIikuY29uY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pfWNhdGNoKGUpe2NvbnNvbGUubG9nKGUpfX0oe25hbWU6Imdvb2dsZS1pbWEzIixhcmdzOltdfSxbXSk7" diff --git a/dist/redirects.yml b/dist/redirects.yml index 465f04b2c..bfbc24ef2 100644 --- a/dist/redirects.yml +++ b/dist/redirects.yml @@ -1,6 +1,6 @@ # # AdGuard Scriptlets (Redirects Source) -# Version 1.7.14 +# Version 1.7.20 # - title: 1x1-transparent.gif description: |- @@ -1428,7 +1428,9 @@ - title: google-ima3 comment: Mocks the IMA SDK of Google. - aliases: [] + aliases: + - ubo-google-ima.js + - google-ima.js contentType: application/javascript content: |- (function(source, args) { diff --git a/dist/scriptlets.corelibs.json b/dist/scriptlets.corelibs.json index 5ae3c7334..c3b96d017 100644 --- a/dist/scriptlets.corelibs.json +++ b/dist/scriptlets.corelibs.json @@ -1,5 +1,5 @@ { - "version": "1.7.14", + "version": "1.7.20", "scriptlets": [ { "names": [ @@ -132,7 +132,7 @@ "ubo-addEventListener-defuser", "ubo-aeld" ], - "scriptlet": "function preventAddEventListener(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 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 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()}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,typeSearch,listenerSearch){var typeSearchRegexp=toRegExp(typeSearch),listenerSearchRegexp=toRegExp(listenerSearch),nativeAddEventListener=window.EventTarget.prototype.addEventListener;function addEventListenerWrapper(type,listener){var shouldPrevent=!1;if(validateType(type)&&validateListener(listener)&&(shouldPrevent=typeSearchRegexp.test(type.toString())&&listenerSearchRegexp.test(listenerToString(listener))),!shouldPrevent){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))}hit(source)}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 preventAddEventListener(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 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 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()}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,typeSearch,listenerSearch){var typeSearchRegexp=toRegExp(typeSearch),listenerSearchRegexp=toRegExp(listenerSearch),nativeAddEventListener=window.EventTarget.prototype.addEventListener;function addEventListenerWrapper(type,listener){var _this$constructor,shouldPrevent=!1;if(validateType(type)&&validateListener(listener)&&(shouldPrevent=typeSearchRegexp.test(type.toString())&&listenerSearchRegexp.test(listenerToString(listener))),!shouldPrevent){var context=this;this&&\"Window\"===(null===(_this$constructor=this.constructor)||void 0===_this$constructor?void 0:_this$constructor.name)&&this!==window&&(context=window);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(context,[type,listener].concat(args))}hit(source)}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": [ @@ -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.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)}}" + "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){var _this$constructor;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);var context=this;this&&\"Window\"===(null===(_this$constructor=this.constructor)||void 0===_this$constructor?void 0:_this$constructor.name)&&this!==window&&(context=window);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(context,[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": [ @@ -444,7 +444,7 @@ "names": [ "prevent-element-src-loading" ], - "scriptlet": "function preventElementSrcLoading(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 safeGetDescriptor(obj,prop){var descriptor=Object.getOwnPropertyDescriptor(obj,prop);return descriptor&&descriptor.configurable?descriptor:null}function noopFunc(){}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,tagName,match){if(\"undefined\"!=typeof Proxy&&\"undefined\"!=typeof Reflect){var instance,policy,srcMockData={script:\"data:text/javascript;base64,KCk9Pnt9\",img:\"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\",iframe:\"data:text/html;base64, PGRpdj48L2Rpdj4=\"};if(\"script\"===tagName)instance=HTMLScriptElement;else if(\"img\"===tagName)instance=HTMLImageElement;else{if(\"iframe\"!==tagName)return;instance=HTMLIFrameElement}window.trustedTypes&&\"function\"==typeof window.trustedTypes.createPolicy&&(policy=window.trustedTypes.createPolicy(\"mock\",{createScriptURL:function(arg){return arg}}));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)}(match),setMatchedAttribute=function(elem){return elem.setAttribute(source.name,\"matched\")},setAttributeHandler={apply:function(target,thisArg,args){if(!args[0]||!args[1])return Reflect.apply(target,thisArg,args);var nodeName=thisArg.nodeName.toLowerCase(),attrName=args[0].toLowerCase(),attrValue=args[1];return\"src\"===attrName&&tagName.toLowerCase()===nodeName&&srcMockData[nodeName]&&searchRegexp.test(attrValue)?(hit(source),setMatchedAttribute(thisArg),Reflect.apply(target,thisArg,[attrName,srcMockData[nodeName]])):Reflect.apply(target,thisArg,args)}};instance.prototype.setAttribute=new Proxy(Element.prototype.setAttribute,setAttributeHandler);var origSrcDescriptor=safeGetDescriptor(instance.prototype,\"src\");if(origSrcDescriptor){Object.defineProperty(instance.prototype,\"src\",{enumerable:!0,configurable:!0,get:function(){return origSrcDescriptor.get.call(this)},set:function(urlValue){var nodeName=this.nodeName.toLowerCase();if(tagName.toLowerCase()!==nodeName||!srcMockData[nodeName]||!searchRegexp.test(urlValue))return origSrcDescriptor.set.call(this,urlValue),!0;if(policy&&urlValue instanceof TrustedScriptURL){var trustedSrc=policy.createScriptURL(urlValue);return origSrcDescriptor.set.call(this,trustedSrc),void hit(source)}setMatchedAttribute(this),origSrcDescriptor.set.call(this,srcMockData[nodeName]),hit(source)}});var origOnerrorDescriptor=safeGetDescriptor(HTMLElement.prototype,\"onerror\");if(origOnerrorDescriptor){Object.defineProperty(HTMLElement.prototype,\"onerror\",{enumerable:!0,configurable:!0,get:function(){return origOnerrorDescriptor.get.call(this)},set:function(cb){return\"matched\"===this.getAttribute(source.name)?(origOnerrorDescriptor.set.call(this,noopFunc),!0):(origOnerrorDescriptor.set.call(this,cb),!0)}});var addEventListenerHandler={apply:function(target,thisArg,args){if(!args[0]||!args[1])return Reflect.apply(target,thisArg,args);var eventName=args[0];return\"function\"==typeof thisArg.getAttribute&&\"matched\"===thisArg.getAttribute(source.name)&&\"error\"===eventName?Reflect.apply(target,thisArg,[eventName,noopFunc]):Reflect.apply(target,thisArg,args)}};EventTarget.prototype.addEventListener=new Proxy(EventTarget.prototype.addEventListener,addEventListenerHandler)}}}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" + "scriptlet": "function preventElementSrcLoading(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 safeGetDescriptor(obj,prop){var descriptor=Object.getOwnPropertyDescriptor(obj,prop);return descriptor&&descriptor.configurable?descriptor:null}function noopFunc(){}var updatedArgs=args?[].concat(source).concat(args):[source];try{(function(source,tagName,match){if(\"undefined\"!=typeof Proxy&&\"undefined\"!=typeof Reflect){var instance,policy,srcMockData={script:\"data:text/javascript;base64,KCk9Pnt9\",img:\"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\",iframe:\"data:text/html;base64, PGRpdj48L2Rpdj4=\"};if(\"script\"===tagName)instance=HTMLScriptElement;else if(\"img\"===tagName)instance=HTMLImageElement;else{if(\"iframe\"!==tagName)return;instance=HTMLIFrameElement}window.trustedTypes&&\"function\"==typeof window.trustedTypes.createPolicy&&(policy=window.trustedTypes.createPolicy(\"AGPolicy\",{createScriptURL:function(arg){return arg}}));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)}(match),setMatchedAttribute=function(elem){return elem.setAttribute(source.name,\"matched\")},setAttributeHandler={apply:function(target,thisArg,args){if(!args[0]||!args[1])return Reflect.apply(target,thisArg,args);var nodeName=thisArg.nodeName.toLowerCase(),attrName=args[0].toLowerCase(),attrValue=args[1];return\"src\"===attrName&&tagName.toLowerCase()===nodeName&&srcMockData[nodeName]&&searchRegexp.test(attrValue)?(hit(source),setMatchedAttribute(thisArg),Reflect.apply(target,thisArg,[attrName,srcMockData[nodeName]])):Reflect.apply(target,thisArg,args)}};instance.prototype.setAttribute=new Proxy(Element.prototype.setAttribute,setAttributeHandler);var origSrcDescriptor=safeGetDescriptor(instance.prototype,\"src\");if(origSrcDescriptor){Object.defineProperty(instance.prototype,\"src\",{enumerable:!0,configurable:!0,get:function(){return origSrcDescriptor.get.call(this)},set:function(urlValue){var nodeName=this.nodeName.toLowerCase();if(tagName.toLowerCase()!==nodeName||!srcMockData[nodeName]||!searchRegexp.test(urlValue))return origSrcDescriptor.set.call(this,urlValue),!0;if(policy&&urlValue instanceof TrustedScriptURL){var trustedSrc=policy.createScriptURL(urlValue);return origSrcDescriptor.set.call(this,trustedSrc),void hit(source)}setMatchedAttribute(this),origSrcDescriptor.set.call(this,srcMockData[nodeName]),hit(source)}});var origOnerrorDescriptor=safeGetDescriptor(HTMLElement.prototype,\"onerror\");if(origOnerrorDescriptor){Object.defineProperty(HTMLElement.prototype,\"onerror\",{enumerable:!0,configurable:!0,get:function(){return origOnerrorDescriptor.get.call(this)},set:function(cb){return\"matched\"===this.getAttribute(source.name)?(origOnerrorDescriptor.set.call(this,noopFunc),!0):(origOnerrorDescriptor.set.call(this,cb),!0)}});var addEventListenerHandler={apply:function(target,thisArg,args){if(!args[0]||!args[1])return Reflect.apply(target,thisArg,args);var eventName=args[0];return\"function\"==typeof thisArg.getAttribute&&\"matched\"===thisArg.getAttribute(source.name)&&\"error\"===eventName?Reflect.apply(target,thisArg,[eventName,noopFunc]):Reflect.apply(target,thisArg,args)}};EventTarget.prototype.addEventListener=new Proxy(EventTarget.prototype.addEventListener,addEventListenerHandler)}}}}).apply(this,updatedArgs)}catch(e){console.log(e)}}" }, { "names": [ diff --git a/dist/scriptlets.js b/dist/scriptlets.js index fcf4e4200..6cc3c1d57 100644 --- a/dist/scriptlets.js +++ b/dist/scriptlets.js @@ -1,7 +1,7 @@ /** * AdGuard Scriptlets - * Version 1.7.14 + * Version 1.7.20 */ (function () { @@ -1584,7 +1584,7 @@ } /** - * Generate random six symbols id + * Generate random seven symbols id */ function randomId() { return Math.random().toString(36).slice(2, 9); @@ -3439,6 +3439,7 @@ var listenerSearchRegexp = toRegExp(listenerSearch); var nativeAddEventListener = window.EventTarget.prototype.addEventListener; function addEventListenerWrapper(type, listener) { + var _this$constructor; var shouldPrevent = false; if (validateType(type) && validateListener(listener)) { shouldPrevent = typeSearchRegexp.test(type.toString()) && listenerSearchRegexp.test(listenerToString(listener)); @@ -3447,10 +3448,17 @@ hit(source); return undefined; } + + // Avoid illegal invocations due to lost context + // https://github.com/AdguardTeam/Scriptlets/issues/271 + var context = this; + if (this && ((_this$constructor = this.constructor) === null || _this$constructor === void 0 ? void 0 : _this$constructor.name) === 'Window' && this !== window) { + context = window; + } 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)); + return nativeAddEventListener.apply(context, [type, listener].concat(args)); } var descriptor = { configurable: true, @@ -3619,6 +3627,7 @@ function logAddEventListener$1(source) { var nativeAddEventListener = window.EventTarget.prototype.addEventListener; function addEventListenerWrapper(type, listener) { + var _this$constructor; if (validateType(type) && validateListener(listener)) { var _message = "addEventListener(\"".concat(type, "\", ").concat(listenerToString(listener), ")"); logMessage(source, _message, true); @@ -3628,10 +3637,17 @@ // logging while debugging var message = "Invalid event type or listener passed to addEventListener:\ntype: ".concat(convertTypeToString(type), "\nlistener: ").concat(convertTypeToString(listener)); logMessage(source, message, true); + + // Avoid illegal invocations due to lost context + // https://github.com/AdguardTeam/Scriptlets/issues/271 + var context = this; + if (this && ((_this$constructor = this.constructor) === null || _this$constructor === void 0 ? void 0 : _this$constructor.name) === 'Window' && this !== window) { + context = window; + } 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)); + return nativeAddEventListener.apply(context, [type, listener].concat(args)); } var descriptor = { configurable: true, @@ -6265,7 +6281,13 @@ var hasTrustedTypes = window.trustedTypes && typeof window.trustedTypes.createPolicy === 'function'; var 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: function createScriptURL(arg) { return arg; } @@ -7357,7 +7379,8 @@ adg: 'googletagservices-gpt', ubo: 'googletagservices_gpt.js' }, { - adg: 'google-ima3' + adg: 'google-ima3', + ubo: 'google-ima.js' }, { adg: 'gemius' }, { @@ -10044,7 +10067,11 @@ window.google.ima = ima; hit(source); } - GoogleIma3.names = ['google-ima3']; + GoogleIma3.names = ['google-ima3', + // prefixed name + 'ubo-google-ima.js', + // original ubo name + 'google-ima.js']; GoogleIma3.injections = [hit, noopFunc, logMessage]; /* eslint-disable func-names, no-underscore-dangle */ @@ -13491,6 +13518,7 @@ * @property {string} comment * @property {string} content * @property {string} contentType + * @property {string} file * @property {boolean} [isBlocking] * @property {string} [sha] */ @@ -13518,7 +13546,7 @@ /** * Returns redirect source object * @param {string} title - * @return {Redirect} + * @return {Redirect|undefined} Found redirect source object, or `undefined` if not found. */ createClass(Redirects, [{ key: "getRedirect", @@ -13540,6 +13568,21 @@ return aliases.indexOf(title) > -1; }); } + /** + * Checks if redirect is blocking like click2load.html + * @param {string} title Title of the redirect. + * @returns True if redirect is blocking otherwise returns `false` even if redirect name is + * unknown. + */ + }, { + key: "isBlocking", + value: function isBlocking(title) { + var redirect = this.redirects[title]; + if (redirect) { + return !!redirect.isBlocking; + } + return false; + } }]); return Redirects; }(); @@ -13604,6 +13647,8 @@ "ubo-googletagmanager_gtm.js": "google-analytics.js", "googletagmanager_gtm.js": "google-analytics.js", "google-ima3": "google-ima3.js", + "ubo-google-ima.js": "google-ima3.js", + "google-ima.js": "google-ima3.js", "googlesyndication-adsbygoogle": "googlesyndication-adsbygoogle.js", "ubo-googlesyndication_adsbygoogle.js": "googlesyndication-adsbygoogle.js", "googlesyndication_adsbygoogle.js": "googlesyndication-adsbygoogle.js", @@ -15934,6 +15979,7 @@ function logAddEventListener(source) { var nativeAddEventListener = window.EventTarget.prototype.addEventListener; function addEventListenerWrapper(type, listener) { + var _this$constructor; if (validateType(type) && validateListener(listener)) { var _message = 'addEventListener("'.concat(type, '", ').concat(listenerToString(listener), ")"); logMessage(source, _message, true); @@ -15941,10 +15987,14 @@ } var message = "Invalid event type or listener passed to addEventListener:\ntype: ".concat(convertTypeToString(type), "\nlistener: ").concat(convertTypeToString(listener)); logMessage(source, message, true); + var context = this; + if (this && ((_this$constructor = this.constructor) === null || _this$constructor === void 0 ? void 0 : _this$constructor.name) === "Window" && this !== window) { + context = window; + } 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)); + return nativeAddEventListener.apply(context, [type, listener].concat(args)); } var descriptor = { configurable: true, @@ -16498,6 +16548,7 @@ var listenerSearchRegexp = toRegExp(listenerSearch); var nativeAddEventListener = window.EventTarget.prototype.addEventListener; function addEventListenerWrapper(type, listener) { + var _this$constructor; var shouldPrevent = false; if (validateType(type) && validateListener(listener)) { shouldPrevent = typeSearchRegexp.test(type.toString()) && listenerSearchRegexp.test(listenerToString(listener)); @@ -16506,10 +16557,14 @@ hit(source); return undefined; } + var context = this; + if (this && ((_this$constructor = this.constructor) === null || _this$constructor === void 0 ? void 0 : _this$constructor.name) === "Window" && this !== window) { + context = window; + } 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)); + return nativeAddEventListener.apply(context, [type, listener].concat(args)); } var descriptor = { configurable: true, @@ -16807,7 +16862,7 @@ var hasTrustedTypes = window.trustedTypes && typeof window.trustedTypes.createPolicy === "function"; var policy; if (hasTrustedTypes) { - policy = window.trustedTypes.createPolicy("mock", { + policy = window.trustedTypes.createPolicy("AGPolicy", { createScriptURL: function createScriptURL(arg) { return arg; } diff --git a/dist/umd/scriptlets.d.ts b/dist/umd/scriptlets.d.ts index 148196c69..c1be2a8e8 100644 --- a/dist/umd/scriptlets.d.ts +++ b/dist/umd/scriptlets.d.ts @@ -64,6 +64,11 @@ declare module '@adguard/scriptlets' { */ contentType: string; + /** + * Filename of the redirect. + */ + file: string; + /** * If it's new type of redirects, i.e. click2load */ @@ -81,6 +86,7 @@ declare module '@adguard/scriptlets' { class Redirects { constructor(rawYaml: string); getRedirect(title: string): Redirect; + isBlocking(title: string): boolean; } /** @@ -117,7 +123,7 @@ declare module '@adguard/scriptlets' { /** * Object with redirects titles in the keys and RedirectSources */ - Redirects: Redirects; + Redirects: typeof Redirects; /** * Returns filename with extension for requested alias diff --git a/dist/umd/scriptlets.umd.js b/dist/umd/scriptlets.umd.js index 5aa51a875..6fa8e8632 100644 --- a/dist/umd/scriptlets.umd.js +++ b/dist/umd/scriptlets.umd.js @@ -1,7 +1,7 @@ /** * AdGuard Scriptlets - * Version 1.7.14 + * Version 1.7.20 */ (function (factory) { @@ -1586,7 +1586,7 @@ } /** - * Generate random six symbols id + * Generate random seven symbols id */ function randomId() { return Math.random().toString(36).slice(2, 9); @@ -3441,6 +3441,7 @@ var listenerSearchRegexp = toRegExp(listenerSearch); var nativeAddEventListener = window.EventTarget.prototype.addEventListener; function addEventListenerWrapper(type, listener) { + var _this$constructor; var shouldPrevent = false; if (validateType(type) && validateListener(listener)) { shouldPrevent = typeSearchRegexp.test(type.toString()) && listenerSearchRegexp.test(listenerToString(listener)); @@ -3449,10 +3450,17 @@ hit(source); return undefined; } + + // Avoid illegal invocations due to lost context + // https://github.com/AdguardTeam/Scriptlets/issues/271 + var context = this; + if (this && ((_this$constructor = this.constructor) === null || _this$constructor === void 0 ? void 0 : _this$constructor.name) === 'Window' && this !== window) { + context = window; + } 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)); + return nativeAddEventListener.apply(context, [type, listener].concat(args)); } var descriptor = { configurable: true, @@ -3621,6 +3629,7 @@ function logAddEventListener$1(source) { var nativeAddEventListener = window.EventTarget.prototype.addEventListener; function addEventListenerWrapper(type, listener) { + var _this$constructor; if (validateType(type) && validateListener(listener)) { var _message = "addEventListener(\"".concat(type, "\", ").concat(listenerToString(listener), ")"); logMessage(source, _message, true); @@ -3630,10 +3639,17 @@ // logging while debugging var message = "Invalid event type or listener passed to addEventListener:\ntype: ".concat(convertTypeToString(type), "\nlistener: ").concat(convertTypeToString(listener)); logMessage(source, message, true); + + // Avoid illegal invocations due to lost context + // https://github.com/AdguardTeam/Scriptlets/issues/271 + var context = this; + if (this && ((_this$constructor = this.constructor) === null || _this$constructor === void 0 ? void 0 : _this$constructor.name) === 'Window' && this !== window) { + context = window; + } 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)); + return nativeAddEventListener.apply(context, [type, listener].concat(args)); } var descriptor = { configurable: true, @@ -6267,7 +6283,13 @@ var hasTrustedTypes = window.trustedTypes && typeof window.trustedTypes.createPolicy === 'function'; var 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: function createScriptURL(arg) { return arg; } @@ -7359,7 +7381,8 @@ adg: 'googletagservices-gpt', ubo: 'googletagservices_gpt.js' }, { - adg: 'google-ima3' + adg: 'google-ima3', + ubo: 'google-ima.js' }, { adg: 'gemius' }, { @@ -10046,7 +10069,11 @@ window.google.ima = ima; hit(source); } - GoogleIma3.names = ['google-ima3']; + GoogleIma3.names = ['google-ima3', + // prefixed name + 'ubo-google-ima.js', + // original ubo name + 'google-ima.js']; GoogleIma3.injections = [hit, noopFunc, logMessage]; /* eslint-disable func-names, no-underscore-dangle */ @@ -13493,6 +13520,7 @@ * @property {string} comment * @property {string} content * @property {string} contentType + * @property {string} file * @property {boolean} [isBlocking] * @property {string} [sha] */ @@ -13520,7 +13548,7 @@ /** * Returns redirect source object * @param {string} title - * @return {Redirect} + * @return {Redirect|undefined} Found redirect source object, or `undefined` if not found. */ createClass(Redirects, [{ key: "getRedirect", @@ -13542,6 +13570,21 @@ return aliases.indexOf(title) > -1; }); } + /** + * Checks if redirect is blocking like click2load.html + * @param {string} title Title of the redirect. + * @returns True if redirect is blocking otherwise returns `false` even if redirect name is + * unknown. + */ + }, { + key: "isBlocking", + value: function isBlocking(title) { + var redirect = this.redirects[title]; + if (redirect) { + return !!redirect.isBlocking; + } + return false; + } }]); return Redirects; }(); @@ -13606,6 +13649,8 @@ "ubo-googletagmanager_gtm.js": "google-analytics.js", "googletagmanager_gtm.js": "google-analytics.js", "google-ima3": "google-ima3.js", + "ubo-google-ima.js": "google-ima3.js", + "google-ima.js": "google-ima3.js", "googlesyndication-adsbygoogle": "googlesyndication-adsbygoogle.js", "ubo-googlesyndication_adsbygoogle.js": "googlesyndication-adsbygoogle.js", "googlesyndication_adsbygoogle.js": "googlesyndication-adsbygoogle.js", @@ -15936,6 +15981,7 @@ function logAddEventListener(source) { var nativeAddEventListener = window.EventTarget.prototype.addEventListener; function addEventListenerWrapper(type, listener) { + var _this$constructor; if (validateType(type) && validateListener(listener)) { var _message = 'addEventListener("'.concat(type, '", ').concat(listenerToString(listener), ")"); logMessage(source, _message, true); @@ -15943,10 +15989,14 @@ } var message = "Invalid event type or listener passed to addEventListener:\ntype: ".concat(convertTypeToString(type), "\nlistener: ").concat(convertTypeToString(listener)); logMessage(source, message, true); + var context = this; + if (this && ((_this$constructor = this.constructor) === null || _this$constructor === void 0 ? void 0 : _this$constructor.name) === "Window" && this !== window) { + context = window; + } 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)); + return nativeAddEventListener.apply(context, [type, listener].concat(args)); } var descriptor = { configurable: true, @@ -16500,6 +16550,7 @@ var listenerSearchRegexp = toRegExp(listenerSearch); var nativeAddEventListener = window.EventTarget.prototype.addEventListener; function addEventListenerWrapper(type, listener) { + var _this$constructor; var shouldPrevent = false; if (validateType(type) && validateListener(listener)) { shouldPrevent = typeSearchRegexp.test(type.toString()) && listenerSearchRegexp.test(listenerToString(listener)); @@ -16508,10 +16559,14 @@ hit(source); return undefined; } + var context = this; + if (this && ((_this$constructor = this.constructor) === null || _this$constructor === void 0 ? void 0 : _this$constructor.name) === "Window" && this !== window) { + context = window; + } 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)); + return nativeAddEventListener.apply(context, [type, listener].concat(args)); } var descriptor = { configurable: true, @@ -16809,7 +16864,7 @@ var hasTrustedTypes = window.trustedTypes && typeof window.trustedTypes.createPolicy === "function"; var policy; if (hasTrustedTypes) { - policy = window.trustedTypes.createPolicy("mock", { + policy = window.trustedTypes.createPolicy("AGPolicy", { createScriptURL: function createScriptURL(arg) { return arg; } diff --git a/scripts/compatibility-table.json b/scripts/compatibility-table.json index 3082fabd8..0172bf512 100644 --- a/scripts/compatibility-table.json +++ b/scripts/compatibility-table.json @@ -295,6 +295,10 @@ "adg": "google-analytics-ga", "ubo": "google-analytics_ga.js" }, + { + "adg": "google-ima3", + "ubo": "google-ima.js" + }, { "adg": "googlesyndication-adsbygoogle", "ubo": "googlesyndication_adsbygoogle.js" @@ -444,9 +448,6 @@ { "ubo": "mxpnl_mixpanel.js" }, - { - "ubo": "google-ima.js" - }, { "ubo": "noop-0.5s.mp3" } diff --git a/src/helpers/compatibility-redirects.js b/src/helpers/compatibility-redirects.js index 6fc846200..a02088194 100644 --- a/src/helpers/compatibility-redirects.js +++ b/src/helpers/compatibility-redirects.js @@ -82,6 +82,7 @@ const redirects = [ }, { adg: 'google-ima3', + ubo: 'google-ima.js', }, { adg: 'gemius', diff --git a/src/redirects/google-ima3.js b/src/redirects/google-ima3.js index fed1727d3..807bbb799 100644 --- a/src/redirects/google-ima3.js +++ b/src/redirects/google-ima3.js @@ -477,7 +477,13 @@ export function GoogleIma3(source) { hit(source); } -GoogleIma3.names = ['google-ima3']; +GoogleIma3.names = [ + 'google-ima3', + // prefixed name + 'ubo-google-ima.js', + // original ubo name + 'google-ima.js', +]; GoogleIma3.injections = [ hit, diff --git a/src/redirects/redirects.js b/src/redirects/redirects.js index b89d6371b..8e2fa1828 100644 --- a/src/redirects/redirects.js +++ b/src/redirects/redirects.js @@ -47,7 +47,7 @@ class Redirects { * Returns redirect source object * * @param {string} title - * @returns {Redirect} + * @returns {Redirect|undefined} Found redirect source object, or `undefined` if not found. */ getRedirect(title) { if (Object.prototype.hasOwnProperty.call(this.redirects, title)) { @@ -65,6 +65,21 @@ class Redirects { return aliases.indexOf(title) > -1; }); } + + /** + * Checks if redirect is blocking like click2load.html + * + * @param {string} title Title of the redirect. + * @returns {boolean} True if redirect is blocking otherwise returns `false` even if redirect name is + * unknown. + */ + isBlocking(title) { + const redirect = this.redirects[title]; + if (redirect) { + return !!redirect.isBlocking; + } + return false; + } } export default Redirects; diff --git a/tests/lib-tests/index.test.js b/tests/lib-tests/index.test.js index d36386554..6866b77b9 100644 --- a/tests/lib-tests/index.test.js +++ b/tests/lib-tests/index.test.js @@ -418,6 +418,10 @@ test('Test REDIRECT converting - UBO -> ADG', (assert) => { uboRule = '||g9g.eu^*fa.js$script,redirect=fuckadblock.js-3.2.0'; expectedAdgRule = '||g9g.eu^*fa.js$script,redirect=prevent-fab-3.2.0'; assert.strictEqual(convertRedirectToAdg(uboRule), expectedAdgRule); + + uboRule = '||imasdk.googleapis.com/js/sdkloader/ima3.js$script,important,redirect=google-ima.js,domain=example.org'; + expectedAdgRule = '||imasdk.googleapis.com/js/sdkloader/ima3.js$script,important,redirect=google-ima3,domain=example.org'; + assert.strictEqual(convertRedirectToAdg(uboRule), expectedAdgRule); }); test('Test REDIRECT-RULE converting - UBO -> ADG', (assert) => { @@ -559,6 +563,10 @@ test('Test REDIRECT converting - ADG -> UBO', (assert) => { new RegExp('Unable to convert for uBO'), // specific error matcher 'no TYPES to specify, ABSENT_SOURCE_TYPE_REPLACEMENT should be updated', ); + + adgRule = '||imasdk.googleapis.com/js/sdkloader/ima3.js$script,important,redirect=google-ima3,domain=example.org'; + expectedUboRule = '||imasdk.googleapis.com/js/sdkloader/ima3.js$script,important,redirect=google-ima.js,domain=example.org'; + assert.strictEqual(convertAdgRedirectToUbo(adgRule), expectedUboRule); }); test('Test REDIRECT-RULE converting - ADG -> UBO', (assert) => { diff --git a/tests/redirects/google-ima3.test.js b/tests/redirects/google-ima3.test.js index 12971cb2e..23f7a8a34 100644 --- a/tests/redirects/google-ima3.test.js +++ b/tests/redirects/google-ima3.test.js @@ -18,6 +18,24 @@ const afterEach = () => { module(name, { beforeEach, afterEach }); +test('Checking if alias name works', (assert) => { + const adgParams = { + name, + engine: 'test', + verbose: true, + }; + const uboParams = { + name: 'ubo-google-ima.js', + engine: 'test', + verbose: true, + }; + + const codeByAdgParams = window.scriptlets.redirects.getCode(adgParams); + const codeByUboParams = window.scriptlets.redirects.getCode(uboParams); + + assert.strictEqual(codeByAdgParams, codeByUboParams, 'ubo name - ok'); +}); + test('Ima mocked', (assert) => { assert.expect(28); diff --git a/types/scriptlets.d.ts b/types/scriptlets.d.ts index 148196c69..c1be2a8e8 100644 --- a/types/scriptlets.d.ts +++ b/types/scriptlets.d.ts @@ -64,6 +64,11 @@ declare module '@adguard/scriptlets' { */ contentType: string; + /** + * Filename of the redirect. + */ + file: string; + /** * If it's new type of redirects, i.e. click2load */ @@ -81,6 +86,7 @@ declare module '@adguard/scriptlets' { class Redirects { constructor(rawYaml: string); getRedirect(title: string): Redirect; + isBlocking(title: string): boolean; } /** @@ -117,7 +123,7 @@ declare module '@adguard/scriptlets' { /** * Object with redirects titles in the keys and RedirectSources */ - Redirects: Redirects; + Redirects: typeof Redirects; /** * Returns filename with extension for requested alias diff --git a/wiki/compatibility-table.md b/wiki/compatibility-table.md index 18b155ffa..bbdc5dfa1 100644 --- a/wiki/compatibility-table.md +++ b/wiki/compatibility-table.md @@ -91,6 +91,7 @@ | [fingerprint3js](../wiki/about-redirects.md#fingerprint3js) | fingerprint3.js | | | [google-analytics](../wiki/about-redirects.md#google-analytics) | google-analytics_analytics.js | | | [google-analytics-ga](../wiki/about-redirects.md#google-analytics-ga) | google-analytics_ga.js | | +| [google-ima3](../wiki/about-redirects.md#google-ima3) | google-ima.js | | | [googlesyndication-adsbygoogle](../wiki/about-redirects.md#googlesyndication-adsbygoogle) | googlesyndication_adsbygoogle.js | | | [googletagservices-gpt](../wiki/about-redirects.md#googletagservices-gpt) | googletagservices_gpt.js | | | [gemius](../wiki/about-redirects.md#gemius) | | | @@ -133,5 +134,4 @@ | | window.open-defuser.js | | | | noeval.js | | | | mxpnl_mixpanel.js | | -| | google-ima.js | | | | noop-0.5s.mp3 | |