From 08fdd07969d2090d20ab8c5358e649fe86faec2d Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Wed, 10 Nov 2021 20:44:13 +0200 Subject: [PATCH] speed up sponsorblock --- plugins/sponsorblock/back.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/plugins/sponsorblock/back.js b/plugins/sponsorblock/back.js index 0f16f102..592d486d 100644 --- a/plugins/sponsorblock/back.js +++ b/plugins/sponsorblock/back.js @@ -1,8 +1,8 @@ const fetch = require("node-fetch"); const is = require("electron-is"); +const { ipcMain } = require("electron"); const defaultConfig = require("../../config/defaults"); -const registerCallback = require("../../providers/song-info"); const { sortSegments } = require("./segments"); let videoID; @@ -13,15 +13,10 @@ module.exports = (win, options) => { ...options, }; - registerCallback(async (info) => { - const newURL = info.url || win.webContents.getURL(); - const newVideoID = new URL(newURL).searchParams.get("v"); - - if (videoID !== newVideoID) { - videoID = newVideoID; - const segments = await fetchSegments(apiURL, categories); - win.webContents.send("sponsorblock-skip", segments); - } + ipcMain.on("song-info-request", async (_, data) => { + videoID = JSON.parse(data)?.videoDetails?.videoId; + const segments = await fetchSegments(apiURL, categories); + win.webContents.send("sponsorblock-skip", segments); }); };