|
5 | 5 | // @description gets multiple torrents which you select in rutorrent
|
6 | 6 | // @include http://*ruTorrent*
|
7 | 7 | // @include https://*ruTorrent*
|
8 |
| -// @version 2.9 |
| 8 | +// @version 3.0 |
9 | 9 | // @grant none
|
10 | 10 | // @downloadURL https://github.com/hannsen/userscripts/raw/master/Rutorrent%20GetMulitpleTorrents.user.js
|
11 | 11 | // @updateURL https://github.com/hannsen/userscripts/raw/master/Rutorrent%20GetMulitpleTorrents.user.js
|
|
14 | 14 | var nav_bar = document.getElementById("t");
|
15 | 15 |
|
16 | 16 | var unfoldLink = document.createElement('a');
|
17 |
| -var newHTML = document.createElement ('div'); |
| 17 | +var newHTML = document.createElement('div'); |
18 | 18 | newHTML.id = 'moved';
|
19 | 19 | unfoldLink.appendChild(newHTML);
|
20 | 20 | unfoldLink.id = 'grab';
|
21 | 21 | unfoldLink.title = 'Download selected torrent files';
|
22 | 22 | unfoldLink.href = 'javascript:void(0)';
|
23 | 23 |
|
24 |
| -if(nav_bar){ |
| 24 | +if (nav_bar) { |
25 | 25 | nav_bar.appendChild(unfoldLink);
|
26 | 26 | document.getElementById('grab').addEventListener('click', getTorrents, false);
|
27 | 27 | }
|
28 | 28 |
|
29 |
| -function getTorrents(){ |
| 29 | +function getTorrents() { |
30 | 30 | var selected = document.getElementsByClassName("selected");
|
31 | 31 | var dl_link = 'plugins/source/action.php?hash=';
|
32 | 32 |
|
33 |
| - if('/' != window.location.toString().slice(-1)){ |
| 33 | + if ('/' != window.location.toString().slice(-1)) { |
34 | 34 | dl_link = '/' + dl_link;
|
35 | 35 | }
|
36 | 36 |
|
37 |
| - for (var i=0;i<(selected.length-3);i++){ |
38 |
| - window.open(window.location + dl_link + selected[i].id); |
| 37 | + for (var i = 0; i < (selected.length - 1); i++) { |
| 38 | + var hash = selected[i].id; |
| 39 | + if (hash && hash.match(/[A-F0-9]{40}/i)) { |
| 40 | + window.open(window.location + dl_link + hash); |
| 41 | + } |
39 | 42 | }
|
40 | 43 | }
|
0 commit comments