Scriptlets
Scriptlets copied to clipboard
Fix 'set-constant' and 'trusted-set-constant' — stack matching does not work correctly
It seems that currently stack parameter doesn't work correctly, it's checked at the beginning of the scriptlet:
https://github.com/AdguardTeam/Scriptlets/blob/3ba245f96237915bbff6fe80c7400b03c0f5014d/src/scriptlets/set-constant.js#L163-L166
not when value is set/get.
Similar to - https://github.com/AdguardTeam/Scriptlets/issues/348
Steps to reproduce:
- Add this rule:
example.org#%#//scriptlet('set-constant', 'alert', 'trueFunc', 'test')
- Go to - https://example.org/
- Run in console:
const test = (arg = 'test') => {
console.log(new Error().stack);
alert(arg);
};
test();
alert is displayed.