From 3a1d85d60ea3ca68be9d2b83f5154f782cab11dd Mon Sep 17 00:00:00 2001 From: Miraculous Ladybugreport <3642643+PeyTy@users.noreply.github.com> Date: Tue, 17 Mar 2020 14:55:44 -0700 Subject: [PATCH] Firefox support --- README.md | 2 -- contentScript/replacer.ts | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c9d3805..15bb375 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ ![Pussy with firethrower](kitty.png?raw=true) - ### Screenshots ![Profiles](profiles.png?raw=true) @@ -69,4 +68,3 @@ yarn global add typescript ``` Call `build.bat` or do the same it does from unix terminal. - diff --git a/contentScript/replacer.ts b/contentScript/replacer.ts index 72a7393..974b298 100644 --- a/contentScript/replacer.ts +++ b/contentScript/replacer.ts @@ -156,10 +156,10 @@ namespace replacer { } // Pretend like this is not a laptop - setAlways(BatteryManager.prototype, "charging", true) - setAlways(BatteryManager.prototype, "chargingTime", 0) - setAlways(BatteryManager.prototype, "dischargingTime", Infinity) - setAlways(BatteryManager.prototype, "level", 1) + if ((window as any).BatteryManager != null) setAlways(BatteryManager.prototype, "charging", true) + if ((window as any).BatteryManager != null) setAlways(BatteryManager.prototype, "chargingTime", 0) + if ((window as any).BatteryManager != null) setAlways(BatteryManager.prototype, "dischargingTime", Infinity) + if ((window as any).BatteryManager != null) setAlways(BatteryManager.prototype, "level", 1) // Geolocation @@ -434,9 +434,11 @@ namespace replacer { let userAgent = window.navigator.userAgent.toString() let appVersion = (window.navigator.appVersion || '').toString() + let oscpu: string | undefined = window.navigator.oscpu const newSourceValue = profile.agent || "Windows NT 6.1;" userAgent = userAgent.replace(/Windows NT [0123456789\.]+;/, newSourceValue); appVersion = appVersion.replace(/Windows NT [0123456789\.]+;/, newSourceValue); + if (oscpu) oscpu = oscpu.replace(/Windows NT [0123456789\.]+;/, newSourceValue); // "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36" Object.defineProperty(window.navigator, 'userAgent', { @@ -451,6 +453,12 @@ namespace replacer { } }); + if (oscpu) Object.defineProperty(window.navigator, 'oscpu', { + get: function() { + return oscpu + } + }); + // WebRTC //window.RTCSessionDescription1 = window.RTCSessionDescription1 || RTCPeerConnection.prototype.onicecandidate