|
1 | 1 | // ==UserScript==
|
2 | 2 | // @name Study163FreeLess ADown
|
3 | 3 | // @namespace https://www.cnblogs.com/Chary/
|
4 |
| -// @version 2019.06.24 |
| 4 | +// @version 2019.06.25 |
5 | 5 | // @description add download button on study.163.com Html Header to download videos
|
6 | 6 | // @author CharyGao
|
7 | 7 | // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
|
8 | 8 | // @require https://cdn.bootcss.com/crypto-js/3.1.9-1/crypto-js.min.js
|
9 | 9 | // @match https://study.163.com/course/courseMain.htm?*courseId=*
|
| 10 | +// @match https://study.163.com/course/introduction.htm?*courseId=* |
10 | 11 | // @grant unsafeWindow
|
11 | 12 | // @grant GM_getValue
|
12 | 13 | // @grant GM_setValue
|
|
56 | 57 | // 添加下载按钮
|
57 | 58 | function addDownloadButton() {
|
58 | 59 | var ksbtn = document.getElementsByClassName('ksbtn')[0];
|
| 60 | + if (ksbtn === undefined) { |
| 61 | + return; |
| 62 | + } |
59 | 63 | var ksbtn_style = 'display:' + getStyle(ksbtn, 'display') + ';width:' + getStyle(ksbtn, 'width') + ';background-position:' + getStyle(ksbtn, 'background-position') + ';margin-top:' + getStyle(ksbtn, 'margin-top') + ';';
|
60 | 64 | var ksbtn_span = ksbtn.firstChild;
|
61 | 65 | var ksbtn_span_style = 'display:' + getStyle(ksbtn_span, 'display') + ';text-align:' + getStyle(ksbtn_span, 'text-align') + ';background:' + getStyle(ksbtn_span, 'background') +
|
|
386 | 390 | async: true,
|
387 | 391 | data: params,
|
388 | 392 | success: function(response) {
|
389 |
| - var signature = response.match(/signature="(\w+?)";/)[1]; |
| 393 | + var responseSignatures = response.match(/signature="(\w+?)";/); |
| 394 | + if (responseSignatures == null || responseSignatures.length < 1) { |
| 395 | + return; |
| 396 | + } |
| 397 | + var signature = responseSignatures[1]; |
| 398 | + // var signature = response.match(/signature="(\w+?)";/)[1]; |
390 | 399 | var videoId = response.match(/videoId=(\w+?);/)[1];
|
391 | 400 | //mylog(file_name, response);
|
392 | 401 | getVideoUrl(videoId, signature, file_name, save_path);
|
|
0 commit comments