本帖最后由 JesseMccree 于 2022-8-22 19:27 编辑
夸克网盘对较大文件需要安装客户端才能下载,分享一个油猴脚本,使夸克网盘大文件可直接通过浏览器或搭配IDM下载
脚本地址:https://greasyfork.org/zh-CN/scripts/448675
注意:1.使用脚本需先保存到自己网盘内。2.无法直接下载整个文件夹。3.一次下载多个文件时浏览器可能会拦截弹窗,需要手动允许。
使用方法:
[Asm] 纯文本查看 复制代码 // ==UserScript==
// @name 夸克网盘直链下载
// @version 1.1
// @namespace https://pan.quark.cn/list
// @description 解除夸克网盘下载限制,直接在浏览器中下载
// @author Lingo Wang
// @license MIT
// @match https://pan.quark.cn/list*
// @icon https://www.google.com/s2/favicons?sz=64&domain=quark.cn
// @grant GM_xmlhttpRequest
// @grant GM_log
// @grant window.onurlchange
// ==/UserScript==
(function () {
'use strict';
GM_log('quark download is running.');
setInterval(gmMain, 250);
const fidAttrName = 'data-row-key';
function gmMain() {
const checkboxes = document.getElementsByClassName('ant-checkbox-input');
if (checkboxes === undefined || checkboxes.length <= 1) {
console.log('document element not loaded yet');
return;
}
// checkboxes.length > 1
console.log('document element loaded, start dealing download btn');
for (let i = 0; i < checkboxes.length; i++) {
checkboxes[i].addEventListener('change', (event) => {
if (event.currentTarget.checked) {
addDownloadBtnListener();
}
})
}
// flow download btn
addFlowDownloadBtnListener();
}
function addDownloadBtnListener() {
let downloadBtn = getDownloadBtn();
downloadBtn.replaceWith(downloadBtn.cloneNode(true)); // remove all event listener
downloadBtn = getDownloadBtn();
downloadBtn.addEventListener('click', () => {
let fids = getSelectedFids();
download(fids);
})
}
function addFlowDownloadBtnListener() {
for (const btn of getFlowDownloadBtns()) {
btn.replaceWith(btn.cloneNode(true)); // remove all event listener
}
for (const btn of getFlowDownloadBtns()) {
btn.addEventListener('click', () => {
const fid = btn.parentElement.parentElement.parentElement.parentElement.parentElement.getAttribute(fidAttrName);
download([fid]);
})
}
}
function download(fids) {
GM_xmlhttpRequest({
method: "POST",
url: "https://drive.quark.cn/1/clouddrive/file/download?pr=ucpro&fr=pc&ve=2.1.5",
headers: {
"Content-Type": "application/json;charset=utf-8"
},
data: JSON.stringify({"fids": fids}),
onload: function (res) {
console.log('get real download url, fids: %o, res: ', fids, res.responseText);
let resData = JSON.parse(res.responseText).data;
if (resData === undefined || resData.length === 0) {
console.log('error!, data is empty. request fids: ', fids);
alert('获取直链失败, 请尝试刷新页面!注意,文件夹不支持直链下载!')
return;
} else {
console.log('get real download url, size: ', resData.length)
}
resData.forEach(o => window.open(o.download_url));
}
});
}
function getDownloadBtn() {
let btnGroup = document.getElementsByClassName('ant-btn btn-file');
let downloadBtn;
for (let i = 0; i < btnGroup.length; i++) {
if ('下载' === btnGroup[i].firstElementChild.innerText) {
downloadBtn = btnGroup[i];
}
}
return downloadBtn;
}
function getFlowDownloadBtns() {
return document.getElementsByClassName('hover-oper-item hoitem-down');
}
function getSelectedFids() {
const checkboxes = document.getElementsByClassName('ant-checkbox-input');
let fids = [];
for (let i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
const fid = checkboxes[i].parentElement.parentElement.parentElement.parentElement.parentElement.getAttribute('data-row-key');
if (fid !== undefined && fid !== '') {
fids.push(fid);
}
}
}
return fids;
}
})(); |