From 64637a6ac5b547d3b805757fe467addeaefd7103 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Mon, 1 Nov 2021 19:57:15 +0200 Subject: [PATCH 1/3] Reset segments on song end --- plugins/sponsorblock/front.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/sponsorblock/front.js b/plugins/sponsorblock/front.js index 45d739b2..c4b32869 100644 --- a/plugins/sponsorblock/front.js +++ b/plugins/sponsorblock/front.js @@ -10,7 +10,9 @@ module.exports = () => { }); document.addEventListener('apiLoaded', () => { - document.querySelector('video').addEventListener('timeupdate', e => { + const video = document.querySelector('video'); + + video.addEventListener('timeupdate', e => { currentSegments.forEach((segment) => { if ( e.target.currentTime >= segment[0] && @@ -23,5 +25,7 @@ module.exports = () => { } }); }) + // Reset segments on song end + video.addEventListener('emptied', () => currentSegments = []); }, { once: true, passive: true }) }; From b1ffd93bc27eb3703569b374fd2f39266e40850a Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Mon, 1 Nov 2021 19:57:28 +0200 Subject: [PATCH 2/3] lint in-app-menu --- plugins/in-app-menu/front.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/plugins/in-app-menu/front.js b/plugins/in-app-menu/front.js index c731b1a0..0ed91a48 100644 --- a/plugins/in-app-menu/front.js +++ b/plugins/in-app-menu/front.js @@ -17,16 +17,15 @@ module.exports = () => { // Increases the right margin of Navbar background when the scrollbar is visible to avoid blocking it (z-index doesn't affect it) document.addEventListener('apiLoaded', () => { - setNavbarMargin() - const playPageObserver = new MutationObserver(() => { - setNavbarMargin(); - }); + setNavbarMargin(); + const playPageObserver = new MutationObserver(setNavbarMargin); playPageObserver.observe($('ytmusic-app-layout'), { attributeFilter: ['player-page-open_', 'playerPageOpen_'] }) - }) + }, { once: true, passive: true }) }; function setNavbarMargin() { - $('ytmusic-app-layout').playerPageOpen_ ? - $('#nav-bar-background').style.right = '0px' : - $('#nav-bar-background').style.right = '12px'; + $('#nav-bar-background').style.right = + $('ytmusic-app-layout').playerPageOpen_ ? + '0px' : + '12px'; } From 7b9415033f6553a03b3ac9c12035fa093eda7309 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Mon, 1 Nov 2021 20:03:57 +0200 Subject: [PATCH 3/3] use `loadedmetadata` instead of `loadeddata` --- providers/song-info-front.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/song-info-front.js b/providers/song-info-front.js index 31748cd3..4ff6041d 100644 --- a/providers/song-info-front.js +++ b/providers/song-info-front.js @@ -11,7 +11,7 @@ ipcRenderer.on("update-song-info", async (_, extractedSongInfo) => { module.exports = () => { document.addEventListener('apiLoaded', e => { - document.querySelector('video').addEventListener('loadeddata', () => { + document.querySelector('video').addEventListener('loadedmetadata', () => { const data = e.detail.getPlayerResponse(); ipcRenderer.send("song-info-request", JSON.stringify(data)); });