summaryrefslogtreecommitdiff
path: root/features/user/gui/apps/qutebrowser/scripts/yt-sponsor-skip.js
diff options
context:
space:
mode:
authortriethyl <triethylammonium@pm.me>2025-09-02 10:48:21 -0400
committertriethyl <triethylammonium@pm.me>2025-09-02 10:48:21 -0400
commit31c316d19cd974bb81a5d6de62142ff24db1c78e (patch)
treecb941422c76cb8953830a8d58c8e14dca1a10319 /features/user/gui/apps/qutebrowser/scripts/yt-sponsor-skip.js
parent1c21018347aa277caba74e554cb8d1b1e7fc6bed (diff)
reorganized directory structure
Diffstat (limited to 'features/user/gui/apps/qutebrowser/scripts/yt-sponsor-skip.js')
-rw-r--r--features/user/gui/apps/qutebrowser/scripts/yt-sponsor-skip.js51
1 files changed, 0 insertions, 51 deletions
diff --git a/features/user/gui/apps/qutebrowser/scripts/yt-sponsor-skip.js b/features/user/gui/apps/qutebrowser/scripts/yt-sponsor-skip.js
deleted file mode 100644
index 3779cbf..0000000
--- a/features/user/gui/apps/qutebrowser/scripts/yt-sponsor-skip.js
+++ /dev/null
@@ -1,51 +0,0 @@
-// ==UserScript==
-// @name Sponsorblock
-// @version 1.1.0
-// @description Skip sponsor segments automatically
-// @author afreakk
-// @author vongaisberg
-// @match *://*.youtube.com/*
-// @exclude *://*.youtube.com/subscribe_embed?*
-// ==/UserScript==
-const delay = 1000;
-
-const tryFetchSkipSegments = (videoID) =>
-
- fetch(`https://sponsor.ajay.app/api/skipSegments?videoID=${videoID}`)
- .then((r) => r.json())
- .then((rJson) =>
- rJson.filter((a) => a.actionType === 'skip').map((a) => a.segment)
- )
- .catch(
- (e) =>
- console.log(
- `Sponsorblock: failed fetching skipSegments for ${videoID}, reason: ${e}`
- ) || []
- );
-
-const skipSegments = async () => {
- const videoID = new URL(document.location).searchParams.get('v');
- if (!videoID) {
- return;
- }
- const key = `segmentsToSkip-${videoID}`;
- window[key] = window[key] || (await tryFetchSkipSegments(videoID));
- for (const v of document.querySelectorAll('video')) {
- if (Number.isNaN(v.duration)) continue;
- for (const [start, end] of window[key]) {
- if (v.currentTime < end && v.currentTime >= start) {
- console.log(`Sponsorblock: skipped video @${v.currentTime} from ${start} to ${end}`);
- v.currentTime = end;
- return
- }
- const timeToSponsor = (start - v.currentTime) / v.playbackRate;
- if (v.currentTime < start && timeToSponsor < (delay / 1000)) {
- console.log(`Sponsorblock: Almost at sponsor segment, sleep for ${timeToSponsor * 1000}ms`);
- setTimeout(skipSegments, timeToSponsor * 1000);
- }
- }
- }
-};
-if (!window.skipSegmentsIntervalID) {
- window.skipSegmentsIntervalID = setInterval(skipSegments, delay);
-}