fix: add missing methods

This commit is contained in:
Andrei O 2022-03-30 10:14:16 +03:00
parent 836beb7c14
commit d592c6a7cf
No known key found for this signature in database
GPG Key ID: B961E5B68389457E
1 changed files with 11 additions and 4 deletions

View File

@ -4,7 +4,7 @@ nav = nav.bind(function () {
return window.navigator; return window.navigator;
}); });
newNav = new nav(); newNav = new nav();
const primitivesNav = { const navClones = {
userAgent: window.navigator.userAgent, userAgent: window.navigator.userAgent,
appVersion: window.navigator.appVersion, appVersion: window.navigator.appVersion,
platform: window.navigator.platform, platform: window.navigator.platform,
@ -18,6 +18,13 @@ const primitivesNav = {
onLine: window.navigator.onLine, onLine: window.navigator.onLine,
sendBeacon: window.navigator.sendBeacon.bind(window.navigator), sendBeacon: window.navigator.sendBeacon.bind(window.navigator),
getBattery: window.navigator.getBattery.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),
cleanAppBadge: window.navigator.cleanAppBadge.bind(window.navigator),
registerProtocolHandler: window.navigator.registerProtocolHandler.bind(window.navigator),
requestMediaKeySystemAccess: window.navigator.requestMediaKeySystemAccess.bind(window.navigator),
requestMIDIAccess: window.navigator.requestMIDIAccess.bind(window.navigator),
}; };
for (let prop in window.navigator) { for (let prop in window.navigator) {
@ -26,10 +33,10 @@ for (let prop in window.navigator) {
} }
newNav[prop] = copyNavRef[prop]; newNav[prop] = copyNavRef[prop];
} }
for (let prop in primitivesNav) { for (let prop in navClones) {
primitivesNav.hasOwnProperty(prop) && navClones.hasOwnProperty(prop) &&
Object.defineProperty(newNav, prop, { Object.defineProperty(newNav, prop, {
value: primitivesNav[prop], value: navClones[prop],
writable: true, writable: true,
}); });
} }