AdguardTeam / Scriptlets

AdGuard scriptlets library
GNU General Public License v3.0
148 stars 29 forks source link

Fix 'log-on-stack-trace' — player is broken on deltabit.co #384

Closed Alex-302 closed 1 month ago

Alex-302 commented 10 months ago

AdGuard for Chrome 4.2.228

Steps to reproduce

  1. Add deltabit.co#%#//scriptlet('log-on-stack-trace', 'document.createElement') to user rules
  2. Open https://deltabit.co/52tiyuhsq52y with Italian VPN

Actual behavior

The player is broken

Details ![image](https://github.com/AdguardTeam/Scriptlets/assets/8361299/ecc3619e-f5a0-48a5-b0ad-5a36741c907b)

Reported by @ghajini

AdamWr commented 10 months ago

Another steps to reproduce:

  1. Add this rule:
    fiddle.jshell.net#%#//scriptlet('log-on-stack-trace', 'document.createElement')
  2. Go to - https://jsfiddle.net/eacwL8gz/
Code: ```js (()=> { const re = /(\w+)\s(\w+)/; const str = 'div a'; str.replace(re, '$2, $1'); document.createElement(RegExp.$1); console.log(`RegExp.$1: ${RegExp.$1}`); alert(`RegExp.$1: ${RegExp.$1}`); })(); ```

Alert RegExp.$1: div should be displayed, but there is an error:

Uncaught DOMException: Failed to execute 'createElement' on 'Document': The tag name provided ('') is not a valid name.

As far as I understand, the problem is that RegExp.$1 is changed by scriptlet and it causes error.


The same issue occurs with rule like this:

fiddle.jshell.net#%#//scriptlet('abort-on-stack-trace', 'document.createElement', 'blablabla.whatever_test')

but it works fine when regexp is used:

fiddle.jshell.net#%#//scriptlet('abort-on-stack-trace', 'document.createElement', '/blablabla\.whatever_test/')