Add SponsorBlock plugin

This commit is contained in:
TC
2021-06-03 21:47:00 +02:00
parent 30e94d1d6f
commit ca64a77ed0
5 changed files with 154 additions and 1 deletions

View File

@ -0,0 +1,27 @@
const { ipcRenderer } = require("electron");
const is = require("electron-is");
const { ontimeupdate } = require("../../providers/video-element");
let currentSegments = [];
module.exports = () => {
ipcRenderer.on("sponsorblock-skip", (_, segments) => {
currentSegments = segments;
});
ontimeupdate((videoElement) => {
if (
currentSegments.length > 0 &&
videoElement.currentTime >= currentSegments[0][0] &&
videoElement.currentTime <= currentSegments[0][1]
) {
videoElement.currentTime = currentSegments[0][1];
const skipped = currentSegments.shift();
if (is.dev()) {
console.log("SponsorBlock: skipping segment", skipped);
}
}
});
};