YouTube → SkipCut Redirect (SPA-proof)

Redirect YouTube videos, live streams, and playlists to SkipCut, including SPA navigation

目前為 2025-08-23 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         YouTube → SkipCut Redirect (SPA-proof)
// @namespace    https://greasyfork.org/users/1197317-opus-x
// @version      1.0
// @description  Redirect YouTube videos, live streams, and playlists to SkipCut, including SPA navigation
// @author       Opus-X
// @license      MIT
// @icon         https://www.skipcut.com/favicon.ico
// @match        https://www.youtube.com/*
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    function checkAndRedirect() {
        const url = new URL(window.location.href);
        let newUrl = null;

        if (url.pathname === '/watch' && url.searchParams.has('v')) {
            newUrl = `https://www.skipcut.com/watch?v=${url.searchParams.get('v')}`;
        }
        else if (url.pathname.startsWith('/live/')) {
            const liveId = url.pathname.split('/')[2];
            if (liveId) {
                newUrl = `https://www.skipcut.com/live/${liveId}`;
            }
        }
        else if (url.pathname === '/playlist' && url.searchParams.has('list')) {
            newUrl = `https://www.skipcut.com/playlist?list=${url.searchParams.get('list')}`;
        }

        if (newUrl && newUrl !== window.location.href) {
            window.location.replace(newUrl);
        }
    }

    // Initial load
    checkAndRedirect();

    // Listen for YouTube SPA navigation events
    window.addEventListener('yt-navigate-start', checkAndRedirect);
    window.addEventListener('yt-page-data-updated', checkAndRedirect);

    // Fallback: detect URL changes manually
    let lastUrl = location.href;
    setInterval(() => {
        if (location.href !== lastUrl) {
            lastUrl = location.href;
            checkAndRedirect();
        }
    }, 300);
})();