mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +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)
|
||||
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';
|
||||
}
|
||||
|
||||
@ -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 })
|
||||
};
|
||||
|
||||
@ -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));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user