Merge pull request #463 from Araxeus/use-apiLoaded-event-for-time-update

Sponsorblock fix + use new apiLoaded event
This commit is contained in:
th-ch
2021-11-01 12:03:47 +01:00
committed by GitHub
9 changed files with 33 additions and 53 deletions

View File

@ -15,5 +15,5 @@ module.exports = () => {
const data = e.detail.getPlayerResponse();
ipcRenderer.send("song-info-request", JSON.stringify(data));
});
})
}, { once: true, passive: true })
};

View File

@ -1,22 +0,0 @@
let videoElement = null;
module.exports.ontimeupdate = (cb) => {
const observer = new MutationObserver((mutations, observer) => {
if (!videoElement) {
videoElement = document.querySelector("video");
if (videoElement) {
observer.disconnect();
videoElement.ontimeupdate = () => cb(videoElement);
}
}
});
if (!videoElement) {
observer.observe(document, {
childList: true,
subtree: true,
});
} else {
videoElement.ontimeupdate = () => cb(videoElement);
}
};