// ==UserScript== // @name 夸克云盘 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 支持下载 // @author 小怪 // @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 // @downloadURL none // ==/UserScript== (function() { 'use strict'; unsafeWindow = unsafeWindow || window; var $ = $ || window.$; var quark = { }; //分享页面 quark.sharePage=function(){ } //主页面 quark.mainPage=function(){ //监听 (function(open) { XMLHttpRequest.prototype.open = function() { if (!this._hooked) { this._hooked = true; setupHook(this); } open.apply(this, arguments); } })(XMLHttpRequest.prototype.open); function setupHook(xhr) { (function setup() { Object.defineProperty(xhr, "response", { get: function getter() { delete xhr.response; var responseURL = xhr.responseURL, response = xhr.response; if (responseURL.includes("file/sort") && response) { console.log(JSON.parse(response)); } setup(); return response; }, configurable: true }); })(); } //获取列表 // quark.mainList(); // console.log( quark.getItem("_share_args").value.stoken); } //获取列表 quark.mainList=function(){ var send = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.send = function(data) { this.addEventListener("load", function(event) { if (this.readyState == 4 && this.status == 200) { var response = this.response, responseURL = this.responseURL; if (responseURL.endsWith("file/sort")) { try { response = JSON.parse(response) } catch (error) { }; if (response instanceof Object) { console.log(JSON.parse(response)); } } } else if (this.readyState == 4 && this.status == 403) { if (obj.expires(this.responseURL) && obj.getItem("default_player") != "NativePlayer") { var media_num = (this.responseURL.match(/media-(\d+)\.ts/) || [])[1] || 0; if (media_num > 0 && obj.video_page.media_num != media_num) { obj.video_page.media_num = media_num; if (obj.getShareId()) { obj.get_share_link_video_preview_play_info(); } else { obj.get_video_preview_play_info(); } } } } }, false); send.apply(this, arguments); }; } //获取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); this.addEventListener("load", function() { if (this.readyState == 4 && this.status == 200) { var url = this.responseURL; if (url.includes("/share?pr=ucpro&fr=pc")) { if (this.response.passcode == share_pwd) { quark.showTipSuccess("自定义分享密码 成功"); } else { localStorage.removeItem("share_pwd"); quark.showTipError("自定义分享密码 失败,请修改分享密码后重试"); } } } }, false); } } 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) { console.log("存在"); $element.html('
'+msg+'
'); } else { console.log("不存在"); $(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(''); }; //初始化 quark.install= function () { quark.mainList(); console.log("夸克云盘插件初始化"); 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... })();