mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-26 09:32:06 +00:00
Merge pull request #595 from Araxeus/useragent-option
make useragent override optional
This commit is contained in:
5
index.js
5
index.js
@ -221,6 +221,7 @@ function createMainWindow() {
|
||||
}
|
||||
|
||||
app.once("browser-window-created", (event, win) => {
|
||||
if (config.get("options.overrideUserAgent")) {
|
||||
// User agents are from https://developers.whatismybrowser.com/useragents/explore/
|
||||
const originalUserAgent = win.webContents.userAgent;
|
||||
const userAgents = {
|
||||
@ -239,12 +240,12 @@ app.once("browser-window-created", (event, win) => {
|
||||
|
||||
win.webContents.session.webRequest.onBeforeSendHeaders((details, cb) => {
|
||||
// this will only happen if login failed, and "retry" was pressed
|
||||
if (win.webContents.getURL().startsWith("https://accounts.google.com") && details.url.startsWith("https://accounts.google.com")){
|
||||
if (win.webContents.getURL().startsWith("https://accounts.google.com") && details.url.startsWith("https://accounts.google.com")) {
|
||||
details.requestHeaders["User-Agent"] = originalUserAgent;
|
||||
}
|
||||
cb({ requestHeaders: details.requestHeaders });
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
setupSongInfo(win);
|
||||
loadPlugins(win);
|
||||
|
||||
8
menu.js
8
menu.js
@ -187,6 +187,14 @@ const mainMenuTemplate = (win) => {
|
||||
setProxy(item, win);
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Override useragent",
|
||||
type: "checkbox",
|
||||
checked: config.get("options.overrideUserAgent"),
|
||||
click: (item) => {
|
||||
config.setMenuOption("options.overrideUserAgent", item.checked);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "Disable hardware acceleration",
|
||||
type: "checkbox",
|
||||
|
||||
Reference in New Issue
Block a user