Skip to content

Commit

Permalink
fixed some things
Browse files Browse the repository at this point in the history
  • Loading branch information
JustYuuto committed Dec 28, 2023
1 parent 3ecd78e commit 56f9333
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 23 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

## Features

* Updates every 1 second so the RPC updates almost instantly
* Shows the song title, the song artist(s), the album cover (when the mouse is over the album cover the album title is shown), the song duration
* Updates instantly
* Shows the song title, the song artist(s), the album cover (when the mouse is over the album cover the album title is shown) and the song duration
* On the RPC there's a "Listen along" button like on the Spotify integration. This is a link to the song
* An in-app updater
* Can hide the activity if song is not playing
* Can set a "Listening to" status (like Spotify)
* Can set a "Listening to" status (like Spotify) (**requires your Discord token**)
* Includes an ad-blocker, so it can block Deezer ads, Sentry requests...
* Supports songs, radios, personal songs, podcasts

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"cpy-cli": "^4.2.0",
"electron": "^25.4.0",
"electron": "^28.1.0",
"electron-builder": "^24.6.3",
"eslint": "^8.56.0",
"fs-extra": "^11.1.1",
Expand Down
2 changes: 2 additions & 0 deletions src/utils/Tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export async function init(app: Electron.App, client: import('discord-rpc').Clie
}
});
} else {
menuItem.enabled = false;
menuItem.checked = false;
await prompt('ws', app);
}
}
Expand Down
30 changes: 18 additions & 12 deletions src/utils/Window.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { userAgents } from '../variables';
import { userAgent } from '../variables';
import { join, resolve } from 'path';
import loadAdBlock from './AdBlock';
import * as Config from './Config';
import * as DiscordWebSocket from './DiscordWebSocket';
import * as RPC from './RPC';
import { log } from './Log';
import { runJs, wait } from '../functions';
import { BrowserWindow, ipcMain, shell, nativeImage, session } from 'electron';
import { BrowserWindow, ipcMain, shell, nativeImage, session, dialog } from 'electron';
import { setActivity } from './Activity';

export let win: BrowserWindow;
Expand Down Expand Up @@ -34,27 +34,31 @@ export async function load(app: Electron.App) {

await win.loadURL('https://www.deezer.com/login', {
// The default user agent does not work with Deezer (the player does not update by itself)
userAgent: userAgents.deezerApp
userAgent
});

await setThumbarButtons();

session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
details.requestHeaders['User-Agent'] = userAgents.deezerApp;
details.requestHeaders['User-Agent'] = userAgent;
callback({ cancel: false, requestHeaders: details.requestHeaders });
});

session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
delete details.responseHeaders['cross-origin-opener-policy'];
delete details.responseHeaders['cross-origin-opener-policy-report-only'];
// delete details.responseHeaders['cross-origin-opener-policy'];
// delete details.responseHeaders['cross-origin-opener-policy-report-only'];
callback({ cancel: false, responseHeaders: details.responseHeaders });
});

win.webContents.setWindowOpenHandler((details) => {
if (
details.url.includes('accounts.google.com') || details.url.includes('facebook.com') ||
details.url.includes('apple.com')
) {
if (details.url.includes('accounts.google.com')) {
dialog.showMessageBox({
type: 'warning',
title: 'Google login',
message: 'Google login is broken, if someone knows how to fix it, please open an issue/PR on GitHub. Thanks!'
});
return { action: 'deny' };
} else if (details.url.includes('facebook.com') || details.url.includes('apple.com')) {
return {
action: 'allow',
overrideBrowserWindowOptions: {
Expand All @@ -64,7 +68,9 @@ export async function load(app: Electron.App) {
closable: true,
autoHideMenuBar: true,
fullscreenable: false,
resizable: true
resizable: true,
title: 'Deezer Discord RPC',
icon: join(__dirname, '..', 'img', 'app.ico'),
}
};
} else {
Expand Down Expand Up @@ -183,7 +189,7 @@ async function updateActivity(app: Electron.App, currentTimeChanged?: boolean) {
};

await setActivity({
client, albumId: result.albumId, timeLeft: result.timeLeft, app, ...currentTrack, /*songTime: realSongTime,*/ type: result.mediaType
client, albumId: result.albumId, timeLeft: result.timeLeft, app, ...currentTrack, type: result.mediaType
}).then(() => log('Activity', 'Updated'));
}
currentTrack.songTime = realSongTime;
Expand Down
4 changes: 1 addition & 3 deletions src/variables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export const clientId = '899229435130183690';
export const userAgents = {
deezerApp: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36',
};
export const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1343,10 +1343,10 @@ [email protected]:
lazy-val "^1.0.5"
mime "^2.5.2"

electron@^25.4.0:
version "25.4.0"
resolved "https://registry.yarnpkg.com/electron/-/electron-25.4.0.tgz#d45b1cf3e4e96eb5bff5fee704d7aa13b532f3a5"
integrity sha512-VLTRxDhL4UvQbqM7pTNENnJo62cdAPZT92N+B7BZQ5Xfok1wuVPEewIjBot4K7U3EpLUuHn1veeLzho3ihiP+Q==
electron@^28.1.0:
version "28.1.0"
resolved "https://registry.yarnpkg.com/electron/-/electron-28.1.0.tgz#9de1ecdaafcb0ec5753827f14dfb199e6c84545e"
integrity sha512-82Y7o4PSWPn1o/aVwYPsgmBw6Gyf2lVHpaBu3Ef8LrLWXxytg7ZRZr/RtDqEMOzQp3+mcuy3huH84MyjdmP50Q==
dependencies:
"@electron/get" "^2.0.0"
"@types/node" "^18.11.18"
Expand Down

0 comments on commit 56f9333

Please sign in to comment.