mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
Only set user-agent on accounts.google.com (affects preload scripts otherwise)
This commit is contained in:
22
index.js
22
index.js
@ -60,12 +60,7 @@ function createMainWindow() {
|
||||
win.maximize();
|
||||
}
|
||||
|
||||
// Force user-agent "Firefox Windows" for Google OAuth to work
|
||||
// From https://github.com/firebase/firebase-js-sdk/issues/2478#issuecomment-571356751
|
||||
const userAgent =
|
||||
"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:70.0) Gecko/20100101 Firefox/70.0";
|
||||
|
||||
win.webContents.loadURL(store.get("url"), { userAgent });
|
||||
win.webContents.loadURL(store.get("url"));
|
||||
win.on("closed", onClosed);
|
||||
|
||||
injectCSS(win.webContents, path.join(__dirname, "youtube-music.css"));
|
||||
@ -99,6 +94,21 @@ function createMainWindow() {
|
||||
}
|
||||
});
|
||||
|
||||
win.webContents.on("will-navigate", (_, url) => {
|
||||
if (url.startsWith("https://accounts.google.com")) {
|
||||
// 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";
|
||||
|
||||
win.webContents.session.webRequest.onBeforeSendHeaders((details, cb) => {
|
||||
details.requestHeaders["User-Agent"] = userAgent;
|
||||
cb({ requestHeaders: details.requestHeaders });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
win.webContents.on(
|
||||
"new-window",
|
||||
(e, url, frameName, disposition, options) => {
|
||||
|
||||
Reference in New Issue
Block a user