From 31d90a342c93d4c025ac94d49989d5d89ba58e30 Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Tue, 20 Apr 2021 21:56:02 +0200 Subject: [PATCH 01/15] add time left for discord rpc --- src/preload.js | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/preload.js b/src/preload.js index 10ad1be..f0efb77 100644 --- a/src/preload.js +++ b/src/preload.js @@ -12,6 +12,10 @@ const notificationPath = `${app.getPath("userData")}/notification.jpg`; let currentSong = ""; let player; let currentPlayStatus = statuses.paused; +let sduration; +let barvalue; +let updatecurrent = false; +let oldcurrent; const elements = { play: '*[data-test="play"]', @@ -32,6 +36,9 @@ const elements = { media: '*[data-test="current-media-imagery"]', image: "img", url: 'a[href*="/track/"]', + current: '*[data-test="current-time"]', + duration: '*[data-test="duration-time"]', + bar: '*[data-test="progress-bar"]', /** * Get an element from the dom @@ -245,6 +252,9 @@ setInterval(function () { const title = elements.getText("title"); const url = elements.get("url").href.replace(/[^0-9]/g, ""); const artists = elements.getText("artists"); + const current = elements.getText("current"); + const duration = elements.getText("duration"); + const barval = elements.get("bar").getAttribute("aria-valuenow"); const songDashArtistTitle = `${title} - ${artists}`; const currentStatus = getCurrentlyPlayingStatus(); const options = { @@ -252,17 +262,46 @@ setInterval(function () { message: artists, status: currentStatus, url: `https://tidal.com/browse/track/${url}`, + current: current, + duration: duration, }; const playStatusChanged = currentStatus !== currentPlayStatus; + const durationChanged = duration !== sduration; + const barvalChanged = barval !== barvalue; const titleOrArtistChanged = currentSong !== songDashArtistTitle; - if (titleOrArtistChanged || playStatusChanged) { + if (titleOrArtistChanged || playStatusChanged || durationChanged || barvalChanged || updatecurrent) { // update title and play info with new info setTitle(songDashArtistTitle); currentSong = songDashArtistTitle; currentPlayStatus = currentStatus; + // check progress bar value and make sure current stays up to date after switch + if(barvalue != barval) { + barvalue = barval; + oldcurrent = options.current; + updatecurrent = true; + } + + if(updatecurrent) { + if(options.current == oldcurrent && currentStatus != "paused") return; + oldcurrent = options.current; + updatecurrent = false; + } + + // make sure current is set to 0 if title changes + if(titleOrArtistChanged) { + options.current = "0:00"; + barvalue = barval; + } + + if(durationChanged) { + options.duration = duration; + options.current = current; + sduration = duration; + } + const image = elements.getSongIcon(); new Promise((resolve) => { From df887b8628d8c8f2b647a7bcdf27c300dff1fa6c Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Tue, 20 Apr 2021 21:56:45 +0200 Subject: [PATCH 02/15] add time left to discord rpc & duration, current to mediainfo --- src/scripts/discord.js | 18 +++++++++++++++--- src/scripts/mediaInfo.js | 4 ++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/scripts/discord.js b/src/scripts/discord.js index 628d821..1753baa 100644 --- a/src/scripts/discord.js +++ b/src/scripts/discord.js @@ -1,21 +1,33 @@ const discordrpc = require("discord-rpc"); -const { ipcMain } = require("electron"); -const electron = require("electron"); +const { app, ipcMain } = require("electron"); const globalEvents = require("../constants/globalEvents"); const clientId = "833617820704440341"; const mediaInfoModule = require("./mediaInfo"); const discordModule = []; +function timeToSeconds(timeArray) { + let minutes = (timeArray[0] * 1); + let seconds = (minutes * 60) + (timeArray[1] * 1); + return seconds; +} + let rpc; const observer = (event, arg) => { if (mediaInfoModule.mediaInfo.status == "paused" && rpc) { rpc.setActivity(idleStatus); } else if (rpc) { + let csec = timeToSeconds(mediaInfoModule.mediaInfo.current.split(":")); + let dsec = timeToSeconds(mediaInfoModule.mediaInfo.duration.split(":")); + const date = new Date(); + let now = date.getTime() / 1000 | 0; + let remaining = date.setSeconds(date.getSeconds() + (dsec - csec)); rpc.setActivity({ ...idleStatus, ...{ details: `Listening to ${mediaInfoModule.mediaInfo.title}`, state: mediaInfoModule.mediaInfo.artist, + startTimestamp: parseInt(now), + endTimestamp: parseInt(remaining), buttons: [{ label: "Play on Tidal", url: mediaInfoModule.mediaInfo.url }], }, }); @@ -25,7 +37,7 @@ const observer = (event, arg) => { const idleStatus = { details: `Browsing Tidal`, largeImageKey: "tidal-hifi-icon", - largeImageText: `Tidal HiFi ${electron.app.getVersion()}`, + largeImageText: `Tidal HiFi ${app.getVersion()}`, instance: false, }; diff --git a/src/scripts/mediaInfo.js b/src/scripts/mediaInfo.js index e7d7f62..0964aa5 100644 --- a/src/scripts/mediaInfo.js +++ b/src/scripts/mediaInfo.js @@ -6,6 +6,8 @@ const mediaInfo = { icon: "", status: statuses.paused, url: "", + current: "", + duration: "" }; const mediaInfoModule = { mediaInfo, @@ -20,6 +22,8 @@ mediaInfoModule.update = function (arg) { mediaInfo.icon = propOrDefault(arg.icon); mediaInfo.url = propOrDefault(arg.url); mediaInfo.status = propOrDefault(arg.status); + mediaInfo.current = propOrDefault(arg.current); + mediaInfo.duration = propOrDefault(arg.duration); }; /** From 5e952e389951cda6c32a4025ec023960eff861cf Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Tue, 20 Apr 2021 22:12:11 +0200 Subject: [PATCH 03/15] Fix delay of one second when switching at song end --- src/preload.js | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/preload.js b/src/preload.js index f0efb77..0501635 100644 --- a/src/preload.js +++ b/src/preload.js @@ -277,29 +277,30 @@ setInterval(function () { currentSong = songDashArtistTitle; currentPlayStatus = currentStatus; - // check progress bar value and make sure current stays up to date after switch - if(barvalue != barval) { - barvalue = barval; - oldcurrent = options.current; - updatecurrent = true; - } - - if(updatecurrent) { - if(options.current == oldcurrent && currentStatus != "paused") return; - oldcurrent = options.current; - updatecurrent = false; - } - // make sure current is set to 0 if title changes - if(titleOrArtistChanged) { + if (titleOrArtistChanged) { options.current = "0:00"; + oldcurrent = options.current; barvalue = barval; - } + } else { + // check progress bar value and make sure current stays up to date after switch + if (barvalue != barval) { + barvalue = barval; + oldcurrent = options.current; + updatecurrent = true; + } - if(durationChanged) { - options.duration = duration; - options.current = current; - sduration = duration; + if (updatecurrent) { + if (options.current == oldcurrent && currentStatus != "paused") return; + oldcurrent = options.current; + updatecurrent = false; + } + + if (durationChanged) { + options.duration = duration; + options.current = current; + sduration = duration; + } } const image = elements.getSongIcon(); From 81a536bbdbcb4e253c94eb5de001edc04ad5827a Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Tue, 20 Apr 2021 22:15:34 +0200 Subject: [PATCH 04/15] revert last change --- src/preload.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/preload.js b/src/preload.js index 0501635..c8f27b0 100644 --- a/src/preload.js +++ b/src/preload.js @@ -277,30 +277,30 @@ setInterval(function () { currentSong = songDashArtistTitle; currentPlayStatus = currentStatus; + // check progress bar value and make sure current stays up to date after switch + if(barvalue != barval) { + barvalue = barval; + oldcurrent = options.current; + updatecurrent = true; + } + + if(updatecurrent) { + if(options.current == oldcurrent && currentStatus != "paused") return; + oldcurrent = options.current; + updatecurrent = false; + } + // make sure current is set to 0 if title changes - if (titleOrArtistChanged) { + if(titleOrArtistChanged) { options.current = "0:00"; oldcurrent = options.current; barvalue = barval; - } else { - // check progress bar value and make sure current stays up to date after switch - if (barvalue != barval) { - barvalue = barval; - oldcurrent = options.current; - updatecurrent = true; - } + } - if (updatecurrent) { - if (options.current == oldcurrent && currentStatus != "paused") return; - oldcurrent = options.current; - updatecurrent = false; - } - - if (durationChanged) { - options.duration = duration; - options.current = current; - sduration = duration; - } + if(durationChanged) { + options.duration = duration; + options.current = current; + sduration = duration; } const image = elements.getSongIcon(); From 59f8b2d0b53d77546b9bd9a28782518c4b2124d9 Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Tue, 20 Apr 2021 22:22:04 +0200 Subject: [PATCH 05/15] remove durationchanged as it was no longer needed --- src/preload.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/preload.js b/src/preload.js index c8f27b0..49206d6 100644 --- a/src/preload.js +++ b/src/preload.js @@ -12,7 +12,6 @@ const notificationPath = `${app.getPath("userData")}/notification.jpg`; let currentSong = ""; let player; let currentPlayStatus = statuses.paused; -let sduration; let barvalue; let updatecurrent = false; let oldcurrent; @@ -267,11 +266,10 @@ setInterval(function () { }; const playStatusChanged = currentStatus !== currentPlayStatus; - const durationChanged = duration !== sduration; const barvalChanged = barval !== barvalue; const titleOrArtistChanged = currentSong !== songDashArtistTitle; - if (titleOrArtistChanged || playStatusChanged || durationChanged || barvalChanged || updatecurrent) { + if (titleOrArtistChanged || playStatusChanged || barvalChanged || updatecurrent) { // update title and play info with new info setTitle(songDashArtistTitle); currentSong = songDashArtistTitle; @@ -281,6 +279,7 @@ setInterval(function () { if(barvalue != barval) { barvalue = barval; oldcurrent = options.current; + options.duration = duration; updatecurrent = true; } @@ -297,12 +296,6 @@ setInterval(function () { barvalue = barval; } - if(durationChanged) { - options.duration = duration; - options.current = current; - sduration = duration; - } - const image = elements.getSongIcon(); new Promise((resolve) => { From cac5db123f87defbd2fdf320bd24f8b45bc066b3 Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Tue, 20 Apr 2021 23:09:53 +0200 Subject: [PATCH 06/15] fix 1-2 second deflay between switching songs at song end --- src/preload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/preload.js b/src/preload.js index 49206d6..2e1553c 100644 --- a/src/preload.js +++ b/src/preload.js @@ -276,7 +276,7 @@ setInterval(function () { currentPlayStatus = currentStatus; // check progress bar value and make sure current stays up to date after switch - if(barvalue != barval) { + if(barvalue != barval && !titleOrArtistChanged) { barvalue = barval; oldcurrent = options.current; options.duration = duration; From 7a30b125ec9bb5940cbe20cd83ac9da43b76bf0e Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Wed, 21 Apr 2021 03:31:28 +0200 Subject: [PATCH 07/15] Add switch case for Video/Song --- src/preload.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/preload.js b/src/preload.js index 2e1553c..b85e49b 100644 --- a/src/preload.js +++ b/src/preload.js @@ -15,6 +15,7 @@ let currentPlayStatus = statuses.paused; let barvalue; let updatecurrent = false; let oldcurrent; +let currentURL = undefined; const elements = { play: '*[data-test="play"]', @@ -22,7 +23,7 @@ const elements = { next: '*[data-test="next"]', previous: 'button[data-test="previous"]', title: '*[data-test^="footer-track-title"]', - artists: '*[data-test^="grid-item-detail-text-title-artist"]', + artists: '*[class^="elemental__text elemental__text css-oxcos"]', home: '*[data-test="menu--home"]', back: '[class^="backwardButton"]', forward: '[class^="forwardButton"]', @@ -249,7 +250,7 @@ function updateMediaInfo(options, notify) { */ setInterval(function () { const title = elements.getText("title"); - const url = elements.get("url").href.replace(/[^0-9]/g, ""); + //const id = elements.get("url").href.replace(/[^0-9]/g, ""); const artists = elements.getText("artists"); const current = elements.getText("current"); const duration = elements.getText("duration"); @@ -260,7 +261,7 @@ setInterval(function () { title, message: artists, status: currentStatus, - url: `https://tidal.com/browse/track/${url}`, + url: currentURL, current: current, duration: duration, }; @@ -283,6 +284,17 @@ setInterval(function () { updatecurrent = true; } + // Video/Song check if it's a video return URL as undefined due to it not having an id. + switch(elements.get("url")) { + case null: + currentURL = undefined; + break; + default: + const id = elements.get("url").href.replace(/[^0-9]/g, ""); + currentURL = `https://tidal.com/browse/track/${id}`; + break; + } + if(updatecurrent) { if(options.current == oldcurrent && currentStatus != "paused") return; oldcurrent = options.current; From 08ec7fadacd74d61d09ab3ff4e2c4db51f17879a Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Wed, 21 Apr 2021 03:31:44 +0200 Subject: [PATCH 08/15] Add Video support --- src/scripts/discord.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/scripts/discord.js b/src/scripts/discord.js index 1753baa..72e9069 100644 --- a/src/scripts/discord.js +++ b/src/scripts/discord.js @@ -21,16 +21,28 @@ const observer = (event, arg) => { const date = new Date(); let now = date.getTime() / 1000 | 0; let remaining = date.setSeconds(date.getSeconds() + (dsec - csec)); - rpc.setActivity({ - ...idleStatus, - ...{ - details: `Listening to ${mediaInfoModule.mediaInfo.title}`, - state: mediaInfoModule.mediaInfo.artist, - startTimestamp: parseInt(now), - endTimestamp: parseInt(remaining), - buttons: [{ label: "Play on Tidal", url: mediaInfoModule.mediaInfo.url }], - }, - }); + if (mediaInfoModule.mediaInfo.url) { + rpc.setActivity({ + ...idleStatus, + ...{ + details: `Listening to ${mediaInfoModule.mediaInfo.title}`, + state: mediaInfoModule.mediaInfo.artist, + startTimestamp: parseInt(now), + endTimestamp: parseInt(remaining), + buttons: [{ label: "Play on Tidal", url: mediaInfoModule.mediaInfo.url }], + }, + }); + } else { + rpc.setActivity({ + ...idleStatus, + ...{ + details: `Listening to ${mediaInfoModule.mediaInfo.title}`, + state: mediaInfoModule.mediaInfo.artist, + startTimestamp: parseInt(now), + endTimestamp: parseInt(remaining), + }, + }); + } } }; From 3cc288e0145eefd11818806927c78905e12f969b Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Wed, 21 Apr 2021 04:44:44 +0200 Subject: [PATCH 09/15] Fix URL fetching --- src/preload.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/preload.js b/src/preload.js index b85e49b..3d80b51 100644 --- a/src/preload.js +++ b/src/preload.js @@ -250,7 +250,6 @@ function updateMediaInfo(options, notify) { */ setInterval(function () { const title = elements.getText("title"); - //const id = elements.get("url").href.replace(/[^0-9]/g, ""); const artists = elements.getText("artists"); const current = elements.getText("current"); const duration = elements.getText("duration"); @@ -285,12 +284,12 @@ setInterval(function () { } // Video/Song check if it's a video return URL as undefined due to it not having an id. - switch(elements.get("url")) { + switch(elements.get("title").querySelector("a")) { case null: currentURL = undefined; break; default: - const id = elements.get("url").href.replace(/[^0-9]/g, ""); + const id = elements.get("title").querySelector("a").href.replace(/[^0-9]/g, ""); currentURL = `https://tidal.com/browse/track/${id}`; break; } From 8201e23e4bccec3141594bab8169f6b2e1fb1cd4 Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Wed, 21 Apr 2021 04:48:23 +0200 Subject: [PATCH 10/15] Forgot to remove the now unused url element. --- src/preload.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/preload.js b/src/preload.js index 3d80b51..1c06c2c 100644 --- a/src/preload.js +++ b/src/preload.js @@ -35,7 +35,6 @@ const elements = { settings: '*[data-test^="open-settings"]', media: '*[data-test="current-media-imagery"]', image: "img", - url: 'a[href*="/track/"]', current: '*[data-test="current-time"]', duration: '*[data-test="duration-time"]', bar: '*[data-test="progress-bar"]', From 43ce85bb28736861f288819c64950b482ed333cb Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Wed, 21 Apr 2021 04:56:59 +0200 Subject: [PATCH 11/15] Change "listening to" to "watching" for videos --- src/scripts/discord.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/discord.js b/src/scripts/discord.js index 72e9069..2586423 100644 --- a/src/scripts/discord.js +++ b/src/scripts/discord.js @@ -36,7 +36,7 @@ const observer = (event, arg) => { rpc.setActivity({ ...idleStatus, ...{ - details: `Listening to ${mediaInfoModule.mediaInfo.title}`, + details: `Watching ${mediaInfoModule.mediaInfo.title}`, state: mediaInfoModule.mediaInfo.artist, startTimestamp: parseInt(now), endTimestamp: parseInt(remaining), From d8f2dbd0c2dcbfbd455fed8cd919ec1bf2865b4e Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Wed, 21 Apr 2021 17:24:18 +0200 Subject: [PATCH 12/15] Update castlabs electron to the newest release from 6 days ago. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f4ba291..ac1bc96 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "devDependencies": { "@mastermindzh/prettier-config": "^1.0.0", - "electron": "git+https://github.com/castlabs/electron-releases.git#v8.5.2-wvvmp", + "electron": "git+https://github.com/castlabs/electron-releases.git#v10.4.3-wvvmp", "electron-builder": "^21.2.0", "electron-reload": "^1.5.0", "prettier": "^2.0.4", From c65d1a56c87ebe8c424861b3953ed193e20c3361 Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Thu, 22 Apr 2021 11:14:49 +0200 Subject: [PATCH 13/15] add the enableRemoteModule preference as the new castlabs release uses v10 --- src/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.js b/src/main.js index 45f61f0..39e9ba9 100644 --- a/src/main.js +++ b/src/main.js @@ -44,6 +44,7 @@ function createWindow(options = {}) { preload: path.join(__dirname, "preload.js"), plugins: true, devTools: true, // I like tinkering, others might too + enableRemoteModule: true, }, }); From 10c1e57680b8a431ad832cf1b2d17fe97bbf0dbc Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Thu, 22 Apr 2021 11:33:57 +0200 Subject: [PATCH 14/15] extract Switch to function and change variable names. --- src/preload.js | 63 ++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/src/preload.js b/src/preload.js index 1c06c2c..ed1f846 100644 --- a/src/preload.js +++ b/src/preload.js @@ -12,9 +12,9 @@ const notificationPath = `${app.getPath("userData")}/notification.jpg`; let currentSong = ""; let player; let currentPlayStatus = statuses.paused; -let barvalue; -let updatecurrent = false; -let oldcurrent; +let progressBarTime; +let currentTimeChanged = false; +let currentTime; let currentURL = undefined; const elements = { @@ -244,6 +244,23 @@ function updateMediaInfo(options, notify) { } } +/** + * Checks if Tidal is playing a video or song by grabbing the "a" element from the title. + * If it's a song it sets the track URL as currentURL, If it's a video it will set currentURL to undefined. + */ +function updateURL() { + const URLelement = elements.get("title").querySelector("a"); + switch (URLelement) { + case null: + currentURL = undefined; + break; + default: + const id = URLelement.href.replace(/[^0-9]/g, ""); + currentURL = `https://tidal.com/browse/track/${id}`; + break; + } +} + /** * Watch for song changes and update title + notify */ @@ -252,7 +269,7 @@ setInterval(function () { const artists = elements.getText("artists"); const current = elements.getText("current"); const duration = elements.getText("duration"); - const barval = elements.get("bar").getAttribute("aria-valuenow"); + const progressBarcurrentTime = elements.get("bar").getAttribute("aria-valuenow"); const songDashArtistTitle = `${title} - ${artists}`; const currentStatus = getCurrentlyPlayingStatus(); const options = { @@ -265,45 +282,35 @@ setInterval(function () { }; const playStatusChanged = currentStatus !== currentPlayStatus; - const barvalChanged = barval !== barvalue; + const progressBarTimeChanged = progressBarcurrentTime !== progressBarTime; const titleOrArtistChanged = currentSong !== songDashArtistTitle; - if (titleOrArtistChanged || playStatusChanged || barvalChanged || updatecurrent) { - // update title and play info with new info + if (titleOrArtistChanged || playStatusChanged || progressBarTimeChanged || currentTimeChanged) { + // update title, url and play info with new info setTitle(songDashArtistTitle); + updateURL(); currentSong = songDashArtistTitle; currentPlayStatus = currentStatus; // check progress bar value and make sure current stays up to date after switch - if(barvalue != barval && !titleOrArtistChanged) { - barvalue = barval; - oldcurrent = options.current; + if(progressBarTime != progressBarcurrentTime && !titleOrArtistChanged) { + progressBarTime = progressBarcurrentTime; + currentTime = options.current; options.duration = duration; - updatecurrent = true; + currentTimeChanged = true; } - // Video/Song check if it's a video return URL as undefined due to it not having an id. - switch(elements.get("title").querySelector("a")) { - case null: - currentURL = undefined; - break; - default: - const id = elements.get("title").querySelector("a").href.replace(/[^0-9]/g, ""); - currentURL = `https://tidal.com/browse/track/${id}`; - break; - } - - if(updatecurrent) { - if(options.current == oldcurrent && currentStatus != "paused") return; - oldcurrent = options.current; - updatecurrent = false; + if(currentTimeChanged) { + if(options.current == currentTime && currentStatus != "paused") return; + currentTime = options.current; + currentTimeChanged = false; } // make sure current is set to 0 if title changes if(titleOrArtistChanged) { options.current = "0:00"; - oldcurrent = options.current; - barvalue = barval; + currentTime = options.current; + progressBarTime = progressBarcurrentTime; } const image = elements.getSongIcon(); From 791a92a4464d0a620e51fa1d2f2b11a3392d0f06 Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Thu, 22 Apr 2021 11:34:26 +0200 Subject: [PATCH 15/15] change let to const and use full length as names. --- src/scripts/discord.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/scripts/discord.js b/src/scripts/discord.js index 2586423..aae5ca6 100644 --- a/src/scripts/discord.js +++ b/src/scripts/discord.js @@ -16,11 +16,11 @@ const observer = (event, arg) => { if (mediaInfoModule.mediaInfo.status == "paused" && rpc) { rpc.setActivity(idleStatus); } else if (rpc) { - let csec = timeToSeconds(mediaInfoModule.mediaInfo.current.split(":")); - let dsec = timeToSeconds(mediaInfoModule.mediaInfo.duration.split(":")); + const currentSeconds = timeToSeconds(mediaInfoModule.mediaInfo.current.split(":")); + const durationSeconds = timeToSeconds(mediaInfoModule.mediaInfo.duration.split(":")); const date = new Date(); - let now = date.getTime() / 1000 | 0; - let remaining = date.setSeconds(date.getSeconds() + (dsec - csec)); + const now = date.getTime() / 1000 | 0; + const remaining = date.setSeconds(date.getSeconds() + (durationSeconds - currentSeconds)); if (mediaInfoModule.mediaInfo.url) { rpc.setActivity({ ...idleStatus,