mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
fix: workarounds for region restrict
This commit is contained in:
14
src/index.ts
14
src/index.ts
@ -265,7 +265,7 @@ async function createMainWindow() {
|
||||
const windowPosition: Electron.Point = config.get('window-position');
|
||||
const useInlineMenu = config.plugins.isEnabled('in-app-menu');
|
||||
|
||||
const defaultTitleBarOverlayOptions: Electron.TitleBarOverlayOptions = {
|
||||
const defaultTitleBarOverlayOptions: Electron.TitleBarOverlay = {
|
||||
color: '#00000000',
|
||||
symbolColor: '#ffffff',
|
||||
height: 32,
|
||||
@ -420,6 +420,18 @@ async function createMainWindow() {
|
||||
});
|
||||
}
|
||||
});
|
||||
win.webContents.on('will-redirect', (event) => {
|
||||
const url = new URL(event.url);
|
||||
|
||||
// Workarounds for regions where YTM is restricted
|
||||
if (url.hostname.endsWith('youtube.com') && url.pathname === '/premium') {
|
||||
event.preventDefault();
|
||||
|
||||
win.webContents.loadURL(
|
||||
'https://accounts.google.com/ServiceLogin?ltmpl=music&service=youtube&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26next%3Dhttps%253A%252F%252Fmusic.youtube.com%252F'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
win.webContents.loadURL(urlToLoad);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user