Greasy Fork

日租号解析一同看

一同看解析插件

目前为 2024-02-13 提交的版本。查看 最新版本

// ==UserScript==
// @name         日租号解析一同看
// @namespace    http://your.namespace/
// @version      2.2
// @description  一同看解析插件
// @author       日租号站长
// @match        *://*/*
// @grant        GM.xmlHttpRequest
// @grant        GM.addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @connect      api.gv1069.vip
// @exclude      http://gv1069.vip/*
// @exclude      http://www.gv1069.vip/*
// @exclude      https://m3u8play.com/*
// @exclude      https://greasyfork.org/*
// @exclude      https://www.greasyfork.org/*
// @license MIT
// ==/UserScript==

(function () {
    'use strict';

    // 定义登录 API 地址
    var yitongkanBase = "http://api.gv1069.vip";

    var value = "450";

    var valueGao = "900";
    var valueChao = "1800";
    var valueJiu = "400";
    var m3u8Url = "";


    // 在页面加载时创建登录弹框
    window.addEventListener('load', function () {
        // 添加样式
        GM.addStyle(`
    #gm-loading-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(255, 255, 255, 0.8);
        display: none;
        z-index: -1;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    #gm-loading-overlay div {
        font-size: 20px;
    }
    #customLoginModal {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        justify-content: center;
        align-items: center;
        z-index: 1000;
    }

    #loginBox {
        background: #fff;
        padding: 20px;
        border-radius: 8px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
        text-align: center;
    }

    #loginBox h2 {
        color: #333;
    }
`);
        // 创建加载中的遮罩层
        const loadingOverlay = document.createElement('div');
        loadingOverlay.id = 'gm-loading-overlay';
        loadingOverlay.innerHTML = '<div>正在解析一同看资源,请稍后...</div>';
        document.body.appendChild(loadingOverlay);

        // 显示加载中
        function showLoading() {
            loadingOverlay.style.display = 'flex';
            loadingOverlay.style.zIndex = 9999;
        }

        // 隐藏加载中
        function hideLoading() {
            loadingOverlay.style.display = 'none';
            loadingOverlay.style.zIndex = -1;
        }


        // Create a modal container
        const modalContainer = document.createElement('div');
        modalContainer.id = 'customLoginModal';
        modalContainer.style.display = 'none';
        document.body.appendChild(modalContainer);

        // Create the login box
        const loginBox = document.createElement('div');
        loginBox.id = 'loginBox';
        loginBox.innerHTML = `
        <h2>日租号专用登录通道</h2>
        <h3 style="margin-top:5px;color:red;">(请勿在一同看的登录框登录!!!)</h3>
        <form style="margin-top:20px;">
            <label for="username">用户名:</label>
            <input type="text" id="username" name="username" required><br>

            <label for="password" style="margin-top:10px;">密码:</label>
            <input type="password" id="password" name="password" required><br>

            <button id="submitBtn" style="margin-top:10px;">登录</button>
        </form>
    `;
        // Create close button
        const closeButton = document.createElement('span');
        closeButton.id = 'closeButton';
        closeButton.innerHTML = '&times;';
        closeButton.style.position = 'relative';
        closeButton.style.top = '10px';
        closeButton.style.right = '10px';
        closeButton.style.cursor = 'pointer';
        closeButton.style.fontSize = '50px';
        closeButton.style.color = '#000';

        // Append close button to login box
        loginBox.appendChild(closeButton);

        modalContainer.appendChild(loginBox);

        // Add click event to close button
        closeButton.addEventListener('click', function () {
            modalContainer.style.display = 'none';
        });

        // Show the login box
        function openLoginBox() {
            modalContainer.style.display = 'flex';
        }

        // Close the login box
        function closeLoginBox() {
            modalContainer.style.display = 'none';
        }

        var token = GM_getValue("YTToken");
        var username = GM_getValue("username");
        var password = GM_getValue("password");

        // 查找具有指定 class 的所有 UL 标签
        var ulElements = document.querySelectorAll('ul.list.g-clear');

        if (ulElements) {
            // 创建加载中的遮罩层
            const loadingOverlay = document.createElement('div');
            loadingOverlay.id = 'gm-loading-overlay';
            loadingOverlay.innerHTML = '<div>正在解析一同看资源,请稍后...</div>';
            document.body.appendChild(loadingOverlay);
            if (token == null || token == "") {
                showLoginPrompt();
            }

        }

        // 遍历每个 UL 元素
        ulElements.forEach(function (ulElement) {
            // 遍历 UL 元素中的每个 LI 元素
            ulElement.querySelectorAll('li').forEach(function (liElement, index) {
                // 查找 LI 元素中的 A 标签
                var aElement = liElement.querySelector('a');

                // 在 LI 元素上增加高度
                liElement.style.height = 600 + 'px';

                // 创建播放按钮
                var playButton1 = document.createElement('button');
                playButton1.innerText = '点我播放(标清)';
                playButton1.style.height = '70px'; // 50px 是你想要设置的高度

                // 创建播放按钮
                var playButton2 = document.createElement('button');
                playButton2.innerText = '高清(部分视频只有标清)';
                playButton2.style.height = '70px'; // 50px 是你想要设置的高度
                playButton2.style.marginTop = '10px';

                // 创建播放按钮
                var playButton3 = document.createElement('button');
                playButton3.innerText = '超清(部分视频只有标清)';
                playButton3.style.height = '70px'; // 50px 是你想要设置的高度
                playButton3.style.marginTop = '10px';

                // 创建播放按钮
                var playButton4 = document.createElement('button');
                playButton4.innerText = '早期视频专用播放按钮';
                playButton4.style.height = '70px'; // 50px 是你想要设置的高度
                playButton4.style.marginTop = '10px';

                // 添加点击事件监听器
                playButton1.addEventListener('click', function (event) {
                    showLoading(); // 显示加载中
                    if (token == null) {
                        var result = confirm("您未登录,请在日租号专用登录通道进行登录!请勿在一同看官方界面登录!点击“确定”按钮前往专用登录通道!");
                        if (result) {
                            window.location.reload();
                        }
                        hideLoading(); // 隐藏加载中

                    } else {

                        // 在这里发送 GET 请求
                        GM.xmlHttpRequest({
                            method: 'GET',
                            url: yitongkanBase + "/yitong/get-m3u8-url?link=" + aElement.href.split('/')[3] + "&token=" + token,  // 替换为你的 API 地址
                            onload: function (response) {
                                const responseData = JSON.parse(response.responseText);
                                if (responseData.success && responseData.content != null && responseData.content != "") {
                                    //后端通过message来区别是返回的是已经处理好的freshCode,还是从新请求的freshCode,0表示缓存fresh,1表示新的
                                    if (responseData.message == "1") {
                                        let strings = responseData.content.match(/(url: ')[^\\s]+/g)
                                        m3u8Url = strings[0].split("'")[1].replace("450", value)
                                        // /1693210723/d33e53edfbf7428b7da27417ead06231/data/d9927e3e380ea1c497f78fb5420bbfae/450/index.m3u8
                                        GM.xmlHttpRequest({
                                            method: 'GET',
                                            url: yitongkanBase + "/yitong/update-fresh-code?expire_time=" + m3u8Url.split("/")[1] + "&fresh_flag=" + m3u8Url.split("/")[2],  // 替换为你的 API 地址
                                            onload: function (response1) {

                                                // 处理响应
                                                const responseData1 = JSON.parse(response1.responseText);
                                                console.log(responseData1.content)
                                            },
                                            onerror: function (error1) {
                                                // 处理错误
                                                console.error(error1);
                                            }

                                        });
                                    } else if (responseData.message == "0") {
                                        //下次修改后端代码再改成默认流畅
                                        m3u8Url = responseData.content.replace("1800", value)
                                    }

                                    window.location.href = "https://m3u8play.com/?play=https://" + window.location.href.split('/')[2] + m3u8Url;
                                    hideLoading(); // 隐藏加载中
                                    // window.location.href = "https://tools.liumingye.cn/m3u8/#" + window.location.href + m3u8Url;
                                    // w!.location.href = "https://tools.liumingye.cn/m3u8/#" + baseUrl.value + m3u8Url;

                                } else if (responseData.message == "2") {
                                    hideLoading(); // 隐藏加载中
                                    // message.error("账户过期,请重新购买")
                                    GM_setValue("YTToken", "");
                                    GM_setValue('username', "");
                                    GM_setValue('password', "");
                                    var result = confirm("该账户已过期,请您重新购买或者取号!点击“确定”按钮自动跳转至购买界面!");
                                    if (result) {
                                        window.location.href = "http://gv1069.vip/#/shop-account";
                                    }

                                } else if (responseData.message == "3") {
                                    hideLoading(); // 隐藏加载中
                                    GM_setValue("YTToken", "");
                                    GM_setValue('username', "");
                                    GM_setValue('password', "");
                                    var result = confirm("请您重新登录!点击“确定”按钮自动弹出登录输入框!");
                                    if (result) {
                                        window.location.reload();
                                    }
                                } else if (responseData.message == "4" || responseData.message == "5") {
                                    hideLoading(); // 隐藏加载中
                                    GM_setValue("YTToken", "");
                                    GM_setValue('username', "");
                                    GM_setValue('password', "");
                                    var result = confirm("请您重新登录!点击“确定”按钮自动弹出登录输入框!");
                                    if (result) {
                                        window.location.reload();
                                    }

                                } else if (responseData.message == "6") {
                                    hideLoading(); // 隐藏加载中
                                    GM_setValue("YTToken", "");
                                    GM_setValue('username', "");
                                    GM_setValue('password', "");
                                    var result = confirm("您的账号在另一台设备上登录,请重新登录");
                                    if (result) {
                                        window.location.reload();
                                    }
                                } else {
                                    hideLoading(); // 隐藏加载中
                                    alert('解析失败,请点击播放按钮重试!');
                                }
                            },
                            onerror: function (error) {
                                hideLoading(); // 隐藏加载中
                                // 处理错误
                                console.error(error);
                                alert('解析失败,请点击播放按钮重试!');
                            }
                        });
                    }

                });



                // 添加点击事件监听器
                playButton2.addEventListener('click', function (event) {
                    showLoading(); // 显示加载中
                    if (token == null || username == "" || password == "") {
                        var result = confirm("您未登录,请在日租号专用登录通道进行登录!请勿在一同看官方界面登录!点击“确定”按钮前往专用登录通道!");
                        if (result) {
                            window.location.reload();
                        }
                        hideLoading(); // 隐藏加载中

                    } else {
                        GM.xmlHttpRequest({
                            method: 'GET',
                            url: yitongkanBase + "/pay/is-taocan?account=" + GM_getValue("username"),
                            onload: function (responseAccount) {
                                const responseDataAccount = JSON.parse(responseAccount.responseText);
                                if (responseDataAccount.content) {
                                    // 在这里发送 GET 请求
                                    GM.xmlHttpRequest({
                                        method: 'GET',
                                        url: yitongkanBase + "/yitong/get-m3u8-url?link=" + aElement.href.split('/')[3] + "&token=" + token,  // 替换为你的 API 地址
                                        onload: function (response) {
                                            const responseData = JSON.parse(response.responseText);
                                            if (responseData.success && responseData.content != null && responseData.content != "") {
                                                //后端通过message来区别是返回的是已经处理好的freshCode,还是从新请求的freshCode,0表示缓存fresh,1表示新的
                                                if (responseData.message == "1") {
                                                    let strings = responseData.content.match(/(url: ')[^\\s]+/g)
                                                    m3u8Url = strings[0].split("'")[1].replace("450", valueGao)
                                                    // /1693210723/d33e53edfbf7428b7da27417ead06231/data/d9927e3e380ea1c497f78fb5420bbfae/450/index.m3u8
                                                    GM.xmlHttpRequest({
                                                        method: 'GET',
                                                        url: yitongkanBase + "/yitong/update-fresh-code?expire_time=" + m3u8Url.split("/")[1] + "&fresh_flag=" + m3u8Url.split("/")[2],  // 替换为你的 API 地址
                                                        onload: function (response1) {

                                                            // 处理响应
                                                            const responseData1 = JSON.parse(response1.responseText);
                                                            console.log(responseData1.content)
                                                        },
                                                        onerror: function (error1) {
                                                            // 处理错误
                                                            console.error(error1);
                                                        }

                                                    });
                                                } else if (responseData.message == "0") {
                                                    //下次修改后端代码再改成默认流畅
                                                    m3u8Url = responseData.content.replace("1800", valueGao)
                                                }

                                                window.location.href = "https://m3u8play.com/?play=https://" + window.location.href.split('/')[2] + m3u8Url;
                                                hideLoading(); // 隐藏加载中
                                                // window.location.href = "https://tools.liumingye.cn/m3u8/#" + window.location.href + m3u8Url;
                                                // w!.location.href = "https://tools.liumingye.cn/m3u8/#" + baseUrl.value + m3u8Url;

                                            } else if (responseData.message == "2") {
                                                hideLoading(); // 隐藏加载中
                                                // message.error("账户过期,请重新购买")
                                                GM_setValue("YTToken", "");
                                                GM_setValue('username', "");
                                                GM_setValue('password', "");
                                                var result = confirm("该账户已过期,请您重新购买或者取号!点击“确定”按钮自动跳转至购买界面!");
                                                if (result) {
                                                    window.location.href = "http://gv1069.vip/#/shop-account";
                                                }

                                            } else if (responseData.message == "3") {
                                                hideLoading(); // 隐藏加载中
                                                GM_setValue("YTToken", "");
                                                GM_setValue('username', "");
                                                GM_setValue('password', "");
                                                var result = confirm("请您重新登录!点击“确定”按钮自动弹出登录输入框!");
                                                if (result) {
                                                    window.location.reload();
                                                }
                                            } else if (responseData.message == "4" || responseData.message == "5") {
                                                hideLoading(); // 隐藏加载中
                                                GM_setValue("YTToken", "");
                                                GM_setValue('username', "");
                                                GM_setValue('password', "");
                                                var result = confirm("请您重新登录!点击“确定”按钮自动弹出登录输入框!");
                                                if (result) {
                                                    window.location.reload();
                                                }

                                            } else if (responseData.message == "6") {
                                                hideLoading(); // 隐藏加载中
                                                GM_setValue("YTToken", "");
                                                GM_setValue('username', "");
                                                GM_setValue('password', "");
                                                var result = confirm("您的账号在另一台设备上登录,请重新登录");
                                                if (result) {
                                                    window.location.reload();
                                                }
                                            } else {
                                                hideLoading(); // 隐藏加载中
                                                alert('解析失败,请点击播放按钮重试!');
                                            }
                                        },
                                        onerror: function (error) {
                                            hideLoading(); // 隐藏加载中
                                            // 处理错误
                                            console.error(error);
                                            alert('解析失败,请点击播放按钮重试!');
                                        }
                                    });

                                } else {
                                    hideLoading(); // 隐藏加载中
                                    var result = confirm("抱歉,清晰度切换和视频下载功能仅支持套餐内的日租号体验,如需要体验请前往租号网址gv1069.vip购买套餐!");
                                    if (result) {
                                        window.location.href = "http://gv1069.vip/#/shop-account";
                                    }
                                }
                            }

                        })
                    }

                });



                // 添加点击事件监听器
                playButton3.addEventListener('click', function (event) {
                    showLoading(); // 显示加载中
                    if (token == null || username == "" || password == "") {
                        var result = confirm("您未登录,请在日租号专用登录通道进行登录!请勿在一同看官方界面登录!点击“确定”按钮前往专用登录通道!");
                        if (result) {
                            window.location.reload();
                        }
                        hideLoading(); // 隐藏加载中

                    } else {
                        GM.xmlHttpRequest({
                            method: 'GET',
                            url: yitongkanBase + "/pay/is-taocan?account=" + GM_getValue("username"),
                            onload: function (responseAccount) {
                                const responseDataAccount = JSON.parse(responseAccount.responseText);
                                if (responseDataAccount.content) {

                                    // 在这里发送 GET 请求
                                    GM.xmlHttpRequest({
                                        method: 'GET',
                                        url: yitongkanBase + "/yitong/get-m3u8-url?link=" + aElement.href.split('/')[3] + "&token=" + token,  // 替换为你的 API 地址
                                        onload: function (response) {
                                            const responseData = JSON.parse(response.responseText);
                                            if (responseData.success && responseData.content != null && responseData.content != "") {
                                                //后端通过message来区别是返回的是已经处理好的freshCode,还是从新请求的freshCode,0表示缓存fresh,1表示新的
                                                if (responseData.message == "1") {
                                                    let strings = responseData.content.match(/(url: ')[^\\s]+/g)
                                                    m3u8Url = strings[0].split("'")[1].replace("450", valueChao)
                                                    // /1693210723/d33e53edfbf7428b7da27417ead06231/data/d9927e3e380ea1c497f78fb5420bbfae/450/index.m3u8
                                                    GM.xmlHttpRequest({
                                                        method: 'GET',
                                                        url: yitongkanBase + "/yitong/update-fresh-code?expire_time=" + m3u8Url.split("/")[1] + "&fresh_flag=" + m3u8Url.split("/")[2],  // 替换为你的 API 地址
                                                        onload: function (response1) {

                                                            // 处理响应
                                                            const responseData1 = JSON.parse(response1.responseText);
                                                            console.log(responseData1.content)
                                                        },
                                                        onerror: function (error1) {
                                                            // 处理错误
                                                            console.error(error1);
                                                        }

                                                    });
                                                } else if (responseData.message == "0") {
                                                    //下次修改后端代码再改成默认流畅
                                                    m3u8Url = responseData.content.replace("1800", valueChao)
                                                }

                                                window.location.href = "https://m3u8play.com/?play=https://" + window.location.href.split('/')[2] + m3u8Url;
                                                hideLoading(); // 隐藏加载中
                                                // window.location.href = "https://tools.liumingye.cn/m3u8/#" + window.location.href + m3u8Url;
                                                // w!.location.href = "https://tools.liumingye.cn/m3u8/#" + baseUrl.value + m3u8Url;

                                            } else if (responseData.message == "2") {
                                                hideLoading(); // 隐藏加载中
                                                // message.error("账户过期,请重新购买")
                                                GM_setValue("YTToken", "");
                                                GM_setValue('username', "");
                                                GM_setValue('password', "");
                                                var result = confirm("该账户已过期,请您重新购买或者取号!点击“确定”按钮自动跳转至购买界面!");
                                                if (result) {
                                                    window.location.href = "http://gv1069.vip/#/shop-account";
                                                }

                                            } else if (responseData.message == "3") {
                                                hideLoading(); // 隐藏加载中
                                                GM_setValue("YTToken", "");
                                                GM_setValue('username', "");
                                                GM_setValue('password', "");
                                                var result = confirm("请您重新登录!点击“确定”按钮自动弹出登录输入框!");
                                                if (result) {
                                                    window.location.reload();
                                                }
                                            } else if (responseData.message == "4" || responseData.message == "5") {
                                                hideLoading(); // 隐藏加载中
                                                GM_setValue("YTToken", "");
                                                GM_setValue('username', "");
                                                GM_setValue('password', "");
                                                var result = confirm("请您重新登录!点击“确定”按钮自动弹出登录输入框!");
                                                if (result) {
                                                    window.location.reload();
                                                }

                                            } else if (responseData.message == "6") {
                                                hideLoading(); // 隐藏加载中
                                                GM_setValue("YTToken", "");
                                                GM_setValue('username', "");
                                                GM_setValue('password', "");
                                                var result = confirm("您的账号在另一台设备上登录,请重新登录");
                                                if (result) {
                                                    window.location.reload();
                                                }
                                            } else {
                                                hideLoading(); // 隐藏加载中
                                                alert('解析失败,请点击播放按钮重试!');
                                            }
                                        },
                                        onerror: function (error) {
                                            hideLoading(); // 隐藏加载中
                                            // 处理错误
                                            console.error(error);
                                            alert('解析失败,请点击播放按钮重试!');
                                        }
                                    });
                                } else {
                                    hideLoading(); // 隐藏加载中
                                    var result = confirm("抱歉,清晰度切换和视频下载功能仅支持套餐内的日租号体验,如需要体验请前往租号网址gv1069.vip购买套餐!");
                                    if (result) {
                                        window.location.href = "http://gv1069.vip/#/shop-account";
                                    }
                                }
                            }

                        })

                    }

                });



                // 添加点击事件监听器
                playButton4.addEventListener('click', function (event) {
                    showLoading(); // 显示加载中
                    if (token == null || username == "" || password == "") {
                        var result = confirm("您未登录,请在日租号专用登录通道进行登录!请勿在一同看官方界面登录!点击“确定”按钮前往专用登录通道!");
                        if (result) {
                            window.location.reload();
                        }
                        hideLoading(); // 隐藏加载中

                    } else {

                        // 在这里发送 GET 请求
                        GM.xmlHttpRequest({
                            method: 'GET',
                            url: yitongkanBase + "/yitong/get-m3u8-url?link=" + aElement.href.split('/')[3] + "&token=" + token,  // 替换为你的 API 地址
                            onload: function (response) {
                                const responseData = JSON.parse(response.responseText);
                                if (responseData.success && responseData.content != null && responseData.content != "") {
                                    //后端通过message来区别是返回的是已经处理好的freshCode,还是从新请求的freshCode,0表示缓存fresh,1表示新的
                                    if (responseData.message == "1") {
                                        let strings = responseData.content.match(/(url: ')[^\\s]+/g)
                                        m3u8Url = strings[0].split("'")[1].replace("450", valueJiu)
                                        // /1693210723/d33e53edfbf7428b7da27417ead06231/data/d9927e3e380ea1c497f78fb5420bbfae/450/index.m3u8
                                        GM.xmlHttpRequest({
                                            method: 'GET',
                                            url: yitongkanBase + "/yitong/update-fresh-code?expire_time=" + m3u8Url.split("/")[1] + "&fresh_flag=" + m3u8Url.split("/")[2],  // 替换为你的 API 地址
                                            onload: function (response1) {

                                                // 处理响应
                                                const responseData1 = JSON.parse(response1.responseText);
                                                console.log(responseData1.content)
                                            },
                                            onerror: function (error1) {
                                                // 处理错误
                                                console.error(error1);
                                            }

                                        });
                                    } else if (responseData.message == "0") {
                                        //下次修改后端代码再改成默认流畅
                                        m3u8Url = responseData.content.replace("1800", valueJiu)
                                    }

                                    window.location.href = "https://m3u8play.com/?play=https://" + window.location.href.split('/')[2] + m3u8Url;
                                    hideLoading(); // 隐藏加载中
                                    // window.location.href = "https://tools.liumingye.cn/m3u8/#" + window.location.href + m3u8Url;
                                    // w!.location.href = "https://tools.liumingye.cn/m3u8/#" + baseUrl.value + m3u8Url;

                                } else if (responseData.message == "2") {
                                    hideLoading(); // 隐藏加载中
                                    // message.error("账户过期,请重新购买")
                                    GM_setValue("YTToken", "");
                                    GM_setValue('username', "");
                                    GM_setValue('password', "");
                                    var result = confirm("该账户已过期,请您重新购买或者取号!点击“确定”按钮自动跳转至购买界面!");
                                    if (result) {
                                        window.location.href = "http://gv1069.vip/#/shop-account";
                                    }

                                } else if (responseData.message == "3") {
                                    hideLoading(); // 隐藏加载中
                                    GM_setValue("YTToken", "");
                                    GM_setValue('username', "");
                                    GM_setValue('password', "");
                                    var result = confirm("请您重新登录!点击“确定”按钮自动弹出登录输入框!");
                                    if (result) {
                                        window.location.reload();
                                    }
                                } else if (responseData.message == "4" || responseData.message == "5") {
                                    hideLoading(); // 隐藏加载中
                                    GM_setValue("YTToken", "");
                                    GM_setValue('username', "");
                                    GM_setValue('password', "");
                                    var result = confirm("请您重新登录!点击“确定”按钮自动弹出登录输入框!");
                                    if (result) {
                                        window.location.reload();
                                    }

                                } else if (responseData.message == "6") {
                                    hideLoading(); // 隐藏加载中
                                    GM_setValue("YTToken", "");
                                    GM_setValue('username', "");
                                    GM_setValue('password', "");
                                    var result = confirm("您的账号在另一台设备上登录,请重新登录");
                                    if (result) {
                                        window.location.reload();
                                    }
                                } else {
                                    hideLoading(); // 隐藏加载中
                                    alert('解析失败,请点击播放按钮重试!');
                                }
                            },
                            onerror: function (error) {
                                hideLoading(); // 隐藏加载中
                                // 处理错误
                                console.error(error);
                                alert('解析失败,请点击播放按钮重试!');
                            }
                        });
                    }

                });


                // 设置播放按钮宽度
                playButton1.style.width = liElement.clientWidth + 'px';

                // 设置播放按钮宽度
                playButton2.style.width = liElement.clientWidth + 'px';

                // 设置播放按钮宽度
                playButton3.style.width = liElement.clientWidth + 'px';

                // 设置播放按钮宽度
                playButton4.style.width = liElement.clientWidth + 'px';

                // 添加播放按钮到 LI 元素
                liElement.appendChild(playButton1);


                // 添加播放按钮到 LI 元素
                liElement.appendChild(playButton2);


                // 添加播放按钮到 LI 元素
                liElement.appendChild(playButton3);


                // 添加播放按钮到 LI 元素
                liElement.appendChild(playButton4);
            });
        });

        // 弹框显示函数
        function showLoginPrompt() {
            // 使用prompt函数创建弹框

            // Trigger the login box
            openLoginBox();

            // 获取用户名和密码输入框的值
            const usernameInput = document.getElementById('username');
            const passwordInput = document.getElementById('password');
            const submitButton = document.getElementById('submitBtn');

            // 添加点击事件监听器
            submitButton.addEventListener('click', function () {
                const username = usernameInput.value;
                const password = passwordInput.value;
                if (username != "" && password != "") {
                    // 模拟后端通信,实际情况应该使用fetch或其他方式与后端通信
                    simulateBackendCommunication(username, password);
                } else {
                    alert('登录失败,用户名和密码不可为空!');
                }
            });
        }

        // 模拟后端通信
        function simulateBackendCommunication(username, password) {
            // 定义登录 API 地址
            const loginApiUrl = "http://api.gv1069.vip/user/login";

            // 定义登录参数
            const loginData = {
                loginName: username,
                password: password
            };
            // 发送登录请求
            GM.xmlHttpRequest({
                method: "POST",
                url: loginApiUrl,
                data: JSON.stringify(loginData),
                headers: {
                    "Content-Type": "application/json"
                },
                onload: function (response) {

                    // 解析返回的 JSON 数据
                    const responseData = JSON.parse(response.responseText);
                    console.log(responseData)

                    if (responseData.success) {
                        closeLoginBox();

                        GM_setValue('YTToken', responseData.content.token);
                        GM_setValue('username', username);
                        GM_setValue('password', password);

                        alert('登录成功,请尽情享受您的观影时间!');
                    } else {
                        if (responseData.message == "账户已过期,请重新购买") {
                            closeLoginBox();
                            GM_setValue("YTToken", "");
                            GM_setValue('username', "");
                            GM_setValue('password', "");
                            var result = confirm("该账户已过期,请您重新购买或者取号!点击“确定”按钮自动跳转至购买界面!");
                            if (result) {
                                window.location.href = "http://gv1069.vip/#/shop-account";
                            } else {
                                window.location.href = "http://gv1069.vip/#/shop-account";
                            }

                        } else {
                            alert('登录失败,请检查用户名和密码。');
                        }
                    }
                },
                onerror: function (error) {
                    console.error("Error:", error);
                }
            });
        }


    });
})();