Skip to content

Instantly share code, notes, and snippets.

@acgotaku
Last active April 26, 2023 04:00
Show Gist options
  • Save acgotaku/29d1fbe3dbf777c25254 to your computer and use it in GitHub Desktop.
Save acgotaku/29d1fbe3dbf777c25254 to your computer and use it in GitHub Desktop.
新版百度云盘aria2c导出下载 ,目前只实现了核心功能.
// ==UserScript==
// @name 百度网盘aria2导出工具
// @author acgotaku311
// @description 一个方便吧百度网盘的Aria2rpc导出的脚本。
// @encoding utf-8
// @include http://*n.baidu.com/s/*
// @include http://*n.baidu.com/disk/home*
// @include http://*n.baidu.com/share/link*
// @include https://*n.baidu.com/s/*
// @include https://*n.baidu.com/disk/home*
// @include https://*n.baidu.com/share/link*
// @run-at document-end
// @version 0.0.1
// ==/UserScript==
var version = "0.0.1";
var thedate_update = "2014/07/01";
var baidupan = (function() {
var SetMessage = function(msg, type) {
var Toast = require("common:widget/toast/toast.js");
Toast.obtain.useToast({
toastMode: Toast.obtain[type],
msg: msg,
sticky: false
});
}
var combination = {
header: function() {
var addheader = [];
var UA="netdisk;4.4.0.6;PC;PC-Windows;6.2.9200;WindowsBaiduYunGuanJia";
var cookies = "BDUSS=WlGQTBqenNHMnU4cmQzcFd0T3hjOTlXQ2tYRUNLYkszZ2pXSkFESzNUTS1wNFpUQVFBQUFBJCQAAAAAAAAAAAEAAADGtAcR0anUwsfvy64AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4aX1M-Gl9TT";
addheader.push("User-Agent: " + UA);
addheader.push("Cookie: " + cookies);
return addheader;
}
};
var url="http://localhost:6800/jsonrpc"+"?tm="+(new Date().getTime().toString())
return {
init: function() {
var self = this;
var aria2_btn = $("<a>").addClass("icon-btn-download").text("RPC下载");
$(".icon-btn-device").after(aria2_btn);
aria2_btn.click(function() {
self.get_dlink();
});
SetMessage("初始化成功!", "MODE_SUCCESS");
},
get_info: function() {
var File = require("common:widget/data-center/data-center.js");
return File.get("selectedList");
},
get_config: function() {
},
get_dlink: function() {
var self = this;
var Service = require("common:widget/commonService/commonService.js");
Service.getDlink(JSON.stringify(self.get_info()), "dlink", self.aria2_rpc.bind(self));
},
aria2_rpc: function(data) {
var self=this;
var obj = $.parseJSON(data);
var length = obj.dlink.length;
for (var i = 0; i < length; i++) {
var rpc_data = [{
"jsonrpc": "2.0",
"method": "aria2.addUri",
"id": new Date().getTime(),
"params": [[obj.dlink[i].dlink], {
// "out": name,
"header": combination.header()
}
]
}];
self.aria2send_data(rpc_data);
}
},
aria2send_data: function(data) {
$.ajax({'url': url, 'dataType': 'json',type:'POST',data:JSON.stringify(data)})
.done(function(xml, textStatus, jqXHR) {
SetMessage("下载成功!赶紧去看看吧~", "MODE_SUCCESS");
})
.fail(function(jqXHR, textStatus, errorThrown) {
SetMessage("下载失败!是不是没有开启aria2?", "MODE_FAILURE");
});
}
}
})();
baidupan.init();
@zelda0079
Copy link

这是用在tampermonkey???
作者也辛苦了

@songxing10000
Copy link

期待,使用教程,辛苦了,大侠

@FradSer
Copy link

FradSer commented Apr 9, 2018

好想不能工作了,我我看看能不能修好

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment