Skip to content

Commit

Permalink
Firefox support
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyTy committed Mar 17, 2020
1 parent 19e85c7 commit 3a1d85d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

![Pussy with firethrower](kitty.png?raw=true)


### Screenshots

![Profiles](profiles.png?raw=true)
Expand Down Expand Up @@ -69,4 +68,3 @@ yarn global add typescript
```

Call `build.bat` or do the same it does from unix terminal.

16 changes: 12 additions & 4 deletions contentScript/replacer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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', {
Expand All @@ -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
Expand Down

0 comments on commit 3a1d85d

Please sign in to comment.