// ==UserScript== // @name 日租号解析一同看 // @namespace http://your.namespace/ // @version 1.5 // @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 // @downloadURL none // ==/UserScript== (function () { 'use strict'; // 定义登录 API 地址 var yitongkanBase = "http://api.gv1069.vip"; var value = "450"; 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 = '
正在解析一同看资源,请稍后...
'; 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'; document.body.appendChild(modalContainer); // Create the login box const loginBox = document.createElement('div'); loginBox.id = 'loginBox'; loginBox.innerHTML = `

日租号专用登录通道

(请勿在一同看的登录框登录!!!)



`; // Create close button const closeButton = document.createElement('span'); closeButton.id = 'closeButton'; closeButton.innerHTML = '×'; 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"); // 查找具有指定 class 的所有 UL 标签 var ulElements = document.querySelectorAll('ul.list.g-clear'); if(ulElements){ // 创建加载中的遮罩层 const loadingOverlay = document.createElement('div'); loadingOverlay.id = 'gm-loading-overlay'; loadingOverlay.innerHTML = '
正在解析一同看资源,请稍后...
'; 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 = 400 + 'px'; // 创建播放按钮 var playButton = document.createElement('button'); playButton.innerText = '点我播放(请勿点击上方图片文字)'; playButton.style.height = '70px'; // 50px 是你想要设置的高度 // 添加点击事件监听器 playButton.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", ""); var result = confirm("该账户已过期,请您重新购买或者取号!点击“确定”按钮自动跳转至购买界面!"); if (result) { window.location.href = "http://gv1069.vip/#/shop-account"; } } else if (responseData.message == "3") { hideLoading(); // 隐藏加载中 GM_setValue("YTToken", ""); var result = confirm("请您重新登录!点击“确定”按钮自动弹出登录输入框!"); if (result) { window.location.reload(); } } else if (responseData.message == "4" || responseData.message == "5") { hideLoading(); // 隐藏加载中 GM_setValue("YTToken", ""); var result = confirm("请您重新登录!点击“确定”按钮自动弹出登录输入框!"); if (result) { window.location.reload(); } } else if (responseData.message == "6") { hideLoading(); // 隐藏加载中 GM_setValue("YTToken", ""); var result = confirm("您的账号在另一台设备上登录,请重新登录"); if (result) { window.location.reload(); } } else { hideLoading(); // 隐藏加载中 alert('解析失败,请点击播放按钮重试!'); } }, onerror: function (error) { hideLoading(); // 隐藏加载中 // 处理错误 console.error(error); alert('解析失败,请点击播放按钮重试!'); } }); } }); // 设置播放按钮宽度 playButton.style.width = liElement.clientWidth + 'px'; // 添加播放按钮到 LI 元素 liElement.appendChild(playButton); }); }); // 弹框显示函数 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); alert('登录成功,请尽情享受您的观影时间!'); } else { if (responseData.message == "账户已过期,请重新购买") { closeLoginBox(); GM_setValue("YTToken", ""); 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); } }); } }); })();