Scriptlets
Scriptlets copied to clipboard
'log-on-stack-trace' breaks a player on deltabit.co
AdGuard for Chrome 4.2.228
Steps to reproduce
- Add
deltabit.co#%#//scriptlet('log-on-stack-trace', 'document.createElement')to user rules - Open https://deltabit.co/52tiyuhsq52y with Italian VPN
Actual behavior
The player is broken
Details
Reported by @ghajini
Another steps to reproduce:
- Add this rule:
fiddle.jshell.net#%#//scriptlet('log-on-stack-trace', 'document.createElement')
- Go to -
https://jsfiddle.net/eacwL8gz/
Code:
(()=> {
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/')