forked from zzebrum/us
-
Notifications
You must be signed in to change notification settings - Fork 0
/
userscript.js
51 lines (47 loc) · 1.66 KB
/
userscript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// ==UserScript==
// @name DevTools Anti-Detector Katy
// @namespace http://tampermonkey.net/
// @version 0.4
// @description something
// @match *://*/*
// @grant unsafeWindow
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
let knownRoots = new WeakSet();
function wrapRegExp(root) {
if (knownRoots.has(root))
return;
let _proto = void 0;
try {
_proto = root.RegExp.prototype;
} catch(ignore) {
return;
}
// Prevent RegExpt + toString trick (technically possible with any other object, but I encountered only this one
let _RE_tS = Object.getOwnPropertyDescriptor(_proto, 'toString');
let _RE_tSV = _RE_tS.value || _RE_tS.get();
let fts = Function.prototype.toString;
Object.defineProperty(_proto, 'toString', {
enumerable: _RE_tS.enumerable,
configurable: _RE_tS.configurable,
get: () => _RE_tSV,
set: function(val) {
console.warn('Attempt to change toString for', this, 'with', fts.call(val));
//throw 'stop it!';
return true;
}
});
}
wrapRegExp(unsafeWindow);
let _contentWindow = Object.getOwnPropertyDescriptor(HTMLIFrameElement.prototype, 'contentWindow');
let _get_contentWindow = _contentWindow.get;
_contentWindow.get = function() {
let _cw = _get_contentWindow.apply(this, arguments);
if (_cw)
wrapRegExp(_cw);
return _cw;
};
Object.defineProperty(HTMLIFrameElement.prototype, 'contentWindow', _contentWindow);
})();