Skip to content

Commit ff94311

Browse files
author
hannsen
authored
open all selected elements, if they match regex
1 parent f0cbe7c commit ff94311

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Rutorrent GetMulitpleTorrents.user.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// @description gets multiple torrents which you select in rutorrent
66
// @include http://*ruTorrent*
77
// @include https://*ruTorrent*
8-
// @version 2.9
8+
// @version 3.0
99
// @grant none
1010
// @downloadURL https://github.com/hannsen/userscripts/raw/master/Rutorrent%20GetMulitpleTorrents.user.js
1111
// @updateURL https://github.com/hannsen/userscripts/raw/master/Rutorrent%20GetMulitpleTorrents.user.js
@@ -14,27 +14,30 @@
1414
var nav_bar = document.getElementById("t");
1515

1616
var unfoldLink = document.createElement('a');
17-
var newHTML = document.createElement ('div');
17+
var newHTML = document.createElement('div');
1818
newHTML.id = 'moved';
1919
unfoldLink.appendChild(newHTML);
2020
unfoldLink.id = 'grab';
2121
unfoldLink.title = 'Download selected torrent files';
2222
unfoldLink.href = 'javascript:void(0)';
2323

24-
if(nav_bar){
24+
if (nav_bar) {
2525
nav_bar.appendChild(unfoldLink);
2626
document.getElementById('grab').addEventListener('click', getTorrents, false);
2727
}
2828

29-
function getTorrents(){
29+
function getTorrents() {
3030
var selected = document.getElementsByClassName("selected");
3131
var dl_link = 'plugins/source/action.php?hash=';
3232

33-
if('/' != window.location.toString().slice(-1)){
33+
if ('/' != window.location.toString().slice(-1)) {
3434
dl_link = '/' + dl_link;
3535
}
3636

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+
}
3942
}
4043
}

0 commit comments

Comments
 (0)