Phát Stripchat bằng PotPlayer, VLC, nPlayer, v.v.

Phát video trực tiếp trên Stripchat bằng các trình phát như PotPlayer, VLC và nPlayer.

Tính đến 07-01-2025. Xem phiên bản mới nhất.

// ==UserScript==
// @name        Play Stripchat by PotPlayer, VLC, nPlayer, etc
// @name:vi     Phát Stripchat bằng PotPlayer, VLC, nPlayer, v.v.
// @namespace   https://greasyfork.org/scripts/473187
// @version     1.1.1
// @author      zqq
// @license     MIT
// @description Play Stripchat live videos using external players like PotPlayer, VLC, and nPlayer.
// @description:vi Phát video trực tiếp trên Stripchat bằng các trình phát như PotPlayer, VLC và nPlayer.
// @match       *://*.stripchat.com/*
// @grant       GM_setClipboard
// ==/UserScript==

(function () {
    'use strict';

    // Lắng nghe XHR và tìm link m3u8
    let live_url = '';
    const originalOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function () {
        this.addEventListener('readystatechange', function () {
            if (this.readyState === 4 && this.responseText) {
                try {
                    if (this.responseText.includes('m3u8')) {
                        const match = this.responseText.match(/https?:\/\/.*?\.m3u8/);
                        if (match) {
                            live_url = match[0];
                            console.log('🔗 Found live URL:', live_url);
                        }
                    }
                } catch (e) {
                    console.warn('❌ Error parsing XHR response:', e);
                }
            }
        });
        originalOpen.apply(this, arguments);
    };

    function btn_com(player_name, player_url, copy_url = false) {
        let button = document.createElement("button");
        button.innerHTML = player_name;
        button.style.cssText = `
            width: 90px;
            height: 32px;
            text-align: center;
            color: white;
            background: #e33e33;
            border: 1px solid #e33e33;
            border-radius: 8px;
            font-size: 16px;
            cursor: pointer;
            margin: 5px;
        `;

        button.onclick = function () {
            if (!live_url) {
                alert('❌ Không tìm thấy URL video. Hãy thử làm mới trang.');
                return;
            }

            let final_url = `${player_url}${live_url}`;
            if (copy_url) {
                GM_setClipboard(final_url);
                alert(`✅ URL đã sao chép: ${final_url}`);
            } else {
                window.open(final_url);
            }
        };

        document.querySelector("#portal-root")?.prepend(button);
    }

    // Thêm nút cho các trình phát
    btn_com("Copy Link", "", true);
    btn_com("PotPlayer", "potplayer://");
    btn_com("VLC", "vlc://");
    btn_com("nPlayer", "nplayer-");

})();