fix: Fix corrupt database, Add soundcloud and spotify embeds
This commit is contained in:
@@ -15,8 +15,37 @@ let mainWindow: BrowserWindow | null = null;
|
||||
let tray: Tray | null = null;
|
||||
let closeToTrayEnabled = true;
|
||||
let appQuitting = false;
|
||||
let youtubeRequestHeadersConfigured = false;
|
||||
|
||||
const WINDOW_STATE_CHANGED_CHANNEL = 'window-state-changed';
|
||||
const YOUTUBE_EMBED_REFERRER = 'https://toju.app/';
|
||||
|
||||
function ensureYoutubeEmbedRequestHeaders(): void {
|
||||
if (youtubeRequestHeadersConfigured || !app.isPackaged) {
|
||||
return;
|
||||
}
|
||||
|
||||
youtubeRequestHeadersConfigured = true;
|
||||
|
||||
session.defaultSession.webRequest.onBeforeSendHeaders(
|
||||
{
|
||||
urls: [
|
||||
'https://www.youtube-nocookie.com/*',
|
||||
'https://www.youtube.com/*',
|
||||
'https://*.youtube.com/*',
|
||||
'https://*.googlevideo.com/*',
|
||||
'https://*.ytimg.com/*'
|
||||
]
|
||||
},
|
||||
(details, callback) => {
|
||||
const requestHeaders = { ...details.requestHeaders };
|
||||
|
||||
requestHeaders['Referer'] ??= YOUTUBE_EMBED_REFERRER;
|
||||
|
||||
callback({ requestHeaders });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function getAssetPath(...segments: string[]): string {
|
||||
const basePath = app.isPackaged
|
||||
@@ -163,6 +192,7 @@ export async function createWindow(): Promise<void> {
|
||||
|
||||
closeToTrayEnabled = readDesktopSettings().closeToTray;
|
||||
ensureTray();
|
||||
ensureYoutubeEmbedRequestHeaders();
|
||||
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1400,
|
||||
|
||||
Reference in New Issue
Block a user