Related issue - AdguardTeam/AdguardFilters#231983, though there is another problem that scriptlet is not injected into iframe.
Steps to reproduce:
- Add to user rules:
example.org#%#//scriptlet('adjust-setTimeout', '/./', '7000', '0.001')
- Navigate to - https://example.org/
- Run in console:
const logTest = () => console.log('Test');
Object.setPrototypeOf(logTest, {foo: 1});
setTimeout(logTest, 7000)
Delay in setTimeout is not adjusted because callback instanceof Function returns false in:
|
export const isValidCallback = (callback: unknown): boolean => { |
|
return callback instanceof Function |
I guess we can change it to typeof callback === 'function'.
And probably for such cases we need to use Function.prototype.toString.call(callback); instead of callback.toString().
The former returns () => console.log('Test'), but the latter [object Function] in this case.
Related issue - AdguardTeam/AdguardFilters#231983, though there is another problem that scriptlet is not injected into iframe.
Steps to reproduce:
Delay in
setTimeoutis not adjusted becausecallback instanceof Functionreturnsfalsein:Scriptlets/src/helpers/prevent-utils.ts
Lines 15 to 16 in 3ba7a33
I guess we can change it to
typeof callback === 'function'.And probably for such cases we need to use
Function.prototype.toString.call(callback);instead ofcallback.toString().The former returns
() => console.log('Test'), but the latter[object Function]in this case.