-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
href-sanitizer
- performance issue
#466
Labels
bug
Something isn't working
Comments
If I'm not wrong, it's due to this part: Scriptlets/src/scriptlets/href-sanitizer.ts Lines 553 to 555 in 3ba245f
It looks like that Does it happen with the following rule? hentai-id.tv#%#!function(t,e){var n=t.uniqueId+t.name+"_"+(Array.isArray(e)?e.join("_"):"");if(!t.uniqueId||"done"!==Window.prototype.toString[n]){var o=e?[].concat(t).concat(e):[t];try{(function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"text";if(e){var o=/^[^\x21-\x7e\p{Letter}]+/u,c=/[^\x21-\x7e\p{Letter}]+$/u,i=function(e){var i;try{i=document.querySelectorAll(e)}catch(n){return void r(t,'Invalid selector "'.concat(e,'"'))}i.forEach((function(e){try{if("a"!==(l=e).nodeName.toLowerCase()||!l.hasAttribute("href"))return;var i=function(e,n){if("text"===n)return e.textContent?e.textContent.replace(o,"").replace(c,""):"";if(n.startsWith("?"))try{return new URL(e.href,document.location.href).searchParams.get(n.slice(1))||""}catch(o){return r(t,"Cannot retrieve the parameter '".concat(n.slice(1),"' from the URL '").concat(e.href)),""}return n.startsWith("[")&&n.endsWith("]")&&e.getAttribute(n.slice(1,-1))||""}(e,n),a=function(e){if(!e)return null;try{var n=new URL(e,document.location.href),o=n.href,c=n.protocol;return"http:"!==c&&"https:"!==c?(r(t,'Protocol not allowed: "'.concat(c,'", from URL: "').concat(o,'"')),null):o}catch(t){return null}}(i);if(!a)return void r(t,"Invalid URL: ".concat(i));var u=e.href;e.setAttribute("href",a),a!==u&&r(t,'Sanitized "'.concat(u,'" to "').concat(a,'".'))}catch(n){r(t,"Failed to sanitize ".concat(e,"."))}var l})),function(t){if(t.verbose){try{var e=console.trace.bind(console),n="".concat("[AdGuard]"," ");"corelibs"===t.engine?n+=t.ruleText:(t.domainName&&(n+="".concat(t.domainName)),t.args?n+="#%#//scriptlet('".concat(t.name,"', '").concat(t.args.join("', '"),"')"):n+="#%#//scriptlet('".concat(t.name,"')")),e&&e(n)}catch(t){}"function"==typeof window.__debug&&window.__debug(t)}}(t)};i(e),function(t){var e,n,o,r,c=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=new MutationObserver((e=function(){l(),t(),u()},o=!1,r=function t(){for(var r=arguments.length,c=new Array(r),i=0;i<r;i++)c[i]=arguments[i];o?n=c:(e(...c),o=!0,setTimeout((function(){o=!1,n&&(t(...n),n=null)}),20))},r)),u=function(){i.length>0?a.observe(document.documentElement,{childList:!0,subtree:!0,attributes:c,attributeFilter:i}):a.observe(document.documentElement,{childList:!0,subtree:!0,attributes:c})},l=function(){a.disconnect()};u()}((function(){return i(e)}),!0)}else r(t,"Selector is required.")}).apply(this,o),t.uniqueId&&Object.defineProperty(Window.prototype.toString,n,{value:"done",enumerable:!1,writable:!1,configurable:!1})}catch(t){console.log(t)}}function r(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],r=t.name,c=t.verbose;if(n||c){var i=console.log;o?i("".concat(r,": ").concat(e)):i("".concat(r,":"),e)}}}({name:"href-sanitizer",engine:"corelibs",version:"1.16.48",verbose:!1},['a[href*="://ouo.io/"]',"?s"]); It's almost the same as scriptlet but with removed mentioned part. |
@AdamWr Works immediately. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AdGuard 4.4.41
Scriptlets v1.12.1
Details
https://hentai-id.tv/ uses URL shortener for analytics
Following rule removes redirection
hentai-id.tv#%#//scriptlet('href-sanitizer', 'a[href*="://ouo.io/"]', '?s')
Example
changed to
Problem details
I need to wait until the page will be loaded completely.
It can be reproduce with throttling as 3G using the DevTools.
Details
Proposed solution
Probably mutation observer can be used to scan elements, or just scan every 0.5-1 second.
The text was updated successfully, but these errors were encountered: