-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathbutton.user.js
232 lines (218 loc) · 9.23 KB
/
button.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
// ==UserScript==
// @name What.cd Whatauto link creator
// @namespace test.com
// @author blubbablubb
// @description Userscript to add a download button next to the torrent on the following sites.
// @include http*://*what.cd/*
// @include http*://*broadcasthe.net/*
// @include http*://*fux0r.eu/*
// @include http*://*passthepopcorn.me/*
// @include http*://*tehconnection.eu/*
// @include https://*waffles.ch/*
// @include http*://*hdbits.org/*
// @include http*://*bitmetv.org/*
// @include http*://*sceneaccess.eu/*
// @include http*://*awesome-hd.me/*
// @include http*://*bit-hdtv.com/*
// @include http*://*x264.me/*
// @include http*://*gazellegames.net/*
// @include http*://*redacted.ch/*
// @include http*://*apollo.rip/*
// @include http*://*morethan.tv/*
// @include http*://*notwhat.cd/*
// @version 0.0.22
// @date 2014-17-11
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_notification
// ==/UserScript==
// EDIT THE FOLLOWING LINE WITH YOUR HOST (OR IP) + PORT WHICH YOU HAVE SELECTED IN setup.conf IN pyWHATAUTO
var weblink = 'http://example.com:1337/dl.pywa?pass=youwouldliketoknowthisone';
if (/https?.*?notwhat\.cd.*/.test(document.URL)) {
var linkregex = /torrents\.php\?action=download.*?id=(\d+).*?authkey=.*?torrent_pass=(?=([a-z0-9]+))\2(?!&)/i;
var devider = ' | ';
var site = "notwhat";
} else if (/https?.*?broadcasthe\.net.*/.test(document.URL)) {
var linkregex = /torrents\.php\?action=download.*?id=(\d+).*?authkey=.*?torrent_pass=(?=([a-z0-9]+))\2(?!&)/i;
var divider = ' | ';
var site = "broadcasthenet";
} else if (/https?.*?fux0r\.eu.*/.test(document.URL)) {
var linkregex = /torrents.php\?action=download.*?id=(\d+).*?/i;
var divider = ' : ';
var site = "fux0r";
} else if (/https?.*?passthepopcorn\.me.*/.test(document.URL)) {
var linkregex = /torrents\.php\?action=download.*?id=(\d+).*?authkey=.*?torrent_pass=(?=([a-z0-9]+))\2(?!&)/i;
var divider = ' | ';
var site = "passthepopcorn";
} else if (/https?.*?tehconnection\.eu.*/.test(document.URL)) {
var linkregex = /torrents\.php\?action=download.*?id=(\d+).*?authkey=.*?torrent_pass=(?=([a-z0-9]+))\2(?!&)/i;
var divider = ' | ';
var site = "tehconnection";
} else if (/https?.*?waffles\.ch.*/.test(document.URL)) {
var linkregex = /.*?download.php\/\d+\/(\d+)\/(.*?)\.torrent\?passkey.*/i;
var divider = ' | ';
var site = "waffles";
var includename = "2";
} else if (/https?.*?hdbits\.org.*/.test(document.URL)) {
var linkregex = /download.php\?id=(\d+).*/i;
var divider = ' | ';
var site = "hdbits";
// var includename = "2";
} else if (/https?.*?bitmetv\.org.*/.test(document.URL)) {
var linkregex = /.*?download.php\/(\d+)\/(.*?)\.torrent$/i;
var divider = ' | ';
var site = "bitmetv";
var includename = "2";
} else if (/https?.*?sceneaccess\.eu.*/.test(document.URL)) {
var linkregex = /downloadbig.php\?id=(\d+).*?/i;
var divider = ' | ';
var site = "sceneaccess";
} else if (/https?.*?awesome-hd\.me.*/.test(document.URL)) {
var linkregex = /torrents.php\?action=download.*?id=(\d+).*?/i;
var divider = ' | ';
var site = "awesomehd";
} else if (/https?.*?bit-hdtv\.com.*/.test(document.URL)) {
var linkregex = /.*?download.php\/(\d+)\/(.*?)\.torrent.*/i;
var divider = ' | ';
var site = "bithdtv";
var includename = "2";
} else if (/https?.*?x264\.me.*/.test(document.URL)) {
var linkregex = /.*?download.php\/(\d+)\/(.*?)\.torrent.*/i;
var divider = ' | ';
var site = "bithdtv";
var includename = "2";
} else if (/https?.*?gazellegames\.net.*/.test(document.URL)) {
var linkregex = /torrents\.php\?action=download.*?id=(\d+).*?authkey=.*?torrent_pass=(?=([a-z0-9]+))\2(?!&)/i;
var divider = ' | ';
var site = "gazellegames";
} else if (/https?.*?redacted\.ch.*/.test(document.URL)) {
var linkregex = /torrents\.php\?action=download.*?id=(\d+).*?authkey=.*?torrent_pass=(?=([a-z0-9]+))\2(?!&)/i;
var divider = ' | ';
var site = "redacted";
} else if (/https?.*?apollo\.rip.*/.test(document.URL)) {
var linkregex = /torrents\.php\?action=download.*?id=(\d+).*?authkey=.*?torrent_pass=(?=([a-z0-9]+))\2(?!&)/i;
var divider = ' | ';
var site = "apollo";
} else if (/https?.*?morethan\.tv.*/.test(document.URL)) {
var linkregex = /torrents\.php\?action=download.*?id=(\d+).*?authkey=.*?torrent_pass=(?=([a-z0-9]+))\2(?!&)/i;
var devider = ' | ';
var site = "morethantv";
} else if (/https?.*?what\.cd.*/.test(document.URL)) {
var linkregex = /torrents.php\?action=download.*?id=(\d+).*/i;
var divider = ' | ';
var site = "whatcd";
} else {
alert("You have found a bug. Go and tell blubba!");
}
var settings = getSettings();
var settingsPage = window.location.href.match('user.php\\?action=edit&userid=');
var top10Page = window.location.href.match('top10.php');
var linkLabel = "pWA";
if (top10Page) {
linkLabel = "[" + linkLabel + "]";
}
if ((settings.pass && settings.url && settings.port) || checkWeblink()) {
alltorrents = [];
for (var i = 0; i < document.links.length; i++) {
alltorrents.push(document.links[i]);
}
for (var i = 0; i < alltorrents.length; i++) {
if (linkregex.exec(alltorrents[i])) {
if (includename == 1) {
id = RegExp.$2;
name = RegExp.$1;
} else if (includename == 2) {
id = RegExp.$1;
name = RegExp.$2;
} else {
id = RegExp.$1;
}
createLink(alltorrents[i], id, name);
}
}
}
if (settingsPage) {
appendSettings();
document.getElementById('pywhatauto_settings_pass').addEventListener('change', saveSettings, false);
document.getElementById('pywhatauto_settings_url').addEventListener('change', saveSettings, false);
document.getElementById('pywhatauto_settings_port').addEventListener('change', saveSettings, false);
}
if (!settings && !settingsPage && !checkWeblink()) {
GM_notification({
text: 'Missing configuration\nVisit user settings page on gazelle site or edit weblink line at the top of script to configure',
title: 'pyWHATauto:',
timeout: 10000,
});
}
function createLink(linkelement, id, name) {
var link = document.createElement("pyWA");
link.appendChild(document.createElement("a"));
link.firstChild.appendChild(document.createTextNode(linkLabel));
link.appendChild(document.createTextNode(divider));
if (name) {
if(checkWeblink()) {
link.firstChild.href=weblink+"&name="+name+"&site="+site+"&id="+id;
} else {
link.firstChild.href = settings.url + ":" + settings.port + "/dl.pywa?pass=" + settings.pass + "&name=" + name + "&site=" + site + "&id=" + id;
}
} else {
if(checkWeblink()) {
link.firstChild.href=weblink+"&site="+site+"&id="+id;
} else {
link.firstChild.href = settings.url + ":" + settings.port + "/dl.pywa?pass=" + settings.pass + "&site=" + site + "&id=" + id;
}
}
link.firstChild.target = "_blank";
link.firstChild.title = "Direct download to pyWHATauto";
linkelement.parentNode.insertBefore(link, linkelement);
}
function appendSettings() {
var container = document.getElementsByClassName('main_column')[0];
var lastTable = container.lastElementChild;
var settingsHTML = '<a name="pywhatauto_settings"></a>\n<table cellpadding="6" cellspacing="1" border="0" width="100%" class="layout border user_options" id="pywhatauto_settings">\n';
settingsHTML += '<tbody>\n<tr class="colhead_dark"><td colspan="2"><strong>pyWHATauto Settings (autosaved)</strong></td></tr>\n';
settingsHTML += '<tr><td class="label" title="Password">Password</td><td><input type="text" id="pywhatauto_settings_pass" placeholder="insert_your_pass" value="' + GM_getValue('pass', '') + '"></td></tr>\n';
settingsHTML += '<tr><td class="label" title="Your seedbox hostname set in pywhatauto">Hostname</td><td><input type="text" id="pywhatauto_settings_url" placeholder="http://hostname.com" value="' + GM_getValue('url', '') + '"></td></tr>\n';
settingsHTML += '<tr><td class="label" title="Your seedbox port set in pywhatauto">Port</td><td><input type="text" id="pywhatauto_settings_port" placeholder="your_chosen_port" value="' + GM_getValue('port', '') + '"></td></tr>\n';
settingsHTML += '</tbody>\n</table>';
lastTable.insertAdjacentHTML('afterend', settingsHTML);
var sectionsElem = document.querySelectorAll('#settings_sections > ul')[0];
sectionsHTML = '<h2><a href="#pywhatauto_settings" class="tooltip" title="pyWHATauto Settings">pyWHATauto</a></h2>';
var li = document.createElement('li');
li.innerHTML = sectionsHTML;
sectionsElem.insertBefore(li, document.querySelectorAll('#settings_sections > ul > li:nth-child(10)')[0]);
}
function getSettings() {
var pass = GM_getValue('pass', '');
var port = GM_getValue('port', '');
var url = GM_getValue('url', '');
if (pass && url && port) {
return {
pass: pass,
url: url,
port: port
};
} else {
return false;
}
}
function saveSettings() {
var elem = document.getElementById(this.id);
var setting = this.id.replace('pywhatauto_settings_', '');
var border = elem.style.border;
GM_setValue(setting, elem.value);
if (GM_getValue(setting) === elem.value) {
elem.style.border = '1px solid green';
setTimeout(function () {
elem.style.border = border;
}, 2000);
} else {
elem.style.border = '1px solid red';
}
}
function checkWeblink() {
if(weblink && weblink !== 'http://example.com:1337/dl.pywa?pass=youwouldliketoknowthisone'){
return true;
}
return false;
}