Skip to content

Add support to inject UserScript through trusted-create-html #3950

@BlazeFTL

Description

@BlazeFTL

Prerequisites

  • I verified that this is not a filter list issue. Report any issues with filter lists or broken website functionality in the uAssets issue tracker.
  • This is NOT a YouTube, Facebook or Twitch report. These sites MUST be reported by clicking their respective links.
  • This is not a support issue or a question. For support, questions, or help, visit /r/uBlockOrigin.
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue.
  • The issue is not present after disabling uBO in the browser.
  • I checked the documentation to understand that the issue I am reporting is not normal behavior.

I tried to reproduce the issue when...

  • uBO is the only extension.
  • uBO uses default lists and settings.
  • using a new, unmodified browser profile.

Description

Being able to inject a custom Js code or UserScript give much more flexibility is handling many issues

Ex:

tech8s.net,game5s.com##+js(trusted-create-html, head, script, (function(){'use strict';const u=window.location.href,p=new URLSearchParams(window.location.search),l=p.get('link');if(l){window.stop();if(u.includes('tech8s.net')){window.location.replace(`https://game5s.com/safe2.php?link=${l}`);}else if(u.includes('game5s.com')){window.location.replace(`https://droplink.co/${l}`);}}})();)

A specific URL where the issue occurs.

droplink.co/32vaVK

Expected behavior

While this works

tech8s.net,game5s.com##+js(trusted-create-html, head, <img src='x' onerror="(function(){'use strict';const u=window.location.href\,p=new URLSearchParams(window.location.search)\,l=p.get('link');if(l){window.stop();if(u.includes('tech8s.net')){window.location.replace(`https://game5s.com/safe2.php?link=${l}`);}else if(u.includes('game5s.com')){window.location.replace(`https://droplink.co/${l}`);}}})();">)

But it also fails a noticable amount of times (probably bcz location.href is given Higher priority)
But adding makes it work 100% of the time
[this attaches to sites existing Script]

tech8s.net,game5s.com##+js(rpnt, script, window.location.href, (function(){const urlParams=new URLSearchParams(window.location.search)\;const linkID=urlParams.get('link')\;if(!linkID)return\;const host=window.location.hostname\;if(host.includes('tech8s.net')){window.location.replace(`https://game5s.com/safe2.php?link=${linkID}`)}else{window.location.replace(`https://droplink.co/${linkID}`)}})()) 

Adguard's version

cuttlinks.com,exe-links.com,cuttty.com,cuttyy.com,cutynow.com,exnion.com,cutyion.com,jixo.online,exe-urls.com,evernia.site,ijvam.com,mrgec.com,emxaw.com,cety.app,cutnet.net#%#//scriptlet('trusted-create-element', 'head', 'script', '', '(()=>{const o=/function\(_0x.*\){const _0x.*\[_0x|adblock/,t={apply:(o,t,e)=>{const n=e[0];"boolean"==typeof n&&!0===n&&(e[0]=!1),setTimeout((()=>Reflect.apply(o,t,e)),1e3)}},e={apply:(e,n,p)=>{const y=p[0];return"function"==typeof y&&o.test(y.toString())&&(p[0]=new Proxy(p[0],t)),Reflect.apply(e,n,p)}};window.Promise.prototype.then=new Proxy(window.Promise.prototype.then,e)})();')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions