YouTube → SkipCut Redirect (SPA-proof)

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

当前为 2025-08-11 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);
})();