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 摘要。