// ==UserScript== // @name 夸克云盘 // @namespace http://tampermonkey.net/ // @version 0.7 // @description 解除浏览器大文件下载,自定义提取码 // @author by小怪 // @match https://pan.quark.cn/s/* // @match https://pan.quark.cn/list* // @connect drive.quark.cn // @connect pan.quark.cn // @icon https://pan.quark.cn/favicon.ico // @require https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js // @run-at document-body // @grant unsafeWindow // @grant GM_xmlhttpRequest // @grant window.onurlchange // @downloadURL https://update.greasyfork.icu/scripts/448602/%E5%A4%B8%E5%85%8B%E4%BA%91%E7%9B%98.user.js // @updateURL https://update.greasyfork.icu/scripts/448602/%E5%A4%B8%E5%85%8B%E4%BA%91%E7%9B%98.meta.js // ==/UserScript== (function() { 'use strict'; unsafeWindow = unsafeWindow || window; var $ = $ || window.$; var quark = { file:[] }; class XMLHttp { request_m = function (param) {}; response_m = function (param) {}; request_s = function (param) {}; response_s = function (param) {}; } let http = new XMLHttp(); //分享页面 quark.sharePage=function(){ // XMLHttpRequest 拦截 http.request_s = function (param) { //console.log(param, "---request"); // if (res.config.url.includes("file/sort")) { // console.log(JSON.parse(res.response)); //} }; http.response_s = function (res) { //console.log(res, "---response"); //文件详情 if (res.config.url!=null&&res.config.url.includes("share/sharepage/detail")) { console.log(JSON.parse(res.response)); // quark.download('94a968da04694fb6aa25fb0e214a7767',function(result){ // console.log('下载---',result); // }); // quark.play('94a968da04694fb6aa25fb0e214a7767',function(result){ // console.log('获取视频---',result); // }); } } // 初始化 XMLHttpRequest quark.initXMLHttpRequest_s(); } //主页面 quark.mainPage=function(){ //监听 // XMLHttpRequest 拦截 http.request_m = function (param) { console.log(param, "---request"); // if (res.config.url.includes("file/sort")) { // console.log(JSON.parse(res.response)); //} }; http.response_m = function (res) { console.log(res, "---response"); //获取列表 if (res.config.url!=null&&res.config.url.includes("file/sort")) { console.log(JSON.parse(res.response)); quark.mainList(JSON.parse(res.response)); } //判断分享码是否一样 if (res.config.url!=null&&res.config.url.includes("/share/password?pr=ucpro&fr=pc")) { var share_pwd = localStorage.getItem("share_pwd"); if (share_pwd!=null&&JSON.parse(res.response).data.passcode == share_pwd) { quark.showTipSuccess("自定义分享密码 成功"); } else { localStorage.removeItem("share_pwd"); quark.showTipError("自定义分享密码 失败,请修改分享密码后重试"); } } } // 初始化 XMLHttpRequest quark.initXMLHttpRequest_m(); } //获取列表 quark.mainList=function(result){ //获取每个下载地址 let arr=[]; for(let i=0; i '+result[i].download_url+' '; } html_model_list+=''; $(document.body).append(html_model_list); }); }); //关闭列表 $(document).on("click", "#close-list", function () { $("#model-list").remove(); }); }; //下载 quark.download = function (fids,callback) { GM_xmlhttpRequest({ method: "POST", url: "https://drive.quark.cn/1/clouddrive/file/download?pr=ucpro&fr=pc", headers: { "Content-Type": "application/json;charset=utf-8" }, data: JSON.stringify({"fids": fids}), onload: function (res) { let resData = JSON.parse(res.responseText).data; if (resData === undefined || resData.length === 0) { //失败 quark.showTipError("获取列表失败!"); callback(""); } else { //成功 quark.showTipSuccess("获取列表成功!"); } callback(resData); //cosnole.log(o.download_url); } }); }; //视频地址 quark.play = function (fids,callback) { GM_xmlhttpRequest({ method: "POST", url: "https://drive.quark.cn/1/clouddrive/file/v2/play?pr=ucpro&fr=pc", headers: { "Content-Type": "application/json;charset=utf-8" }, data: JSON.stringify({"fid":fids,"resolutions":"normal,low,high,super,2k,4k","supports":"fmp4"}), onload: function (res) { let resData = JSON.parse(res.responseText).data; if (resData === undefined || resData.length === 0) { //失败 quark.showTipError("获取视频失败!"); callback(""); } else { //成功 quark.showTipSuccess("获取视频成功!"); } callback(resData); //cosnole.log(o.download_url); } }); }; //获取Storage quark.getItem = function(n) { n = window.localStorage.getItem(n)|| sessionStorage.getItem(n);; if (!n) { return null; } try { return JSON.parse(n); } catch (e) { return n; } }; //自定义提取码 //url_type=1 是没有提取码 2是提取码 // quark.customSharePwd=function(){ //监听 $(document).on("DOMNodeInserted", ".ant-modal-root", function() { var text = $(this).find(".ant-modal-title").text(); if (text == "分享文件") { if ($(".input-share-pwd").length == 0) { var sharePwd = localStorage.getItem("share_pwd"); var html = '
自定义提取码'; //html += '
' html+=''; $(".create-share-body").append(html); sendSharePwd(); } } }); //判断获取的值 function sendSharePwd () { (function(send) { XMLHttpRequest.prototype.send = function() { if (arguments.length && typeof arguments[0] == "string" && arguments[0].includes("fid_list")) { var share_pwd = localStorage.getItem("share_pwd"); if (share_pwd) { var body = JSON.parse(arguments[0]); body.passcode = share_pwd; arguments[0] = JSON.stringify(body); } } send.apply(this, arguments); }; })(XMLHttpRequest.prototype.send); } //获取修改的值 $(document).on("change", ".input-share-pwd", function () { var value = this.value; localStorage.setItem("share_pwd", value); }); }; //提示成功 quark.showTipSuccess = function (msg, timeout) { quark.hideTip(); var $element = $(".ant-message"); if ($element.length) { $element.html('
'+msg+'
'); } else { $(document.body).append('
' + msg + '
'); } setTimeout(function () { quark.hideTip(); }, timeout || 3000); }; //提示失败 quark.showTipError = function (msg, timeout) { quark.hideTip(); var $element = $(".ant-message"); if ($element.length) { $element.html('
'+msg+'
'); } else { $(document.body).append('
'+msg+'
'); } setTimeout(function () { quark.hideTip() }, timeout || 3000); }; //隐藏 quark.hideTip = function() { $(".ant-message").html(''); }; // 初始化 拦截XMLHttpRequest 主页面 quark.initXMLHttpRequest_m= function() { let open = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function(...args){ let send = this.send; let _this = this let post_data = [] this.send = function (...data) { post_data = data; return send.apply(_this, data) } // 请求前拦截 http.request_m(args) this.addEventListener('readystatechange', function () { if (this.readyState === 4) { let config = { url: args[1], status: this.status, method: args[0], data: post_data } // 请求后拦截 http.response_m({config, response: this.response}) } }, false) return open.apply(this, args); } }; //分享页面 quark.initXMLHttpRequest_s= function() { let open = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function(...args){ let send = this.send; let _this = this let post_data = [] this.send = function (...data) { post_data = data; return send.apply(_this, data) } // 请求前拦截 http.request_s(args) this.addEventListener('readystatechange', function () { if (this.readyState === 4) { let config = { url: args[1], status: this.status, method: args[0], data: post_data } // 请求后拦截 http.response_s({config, response: this.response}) } }, false) return open.apply(this, args); } } //初始化 quark.install= function () { var url = location.href; if (url.indexOf(".quark.cn/s/") > 0) { //分享页面初始化 quark.sharePage(); quark.showTipSuccess("夸克云盘插件初始化成功!"); } else if (url.indexOf(".quark.cn/list") > 0) { // debugger //主页面初始化 quark.customSharePwd(); quark.showTipSuccess("夸克云盘插件初始化成功!"); quark.mainPage(); } }(); // Your code here... })();