forked from gxvv/ex-baiduyunpan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EX-baiduyunpan.mock.js
83 lines (77 loc) · 2.89 KB
/
EX-baiduyunpan.mock.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// ==UserScript==
// @name EX-百度云盘-mock
// @namespace https://github.com/gxvv/ex-baiduyunpan/
// @version 0.2.0
// @description ex-baiduyunpan-mock
// @author gxvv
// @license MIT
// @match *://pan.baidu.com/disk/home*
// @match *://yun.baidu.com/disk/home*
// @match *://pan.baidu.com/s/*
// @match *://yun.baidu.com/s/*
// @match *://pan.baidu.com/share/link?*
// @match *://yun.baidu.com/share/link?*
// @match *://eyun.baidu.com/s/*
// @match *://eyun.baidu.com/enterprise/*
// @run-at document-end
// @grant unsafeWindow
// ==/UserScript==
(function(require) {
'use strict';
var script = unsafeWindow.document.createElement('script');
script.setAttribute('src', 'https://cdn.bootcss.com/Mock.js/1.0.0/mock-min.js');
unsafeWindow.document.body.appendChild(script);
script.onload = function() {
init(unsafeWindow.Mock);
};
function init(Mock) {
Mock.mock(/\/api\/download/, function(opts) {
console.log(opts);
if (/type=batch/.test(opts.body)) {
return {
"errno": 0,
"request_id": 1638728891788015501,
"dlink": "batch-https:\/\/www.baidupcs.com\/rest\/2.0\/pcs\/file?xxxx"
};
} else if (/type=nolimit/.test(opts.body)) {
return {
"errno": 0,
"request_id": 1638807446155143968,
"dlink": [{
"fs_id": "585382316377758",
"dlink": "nolimit-https:\/\/d.pcs.baidu.com\/file\/xxxx"
}, {
"fs_id": "719329425382101",
"dlink": "nolimit-https:\/\/d.pcs.baidu.com\/file\/xxxx"
}]
};
}
return {errno: -1};
});
Mock.mock(/\/api\/sharedownload/, function(opts) {
console.log(opts);
if (/type=batch/.test(opts.body)) {
return {
"errno": 0,
"request_id": 1638867848412003560,
"server_time": 1520841258,
"dlink": "batch-https:\/\/www.baidupcs.com\/rest\/2.0\/pcs\/file?xxxx"
};
}
return {
"errno": 0,
"request_id": 1638837700730131957,
"server_time": 1520841146,
"list": [{
"fs_id": 168192872164822,
"server_filename": "\u6559\u7236BD\u53cc\u8bed\u53cc\u5b57.mkv",
"size": 3311639424,
"isdir": 0,
"category": 1,
"share": "0",
"dlink": "nolimit-https:\/\/d.pcs.baidu.com\/file\/xxxxx",
}]
};
});
}
})(unsafeWindow.require);