Sussy Links Stream Player

Play Video Stream URL's

// ==UserScript==
// @name         Sussy Links Stream Player
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Play Video Stream URL's
// @author       God
// @match        https://www.patreon.com/*
// @grant        none
// @icon         https://cdn.discordapp.com/icons/879103759328903289/4bca65635b628c53c71ed94a54d89cfd.webp?size=1024
// ==/UserScript==

(function () {
    'use strict';

    function loadHLS(callback) {
        const script = document.createElement('script');
        script.src = "https://cdn.jsdelivr.net/npm/[email protected]";
        script.onload = callback;
        script.onerror = () => alert("HLS.js failed to load dynamically.");
        document.head.appendChild(script);
    }

    const playButton = document.createElement('button');
    playButton.textContent = '▶ Play HLS Stream';
    playButton.style.cssText = `
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        padding: 12px 24px;
        font-size: 18px;
        z-index: 9999;
        background: #FF424D;
        color: white;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    `;

    function setupPlayer(streamUrl) {
        playButton.style.display = 'none';

        while (document.body.firstChild) {
            document.body.removeChild(document.body.firstChild);
        }
        document.body.appendChild(playButton);

        const video = document.createElement('video');
        video.controls = true;
        video.autoplay = true;
        video.playsInline = true;
        video.style.cssText = `
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: contain;
            z-index: 9998;
            background: black;
        `;

        const backButton = document.createElement('button');
        backButton.textContent = '✕ Close';
        backButton.style.cssText = `
            position: fixed;
            top: 15px;
            right: 15px;
            padding: 8px 12px;
            z-index: 9999;
            background: rgba(0,0,0,0.7);
            color: white;
            border: none;
            border-radius: 50%;
            font-size: 16px;
        `;
        backButton.onclick = () => {
            document.body.removeChild(video);
            document.body.removeChild(backButton);
            playButton.style.display = 'block';
        };

        document.body.appendChild(video);
        document.body.appendChild(backButton);

        if (Hls.isSupported()) {
            const hls = new Hls({
                maxBufferLength: 30,
                maxMaxBufferLength: 600,
                enableWorker: false
            });

            hls.loadSource(streamUrl);
            hls.attachMedia(video);

            hls.on(Hls.Events.MANIFEST_PARSED, () => video.play());
            hls.on(Hls.Events.ERROR, (event, data) => {
                if (data.fatal) {
                    alert(`HLS Error: ${data.type}`);
                    backButton.click();
                }
            });
        } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
            video.src = streamUrl;
            video.addEventListener('error', () => {
                alert('Native HLS failed.');
                backButton.click();
            });
        } else {
            alert('HLS not supported on this browser.');
            backButton.click();
        }
    }

    playButton.onclick = () => {
        const streamUrl = prompt("Paste stream URL:", "");
        if (streamUrl && (streamUrl.includes('.m3u8') || streamUrl.includes('mux.com'))) {
            if (typeof Hls === "undefined") {
                loadHLS(() => setupPlayer(streamUrl));
            } else {
                setupPlayer(streamUrl);
            }
        } else if (streamUrl) {
            alert("Not a valid HLS stream URL.");
        }
    };

    document.body.appendChild(playButton);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址