mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 12:42:06 +00:00
Merge pull request #465 from Araxeus/fix-sponsorblock-v2
Fix sponsorblock skipping when not needed
This commit is contained in:
@ -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)
|
// 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', () => {
|
document.addEventListener('apiLoaded', () => {
|
||||||
setNavbarMargin()
|
setNavbarMargin();
|
||||||
const playPageObserver = new MutationObserver(() => {
|
const playPageObserver = new MutationObserver(setNavbarMargin);
|
||||||
setNavbarMargin();
|
|
||||||
});
|
|
||||||
playPageObserver.observe($('ytmusic-app-layout'), { attributeFilter: ['player-page-open_', 'playerPageOpen_'] })
|
playPageObserver.observe($('ytmusic-app-layout'), { attributeFilter: ['player-page-open_', 'playerPageOpen_'] })
|
||||||
})
|
}, { once: true, passive: true })
|
||||||
};
|
};
|
||||||
|
|
||||||
function setNavbarMargin() {
|
function setNavbarMargin() {
|
||||||
$('ytmusic-app-layout').playerPageOpen_ ?
|
$('#nav-bar-background').style.right =
|
||||||
$('#nav-bar-background').style.right = '0px' :
|
$('ytmusic-app-layout').playerPageOpen_ ?
|
||||||
$('#nav-bar-background').style.right = '12px';
|
'0px' :
|
||||||
|
'12px';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,9 @@ module.exports = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener('apiLoaded', () => {
|
document.addEventListener('apiLoaded', () => {
|
||||||
document.querySelector('video').addEventListener('timeupdate', e => {
|
const video = document.querySelector('video');
|
||||||
|
|
||||||
|
video.addEventListener('timeupdate', e => {
|
||||||
currentSegments.forEach((segment) => {
|
currentSegments.forEach((segment) => {
|
||||||
if (
|
if (
|
||||||
e.target.currentTime >= segment[0] &&
|
e.target.currentTime >= segment[0] &&
|
||||||
@ -23,5 +25,7 @@ module.exports = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
// Reset segments on song end
|
||||||
|
video.addEventListener('emptied', () => currentSegments = []);
|
||||||
}, { once: true, passive: true })
|
}, { once: true, passive: true })
|
||||||
};
|
};
|
||||||
|
|||||||
@ -11,7 +11,7 @@ ipcRenderer.on("update-song-info", async (_, extractedSongInfo) => {
|
|||||||
|
|
||||||
module.exports = () => {
|
module.exports = () => {
|
||||||
document.addEventListener('apiLoaded', e => {
|
document.addEventListener('apiLoaded', e => {
|
||||||
document.querySelector('video').addEventListener('loadeddata', () => {
|
document.querySelector('video').addEventListener('loadedmetadata', () => {
|
||||||
const data = e.detail.getPlayerResponse();
|
const data = e.detail.getPlayerResponse();
|
||||||
ipcRenderer.send("song-info-request", JSON.stringify(data));
|
ipcRenderer.send("song-info-request", JSON.stringify(data));
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user