// ==UserScript== // @name 百度网盘不限速下载-KDown🔥🔥🔥 // @namespace https://kdown.moiu.net // @description 一款百度云加速程序,加速永无止境,无视黑号 // @version 1.1 // @author KDown // @license AGPL-3.0 // @icon https://upload.moiu.net/MoTeam-CDN-img/logo.png // @resource https://cdn.staticfile.org/limonte-sweetalert2/11.7.1/sweetalert2.min.css // @require https://cdn.staticfile.org/limonte-sweetalert2/11.7.1/sweetalert2.all.min.js // @require https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js // @grant GM_xmlhttpRequest // @grant GM_addStyle // @grant GM_setClipboard // 确保此权限已被添加 // @match *://pan.baidu.com/* // @connect moiu.net // @connect staticfile.org // @connect baidu.com // @namespace https://www.xiaomo.me // ==/UserScript== (() => { if (window.location.pathname === "/disk/home") { window.location.replace("./main"); } AddElement(); function AddElement() { if (document.getElementById("KDown") === null) { const toolbar = document.querySelector("div.wp-s-agile-tool-bar__header"); if (toolbar) { const newButton = document.createElement("button"); newButton.id = "KDown"; newButton.className = "u-button nd-file-list-toolbar-action-item u-button--primary"; newButton.style.marginRight = "8px"; newButton.innerText = "KDown"; toolbar.prepend(newButton); const statusButton = document.createElement("button"); statusButton.id = "KDownStatus"; statusButton.className = "u-button nd-file-list-toolbar-action-item u-button--primary"; statusButton.style.marginRight = "8px"; statusButton.innerText = "KDown Status"; toolbar.prepend(statusButton); newButton.addEventListener("click", handleKDownClick); statusButton.addEventListener("click", handleKDownStatusClick); } else { setTimeout(AddElement, 100); } } } async function getBdsToken() { var htmlString = $("html").html(); var regex = /"bdstoken":"(\w+)"/; var match = regex.exec(htmlString); return match ? match[1] : null; } async function shareFiles(bdstoken, selectedIds, bdpassword) { return $.post("https://pan.baidu.com/share/set?channel=chunlei&bdstoken=" + bdstoken, { period: 1, pwd: bdpassword, eflag_disable: true, channel_list: "[]", schannel: 4, fid_list: JSON.stringify(selectedIds) }).then(response => response); } function getDownloadLinkFromApi(link, password) { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: "GET", url: `https://api-app-v2.moiu.net/api/app/v1/get_link?url=${encodeURIComponent(link)}&dir=/&password=${encodeURIComponent(password)}`, onload: function(response) { if (response.status >= 200 && response.status < 300) { const data = JSON.parse(response.responseText); resolve(data); } else { reject({ status: response.status, statusText: response.statusText }); } }, onerror: function(response) { reject({ status: response.status, statusText: "Network error" }); } }); }); } async function handleKDownClick() { let selectedElements = document.querySelectorAll(".wp-s-pan-table__body-row.mouse-choose-item.selected, .wp-s-file-grid-list__item.text-center.cursor-p.mouse-choose-item.is-checked, .wp-s-file-contain-list__item.text-center.cursor-p.mouse-choose-item.is-checked"); let selectedIds = Array.from(selectedElements).map(item => item.getAttribute("data-id")); if (selectedIds.length === 0) { Swal.fire("提示", "请选择一个文件", "info"); return; } const { value: password } = await Swal.fire({ title: '输入密码', input: 'password', inputLabel: '密码:CN.DuPan.Fun,防止刷流量狗', inputPlaceholder: '密码:CN.DuPan.Fun,防止刷流量狗', inputAttributes: { maxlength: 30, autocapitalize: 'off', autocorrect: 'off' } }); if (!password) { Swal.fire("提示", "需要密码来继续", "info"); return; } Swal.fire({ title: "正在获取下载链接...", onBeforeOpen: () => { Swal.showLoading(); } }); const bdstoken = await getBdsToken(); if (!bdstoken) { Swal.fire("错误", "无法获取bdstoken", "error"); return; } const bdpassword = "zzzz"; // 这个是分享密码,云端设的就是这个,不要乱改了 const shareResponse = await shareFiles(bdstoken, selectedIds, bdpassword); if (!shareResponse || !shareResponse.link) { Swal.update({ icon: 'error', title: '分享失败', text: '无法获取分享链接' }); return; } const apiResponse = await getDownloadLinkFromApi(shareResponse.link, password); if (apiResponse && apiResponse.dlink && apiResponse.server_filename) { Swal.update({ icon: 'success', title: '下载链接获取成功', html: ` 文件名: ${apiResponse.server_filename}
链接:
用户代理(UA): `, didOpen: () => { document.getElementById("copyButton").addEventListener("click", () => { GM_setClipboard(apiResponse.dlink, "text"); // 确保剪贴板API被正确调用 Swal.fire("已复制", "下载链接已复制到剪贴板", "success"); }); }, preConfirm: () => { return { dlink: apiResponse.dlink }; } }); } else { Swal.update({ icon: 'error', title: '错误', text: '无法获取下载链接' }); } } function handleKDownStatusClick() { // 相应的状态检查逻辑 Swal.fire("检查中...", "正在检查服务器状态,请稍候...", "info"); // 假设你有一个函数来检查状态 checkServerStatus().then(status => { Swal.fire("状态", `服务器状态: ${status}`, "info"); }); } // 你可以在这里添加 checkServerStatus 函数和其他可能需要的功能。 })();