Merge pull request #465 from Araxeus/fix-sponsorblock-v2

Fix sponsorblock skipping when not needed
This commit is contained in:
th-ch
2021-11-01 21:54:05 +01:00
committed by GitHub
3 changed files with 13 additions and 10 deletions

View File

@ -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';
}

View File

@ -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 })
};

View File

@ -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));
});