refactor: block script

This commit is contained in:
Andrei O 2022-04-05 18:57:34 +03:00
parent 6545e1ffe8
commit fffba0ae00
No known key found for this signature in database
GPG Key ID: B961E5B68389457E
1 changed files with 21 additions and 45 deletions

View File

@ -1,50 +1,26 @@
let nav = function Navigator() {};
let copyNavRef = window.navigator;
nav = nav.bind(function () {
return window.navigator;
});
newNav = new nav();
const navClones = {
userAgent: window.navigator.userAgent,
appVersion: window.navigator.appVersion,
platform: window.navigator.platform,
vendor: window.navigator.vendor,
language: window.navigator.language,
oscpu: window.navigator.oscpu,
cookieEnabled: true,
appCodeName: window.navigator.appCodeName,
appName: window.navigator.appName,
product: window.navigator.product,
geolocation: window.navigator.geolocation,
onLine: window.navigator.onLine,
sendBeacon: window.navigator.sendBeacon.bind(window.navigator),
getBattery: window.navigator.getBattery.bind(window.navigator),
vibrate: window.navigator.vibrate.bind(window.navigator),
share: window.navigator.share.bind(window.navigator),
canShare: window.navigator.canShare.bind(window.navigator),
registerProtocolHandler: window.navigator.registerProtocolHandler.bind(window.navigator),
requestMediaKeySystemAccess: window.navigator.requestMediaKeySystemAccess.bind(window.navigator),
requestMIDIAccess: window.navigator.requestMIDIAccess.bind(window.navigator),
bluetooth: window.navigator.bluetooth.bind(window.navigator),
onLine: window.navigator.onLine,
};
const skipPropList = [...Object.keys(navClones), 'brave'];
for (let prop in window.navigator) {
if (skipPropList.includes(prop)) {
continue;
class Navigator {
constructor(copyNavRef) {
this.name = 'Navigator';
this.prototype = copyNavRef;
for (let prop in copyNavRef) {
if (prop === 'brave') {
continue;
}
Object.defineProperty(this, prop, {
value: typeof copyNavRef[prop] === 'function' ? copyNavRef[prop].bind(copyNavRef) : copyNavRef[prop],
writable: true,
enumerable: false,
});
}
}
newNav[prop] = copyNavRef[prop];
}
for (let prop in navClones) {
navClones.hasOwnProperty(prop) &&
Object.defineProperty(newNav, prop, {
value: navClones[prop],
writable: true,
});
}
Navigator = Navigator.bind(window.navigator);
newNav = new Navigator(window.navigator);
delete window.navigator.__proto__.brave;
newNav.__proto__.__proto__ = window.navigator.__proto__;
Object.defineProperty(window, 'navigator', {
value: newNav,
writable: true,
enumerable: true,
configurable: true,
writable: false,
enumerable: false,
configurable: false,
});