-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRutorrent GetMulitpleTorrents.user.js
62 lines (51 loc) · 1.81 KB
/
Rutorrent GetMulitpleTorrents.user.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
// ==UserScript==
// https://github.com/hannsen/userscripts
// @name Rutorrent GetMulitpleTorrents
// @namespace rutorrent
// @description gets multiple torrents which you select in rutorrent
// @include http://*ruTorrent*
// @include https://*ruTorrent*
// @version 3.1
// @grant none
// @downloadURL https://github.com/hannsen/userscripts/raw/master/Rutorrent%20GetMulitpleTorrents.user.js
// @updateURL https://github.com/hannsen/userscripts/raw/master/Rutorrent%20GetMulitpleTorrents.user.js
// ==/UserScript==
const nav_bar = document.getElementById("t");
const unfoldLink = document.createElement('a');
const newHTML = document.createElement('div');
newHTML.id = 'moved';
unfoldLink.appendChild(newHTML);
unfoldLink.id = 'grab';
unfoldLink.title = 'Download selected torrent files';
unfoldLink.href = 'javascript:void(0)';
if (nav_bar) {
nav_bar.appendChild(unfoldLink);
document.getElementById('grab').addEventListener('click', getTorrents, false);
}
function getTorrents() {
const selected = document.getElementsByClassName("selected");
let dl_link = 'plugins/source/action.php';
if ('/' != window.location.toString().slice(-1)) {
dl_link = '/' + dl_link;
}
function downloadTorrent(hash) {
const form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", dl_link);
form.setAttribute("target", "_blank");
const input = document.createElement("input");
input.type = "hidden";
input.name = "hash";
input.value = hash;
form.appendChild(input);
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
}
for (let i = 0; i < (selected.length - 1); i++) {
let hash = selected[i].id;
if (hash && hash.match(/[A-F0-9]{40}/i)) {
downloadTorrent(hash);
}
}
}