-
Notifications
You must be signed in to change notification settings - Fork 21
/
PtpUploaderTorrentSender.user.js
288 lines (246 loc) · 13.7 KB
/
PtpUploaderTorrentSender.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
// ==UserScript==
// @name PtpUploader Torrent Sender
// @author TnS
// @description Creates a send to PtpUploader link on the torrent details page.
// @homepage http://userscripts.org/scripts/show/133847
// @version 1.08
// @date 2017-09-20
// @namespace http://greasemonkey.mozdev.com
// @include http*://*torviet.com/*
// @include https://*alpharatio.cc/torrents.php?id=*
// @include http*://*awesome-hd.me/torrents.php*
// @include http*://*bit-hdtv.com/details.php*
// @include http*://*chdbits.org/details.php*
// @include http*://*cinemageddon.net/details.php*
// @include http*://*fuckyeahtorrents.com/details.php*
// @include http*://*hd-torrents.org/details.php*
// @include http*://*hdts.ru/details.php*
// @include http*://*hdahoy.net/torrents.php*
// @include http*://*hdbits.org/details.php*
// @include http*://*hdme.eu/details.php*
// @include http*://*iptorrents.com/details.php*
// @include http*://*iptorrents.me/details.php*
// @include http*://*iptorrents.ru/details.php*
// @include http*://*karagarga.in/details.php*
// @include http*://*piratethenet.org/details.php*
// @include http*://*pretome.info/details.php*
// @include http*://*tehconnection.eu/torrents.php*
// @include http*://*thegft.org/details.php*
// @include https://www.torrentbytes.net/details.php?id=
// @include http*://*torrentleech.org/torrent/*
// @include http*://*digitalhive.org/details.php*
// @include http*://*desitorrents.com/forums/*
// @include http*://*bollywoodtorrents.me/*
// @include http*://*hdwing.com/details.php*
// @include http*://*cinematik.net/details.php*
// @include http*://*horrorcharnel.kicks-ass.org/details.php*
// @include http*://*bitvaulttorrent.com/details.php*
// @include http*://*opensharing.org/torrent/*
// @include http*://*rarbg.to/*
// @include http*://*publichd.to/*
// @include http*://*extratorrent.cc/*
// @include http*://*hdaccess.net/*
// @include http*://*devilscore.org/*
// @include http*://*revolutiontt.me/*
// @include http*://*hon3yhd.com/*
// @include http*://*hdclub.org/*
// ==/UserScript==
// START OF SETTINGS
// Set the URL of your PtpUploader in the following link.
// E.g.: http://myhost.com:8000
var ptpUploaderUrl = "";
// The web.api_key set in your config.yml.
var ptpUploaderTorrentSenderPassword = "";
// Set this "true" (without the quotes) to open PTP and PtpUploader in a new tab, instead of the current tab
// when clicking on the PTP or the Up link.
var openPtpAndPtpUploaderInNewTab = false;
// END OF SETTINGS
function SendTorrentToPtpUploader(rawTorrentData, imdbUrl, sendToLink, sendPageContent) {
var uploadUrl = ptpUploaderUrl + "/ajax/create";
var formData = new FormData();
formData.append("password", ptpUploaderTorrentSenderPassword);
formData.append("torrent", rawTorrentData);
formData.append("imdbUrl", imdbUrl);
if (sendPageContent) {
formData.append("SourceUrl", window.location.href);
formData.append("PageContent", document.documentElement.innerHTML);
}
var xhr = new XMLHttpRequest();
xhr.onload = function (e) {
var showError = true;
var error = this.response;
if (this.status == 200) {
var jsonResponse = JSON.parse(this.response);
if (jsonResponse && jsonResponse.result) {
if (jsonResponse.result == "OK") {
showError = false;
sendToLink.innerHTML = "OK";
sendToLink.onclick = function () {
return false;
};
var editJobUrl = ptpUploaderUrl + "/job/" + jsonResponse.jobId + "/edit";
if (openPtpAndPtpUploaderInNewTab) window.open(editJobUrl);
else window.location = editJobUrl;
} else {
error = jsonResponse.message;
}
}
}
if (showError) alert("An error happened while trying to send the torrent to PtpUploader!\n\n" + error);
};
xhr.onerror = function () {
alert("An error happened while trying to send the torrent to PtpUploader!");
};
xhr.open("POST", uploadUrl, true);
xhr.send(formData);
}
function DownloadTorrent(downloadUrl, imdbUrl, sendToLink, sendPageContent) {
// Use XMLHttpRequest Level 2.
var xhr = new XMLHttpRequest();
xhr.open("GET", downloadUrl, true);
xhr.responseType = "arraybuffer"; // blob response type resulted in gzipped response on SCC...
xhr.onload = function (e) {
if (this.status == 200) {
var blob = new Blob([this.response], { type: "application/x-bittorrent" });
SendTorrentToPtpUploader(blob, imdbUrl, sendToLink, sendPageContent);
} else {
alert("An error happened while trying to download the torrent from the source site!\n\n" + this.response);
}
};
xhr.onerror = function () {
alert("An error happened while trying to download the torrent from the source site!");
};
xhr.send();
}
function CreateSendToPtpUploaderLink(downloadLinkElement, downloadUrl, imdbUrl, sendPageContent) {
var ptpLink = document.createElement("a");
ptpLink.title = "Check movie page on PTP";
ptpLink.innerHTML = "PTP";
ptpLink.href = "https://passthepopcorn.me/torrents.php?searchstr=" + imdbUrl;
if (openPtpAndPtpUploaderInNewTab) ptpLink.setAttribute("target", "_blank");
downloadLinkElement.parentNode.insertBefore(ptpLink, downloadLinkElement);
downloadLinkElement.parentNode.insertBefore(document.createTextNode(" | "), downloadLinkElement);
var sendToLink = document.createElement("a");
sendToLink.title = "Send to PtpUploader";
sendToLink.innerHTML = "Up";
sendToLink.href = "#";
sendToLink.onclick = function () {
DownloadTorrent(downloadUrl ? downloadUrl : downloadLinkElement.href, imdbUrl, sendToLink, sendPageContent);
return false;
};
downloadLinkElement.parentNode.insertBefore(sendToLink, downloadLinkElement);
downloadLinkElement.parentNode.insertBefore(document.createTextNode(" | "), downloadLinkElement);
}
// Make sure to get the correct IMDb link that is in the IMDB info section.
function IsCorrectAhdImdbUrl(urlNode) {
while (true) {
urlNode = urlNode.parentNode;
if (!urlNode) break;
if (urlNode.id && urlNode.id.indexOf("movieinfo_") != -1) return true;
}
return false;
}
// Links in the NFO are not linkified on some sites.
function GetNonLinkifiedImdbUrl() {
var match = document.body.innerHTML.match(/imdb\.com\/title\/tt\d+/);
return match ? match[0] : "";
}
function GetImdbUrl(urlNode, siteName) {
var url = urlNode.href;
if (/.*?imdb\.com.*?title.*?tt\d+.*/.test(url)) {
if (siteName == "ahd" && !IsCorrectAhdImdbUrl(urlNode)) return "";
// Handle urlencoded anonymized IMDb links too. E.g.: http://anonym.to/?http%3A%2F%2Fakas.imdb.com%2Ftitle%2Ftt0401729
url = decodeURIComponent(url);
// The first link is a trailer link on HDBits. Simply ignoring it would work too.
url = url.replace("/trailers", "");
return url;
}
return "";
}
function Main() {
var downloadLinkElement = null;
var downloadLinkRegEx = null;
var downloadUrl = null;
var siteName = null;
var imdbUrl = "";
var sendPageContent = false;
if (/https:\/\/.*?alpharatio\.cc\/torrents\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /torrents.php\?action=download.*?id=\d+.*$/;
else if (/https?:\/\/torviet\.com\/.*/.test(document.URL)) downloadLinkRegEx = /download.php\?id=\d+.*/;
else if (/https?:\/\/.*?awesome-hd\.me\/torrents\.php\?id=.*/.test(document.URL)) {
downloadLinkRegEx = /torrents.php\?action=download.*?id=\d+.*/;
siteName = "ahd";
} else if (/https?:\/\/.*?bitvaulttorrent\.com\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\/\d+\/.*/;
else if (/https?:\/\/.*?bit-hdtv\.com\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\?\/\d+\/.*/;
else if (/https?:\/\/.*?chdbits\.org\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\?id=\d+.*/;
else if (/https?:\/\/.*?hon3yhd\.com\/.*/.test(document.URL)) {
downloadLinkRegEx = /download.php\?id=.*/;
imdbUrl = GetNonLinkifiedImdbUrl();
} else if (/https?:\/\/.*?cinemageddon\.net\/details\.php\?id=.*/.test(document.URL)) {
downloadLinkRegEx = /download.php\?id=\d+.*/;
sendPageContent = true;
} else if (/https?:\/\/.*?fuckyeahtorrents\.com\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\?torrent=\d+.*/;
else if (/https?:\/\/.*?hd-torrents\.org\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\?id=.+/;
else if (/https?:\/\/.*?devilscore\.org\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\?id=.+/;
else if (/https?:\/\/.*?hdts\.ru\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\?id=.+/;
else if (/https?:\/\/.*?hdahoy\.net\/torrents\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /torrents.php\?action=download.*?id=\d+.*/;
else if (/https?:\/\/.*?hdbits\.org\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\/.*?\?id=\d+.*/;
else if (/https?:\/\/.*?hdaccess\.net\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\?torrent=\d+/;
else if (/https?:\/\/.*?hdme\.eu\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\?torrent=\d+.*/;
else if (/https?:\/\/.*?iptorrents\.(?:com|me|ru)\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\/\d+\/.*/;
else if (/https?:\/\/.*?karagarga\.in\/details\.php\?id=.*/.test(document.URL)) {
downloadLinkRegEx = /down.php\/\d+\/.*/;
sendPageContent = true;
} else if (/https?:\/\/.*?piratethenet\.org\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\?torrent=\d+.*/;
else if (/https?:\/\/.*?pretome\.info\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\/\d+\/.*/;
else if (/https?:\/\/.*?tehconnection\.eu\/torrents\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /torrents.php\?action=download.*?id=\d+.*/;
else if (/https:\/\/www.torrentbytes\.net\/details\.php\?id=.*/.test(document.URL)) {
downloadLinkRegEx = /download.php\?id=.*/;
imdbUrl = GetNonLinkifiedImdbUrl(); // The IMDb link uses a redirect, so we use the text.
} else if (/https?:\/\/.*?digitalhive\.org\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\?id=\d+.*/;
else if (/https?:\/\/.*?horrorcharnel.kicks-ass\.org\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\?torrent=\d+.*/;
else if (/https?:\/\/.*?cinematik\.net\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\?id=\d+.*/;
else if (/https?:\/\/.*?hdclub\.org\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\?id=\d+.*/;
else if (/https?:\/\/.*?hdwing\.com\/details\.php\?id=.*/.test(document.URL)) downloadLinkRegEx = /download.php\/\d+\/.*/;
else if (/https?:\/\/.*?opensharing\.org\/.*/.test(document.URL)) downloadLinkRegEx = /download\/\d+.*/;
else if (/https?:\/\/.*?rarbg\.to\/.*/.test(document.URL)) downloadLinkRegEx = /download.php\?id=\.*/;
else if (/https?:\/\/.*?publichd\.to\/.*/.test(document.URL)) downloadLinkRegEx = /torrent\/download\/.*/;
else if (/https?:\/\/.*?revolutiontt\.me\/.*/.test(document.URL)) downloadLinkRegEx = /download\.php\/.*/;
else if (/https?:\/\/.*extratorrent\.cc\/.*/.test(document.URL)) {
downloadLinkRegEx = /xt=urn:btih:\/(\w+)/;
var match = document.body.innerHTML.match(downloadLinkRegEx);
if (match) downloadUrl = "http://178.73.198.210/torrent/" + match[1] + ".torrent";
} else if (/https?:\/\/.*?thegft\.org\/details\.php\?id=.*/.test(document.URL)) {
downloadLinkRegEx = /download.php\?torrent=\d+.*/;
imdbUrl = GetNonLinkifiedImdbUrl(); // Links in the NFO are not linkified on GFT.
} else if (/https?:\/\/.*?bollywoodtorrents\.me\/.*/.test(document.URL)) {
downloadLinkRegEx = /attachmentid=(\d+)/;
var match = document.body.innerHTML.match(downloadLinkRegEx);
if (match) downloadUrl = window.location.protocol + "//" + window.location.host + "/attachment.php?" + match[0];
} else if (/https?:\/\/.*?desitorrents\.com\/.*/.test(document.URL)) {
downloadLinkRegEx = /attachment\.php\?.*/;
imdbUrl = GetNonLinkifiedImdbUrl();
} else if (/https?:\/\/.*?torrentleech\.org\/torrent\/.*/.test(document.URL)) {
downloadLinkElement = document.getElementById("downloadButton");
if (!downloadLinkElement) return;
var action = downloadLinkElement.parentNode.getAttribute("action");
if (!action) return;
downloadUrl = window.location.protocol + "//" + window.location.host + action;
}
if (!downloadLinkRegEx && !downloadLinkElement) return;
var allLinks = new Array();
for (var i = 0; i < document.links.length; ++i) {
var urlNode = document.links[i];
allLinks.push(urlNode);
if (imdbUrl.length <= 0) imdbUrl = GetImdbUrl(urlNode, siteName);
}
if (imdbUrl.length <= 0) return;
if (downloadLinkElement) {
CreateSendToPtpUploaderLink(downloadLinkElement, downloadUrl, imdbUrl, sendPageContent);
} else {
for (var i = 0; i < allLinks.length; ++i) {
var link = allLinks[i];
if (downloadLinkRegEx.test(link.href)) CreateSendToPtpUploaderLink(link, downloadUrl, imdbUrl, sendPageContent);
}
}
}
Main();