Skip to content

Commit faf61f3

Browse files
flatmapthatshithannsen
authored and
hannsen
committed
Fix GetMulitpleTorrents.user.js to work with v3.9
In order to make the script work with ruTorrent v3.9 I had to convert from simple GET to POST requests
1 parent 9f121dd commit faf61f3

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

Rutorrent GetMulitpleTorrents.user.js

+28-9
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
// @description gets multiple torrents which you select in rutorrent
66
// @include http://*ruTorrent*
77
// @include https://*ruTorrent*
8-
// @version 3.0
8+
// @version 3.1
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
1212
// ==/UserScript==
1313

14-
var nav_bar = document.getElementById("t");
14+
const nav_bar = document.getElementById("t");
1515

16-
var unfoldLink = document.createElement('a');
17-
var newHTML = document.createElement('div');
16+
const unfoldLink = document.createElement('a');
17+
const newHTML = document.createElement('div');
1818
newHTML.id = 'moved';
1919
unfoldLink.appendChild(newHTML);
2020
unfoldLink.id = 'grab';
@@ -27,17 +27,36 @@ if (nav_bar) {
2727
}
2828

2929
function getTorrents() {
30-
var selected = document.getElementsByClassName("selected");
31-
var dl_link = 'plugins/source/action.php?hash=';
30+
const selected = document.getElementsByClassName("selected");
31+
let dl_link = 'plugins/source/action.php';
3232

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

37-
for (var i = 0; i < (selected.length - 1); i++) {
38-
var hash = selected[i].id;
37+
function downloadTorrent(hash) {
38+
const form = document.createElement("form");
39+
form.setAttribute("method", "post");
40+
form.setAttribute("action", dl_link);
41+
form.setAttribute("target", "_blank");
42+
43+
const input = document.createElement("input");
44+
input.type = "hidden";
45+
input.name = "hash";
46+
input.value = hash;
47+
form.appendChild(input);
48+
49+
document.body.appendChild(form);
50+
51+
form.submit();
52+
53+
document.body.removeChild(form);
54+
}
55+
56+
for (let i = 0; i < (selected.length - 1); i++) {
57+
let hash = selected[i].id;
3958
if (hash && hash.match(/[A-F0-9]{40}/i)) {
40-
window.open(window.location + dl_link + hash);
59+
downloadTorrent(hash);
4160
}
4261
}
4362
}

0 commit comments

Comments
 (0)