forked from ywzhaiqi/userscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
360yunpan.user.js
44 lines (38 loc) · 1.11 KB
/
360yunpan.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// ==UserScript==
// @name 360 云盘辅助
// @namespace https://github.com/ywzhaiqi/
// @version 0.1
// @description 批量离线
// @match http://c13.yunpan.360.cn/my*
// @grant none
// ==/UserScript==
$('#tbOffline')
.clone().attr('id', 'tbOffline-my').removeData('cn')
.find('span').text('批量离线')
.end()
.click(batchOfflineDown)
.insertAfter($('#tbOffline'))
// 批量离线
function batchOfflineDown() {
var data = prompt('填入要批量离线的网址');
if (data) {
var urls = data.split('\n').filter(function(r) { return r; });
run(urls);
}
function run(urls) {
var url = urls.shift();
if (!url) {
console.log('全部离线完成');
return;
}
Ajax.post("/offline/offlineDownload", {url: url}, function(data) {
var res = JSON.parse(data);
if (res.errno == 0) {
console.log('成功离线下载:', url);
run(urls);
} else {
console.log(res.errmsg, url);
}
});
}
}