From ba40800a5e6723bf516d6edb2c2a2ab6bdcb758d Mon Sep 17 00:00:00 2001 From: Shiny Nematoda Date: Wed, 15 Mar 2023 03:38:16 +0530 Subject: [PATCH] Minor fix for SponsorBlock --- src/components/VideoPlayer.vue | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/components/VideoPlayer.vue b/src/components/VideoPlayer.vue index 4283ba77..08c922ab 100644 --- a/src/components/VideoPlayer.vue +++ b/src/components/VideoPlayer.vue @@ -222,6 +222,8 @@ export default { }, methods: { async loadVideo() { + this.updateSponsors(); + const component = this; const videoEl = this.$refs.videoEl; @@ -696,6 +698,18 @@ export default { if (markers) markers.style.background = `linear-gradient(${array.join(",")})`; }, + updateSponsors() { + const skipOptions = this.getPreferenceJSON("skipOptions", {}); + this.sponsors?.segments?.forEach(segment => { + const option = skipOptions[segment.category]; + segment.autoskip = option === undefined || option === "auto"; + }); + if (this.getPreferenceBoolean("showMarkers", true)) { + this.shakaPromise.then(() => { + this.updateMarkers(); + }); + } + }, destroy(hotkeys) { if (this.$ui && !document.pictureInPictureElement) { this.$ui.destroy(); @@ -710,20 +724,6 @@ export default { this.$refs.container?.querySelectorAll("div").forEach(node => node.remove()); }, }, - watch: { - sponsors() { - const skipOptions = this.getPreferenceJSON("skipOptions", {}); - this.sponsors?.segments?.forEach(segment => { - const option = skipOptions[segment.category]; - segment.autoskip = option === undefined || option === "auto"; - }); - if (this.getPreferenceBoolean("showMarkers", true)) { - this.shakaPromise.then(() => { - this.updateMarkers(); - }); - } - }, - }, };