AdguardTeam / AdguardTeam/Scriptlets

Add "prevent-console-hijack(ing)" scriptlet?

Đang mở
#167 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Feature request Priority: P4
Ngôn ngữ chính
JavaScript
Star
195
Fork
33
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

#### Hello,
 
A lot of websites like [TF1.fr](https://github.com/AdguardTeam/AdguardFilters/pull/102134) hijack `window.console` — allowing them, if necessary, to send the results of `console.error`, etc. to their servers.

#### This forced me to create this userscript in Tampermonkey because of my many uses of `console.xxx` during my tests:

```javascript
// ==UserScript==
// @name Force keeping native window.console on different websites
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Force keeping native window.console on different websites (currently: various catch-up TV websites).
// @author Contribucious
// @match http*://*.6play.fr/*
// @match http*://*.rtlplay.be/*
// @match http*://*.tf1.fr/*
// @run-at document-start
// ==/UserScript==

(function() {
'use strict';

// Based on: https://humanwhocodes.com/blog/2014/04/22/creating-defensive-objects-with-es6-proxies/

// Function(s)
function createDefensiveObject(target, wanted) {
return new Proxy(target, {
get(target, prop) {
if (prop in wanted) {
return wanted[prop];
}
}
});
}

// Main
unsafeWindow.console = createDefensiveObject(window.console, unsafeWindow.console);
})();

```
###### [`// @grant none`](https://www.tampermonkey.net/documentation.php#_grant) must not be present (i.e. sandbox required here for this to work).
 

:arrow_right: What about adding an equivalent in **AdGuard**, to be added [here](https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#debug-scriptlets) afterwards, as:
- `example.org#%#//scriptlet('prevent-console-hijack')` or
- `example.org#%#//scriptlet('prevent-console-hijacking')`,

… to keep a name similar to `prevent-window-open` and others? 🙂

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.