mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
Add platform-based user-agent
This commit is contained in:
19
index.js
19
index.js
@ -207,8 +207,23 @@ app.once("browser-window-created", (event, win) => {
|
||||
// Force user-agent "Firefox Windows" for Google OAuth to work
|
||||
// From https://github.com/firebase/firebase-js-sdk/issues/2478#issuecomment-571356751
|
||||
// Only set on accounts.google.com, otherwise querySelectors in preload scripts fail (?)
|
||||
const userAgent =
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:70.0) Gecko/20100101 Firefox/70.0";
|
||||
// Uses custom user agent to Google alert with a correct device type (https://github.com/th-ch/youtube-music/issues/327)
|
||||
// User agents are from https://developers.whatismybrowser.com/useragents/explore/
|
||||
const userAgents = {
|
||||
mac: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:70.0) Gecko/20100101 Firefox/70.0",
|
||||
windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
||||
linux: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36",
|
||||
}
|
||||
|
||||
const userAgent = ""
|
||||
|
||||
if (process.platform == darwin) {
|
||||
userAgent = userAgents.mac;
|
||||
} else if (process.platform == win32) {
|
||||
userAgent = userAgents.windows;
|
||||
} else {
|
||||
userAgent = userAgents.linux;
|
||||
}
|
||||
|
||||
win.webContents.session.webRequest.onBeforeSendHeaders((details, cb) => {
|
||||
details.requestHeaders["User-Agent"] = userAgent;
|
||||
|
||||
Reference in New Issue
Block a user