AdguardTeam / AdguardTeam/Scriptlets

Improve logging in scriptlets — save reference to console

未关闭
#546 0 条评论 1 个 reaction 已指派 1 人 已被 @maximtop 认领 在 GitHub 查看
enhancement Priority: P4
主要语言
JavaScript
星标
195
派生
33
PR 合并指标
30 天内没有已合并 PR

描述

Currently if website overrides `console.log` or other properties then logging does not work.

Steps to reproduce:
1. Add to user rules:
```adblock
example.org#%#//scriptlet('prevent-setTimeout')
example.org#%#//scriptlet('log-on-stack-trace', 'document.querySelectorAll')
```
2. Go to - https://example.org/
3. Run in console:
```js
const noopFunc = ()=>{};
console.log = console.table = noopFunc;
setTimeout(()=>{const ads = {};});
const adblock = ()=>{ document.querySelectorAll('p'); };
adblock();
```

Scriptlets should log information to console.
There is nothing in console because `console.log` and `console.table` have been overridden.

Screenshot

Image


It works fine if `console.log = console.table = noopFunc;` is commented out.

Screenshot

Image

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。