mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 20:52:06 +00:00
make useragent override optional
This commit is contained in:
5
index.js
5
index.js
@ -192,6 +192,7 @@ function createMainWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.once("browser-window-created", (event, win) => {
|
app.once("browser-window-created", (event, win) => {
|
||||||
|
if (config.get("options.overrideUserAgent")) {
|
||||||
// User agents are from https://developers.whatismybrowser.com/useragents/explore/
|
// User agents are from https://developers.whatismybrowser.com/useragents/explore/
|
||||||
const originalUserAgent = win.webContents.userAgent;
|
const originalUserAgent = win.webContents.userAgent;
|
||||||
const userAgents = {
|
const userAgents = {
|
||||||
@ -210,12 +211,12 @@ app.once("browser-window-created", (event, win) => {
|
|||||||
|
|
||||||
win.webContents.session.webRequest.onBeforeSendHeaders((details, cb) => {
|
win.webContents.session.webRequest.onBeforeSendHeaders((details, cb) => {
|
||||||
// this will only happen if login failed, and "retry" was pressed
|
// 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;
|
details.requestHeaders["User-Agent"] = originalUserAgent;
|
||||||
}
|
}
|
||||||
cb({ requestHeaders: details.requestHeaders });
|
cb({ requestHeaders: details.requestHeaders });
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setupSongInfo(win);
|
setupSongInfo(win);
|
||||||
loadPlugins(win);
|
loadPlugins(win);
|
||||||
|
|||||||
8
menu.js
8
menu.js
@ -174,6 +174,14 @@ const mainMenuTemplate = (win) => {
|
|||||||
setProxy(item, win);
|
setProxy(item, win);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Override useragent",
|
||||||
|
type: "checkbox",
|
||||||
|
checked: config.get("options.overrideUserAgent"),
|
||||||
|
click: (item) => {
|
||||||
|
config.set("options.overrideUserAgent", item.checked);
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "Disable hardware acceleration",
|
label: "Disable hardware acceleration",
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
|
|||||||
Reference in New Issue
Block a user