mirror of
https://github.com/andrei0x309/Brave-Detection-Blocker-Chrome-Extension.git
synced 2024-11-22 08:03:49 +00:00
refactor: block script
This commit is contained in:
parent
6545e1ffe8
commit
fffba0ae00
@ -1,50 +1,26 @@
|
|||||||
let nav = function Navigator() {};
|
class Navigator {
|
||||||
let copyNavRef = window.navigator;
|
constructor(copyNavRef) {
|
||||||
nav = nav.bind(function () {
|
this.name = 'Navigator';
|
||||||
return window.navigator;
|
this.prototype = copyNavRef;
|
||||||
});
|
for (let prop in copyNavRef) {
|
||||||
newNav = new nav();
|
if (prop === 'brave') {
|
||||||
const navClones = {
|
continue;
|
||||||
userAgent: window.navigator.userAgent,
|
}
|
||||||
appVersion: window.navigator.appVersion,
|
Object.defineProperty(this, prop, {
|
||||||
platform: window.navigator.platform,
|
value: typeof copyNavRef[prop] === 'function' ? copyNavRef[prop].bind(copyNavRef) : copyNavRef[prop],
|
||||||
vendor: window.navigator.vendor,
|
writable: true,
|
||||||
language: window.navigator.language,
|
enumerable: false,
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
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', {
|
Object.defineProperty(window, 'navigator', {
|
||||||
value: newNav,
|
value: newNav,
|
||||||
writable: true,
|
writable: false,
|
||||||
enumerable: true,
|
enumerable: false,
|
||||||
configurable: true,
|
configurable: false,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user