This repository has been archived by the owner on Dec 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Torrentz.eu magnet and direct links.user.js
173 lines (162 loc) · 6.96 KB
/
Torrentz.eu magnet and direct links.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
// ==UserScript==
// @name Torrentz2 (dot) eu magnet link
// @namespace Torrentz2
// @description Adds direct download links to the pages on https://torrentz2.*. It uses the magnet URI scheme to provide a user friendly, faster way to access your favorite torrents.
// @match https://torrentz2.eu/*
// @match https://torrentz2.me/*
// @match https://torrentzwealmisr.onion/*
// @include https://torrentz.*
// @include https://torrentz2.*
// @grant GM_addStyle
// @updateURL https://github.com/netravnen/torrentz2-magnet-link/raw/master/Torrentz.eu%20magnet%20and%20direct%20links.user.js
// @downloadURL https://github.com/netravnen/torrentz2-magnet-link/raw/master/Torrentz.eu%20magnet%20and%20direct%20links.user.js
// @license CC-BY-SA-3.0; http://creativecommons.org/licenses/by-sa/3.0/
// @license BSD-3-Clause; https://opensource.org/licenses/BSD-3-Clause
// @contributionURL https://github.com/netravnen/torrentz2-magnet-link
// @supportURL https://github.com/netravnen/torrentz2-magnet-link
// @version 1.1.5
// ==/UserScript==
/*
## Changelog
- v1.1.4
- Fix dn to tr so trackers actually get added
- v1.1.3
- Forgot to replace ':' with '%3A'
- Forgot to replace '/' with '%2F'
- v1.1.2
- Updated @updateURL
- Updated @downloadURL
- v1.1.1
- Updated @updateURL
- Updated @downloadURL
- v1.1.0
- Removed all predefined trackers.
- Now only using the listed trackers listed for the individual torrent
- v1.0.15
- Added http tracker: explodie.org
- Added http tracker: mgtracker.org
- Added http tracker: t1.pow7.com
- Added http tracker: thetracker.org
- v1.0.14.3
- Changed updateURL and downloadURL BACK to openuserjs.org after fixing TOS compliance
- v1.0.14.2
- Added dual license BSD-3-Clause to be compliant with OpenUserJS TOS https://openuserjs.org/about/Terms-of-Service
- v1.0.14.1
- Changed updateURL and downloadURL to github.com raw link to script
- v1.0.14
- Added tracker: tracker2.indowebster.com
- v1.0.13
- Added tracker: exodus.desync.com
- Added tracker: tracker.pirateparty.gr
- Added tracker: oscar.reyesleon.xyz
- Added tracker: tracker.cyberia.is
- v1.0.12
- Fix: zer0day changed to .to top-domain
- v1.0.11
- Do not use pow7 tracker anymore
- Removed http protocol mathcing of urls. Now only https url matching
- v1.0.10
- Fix: Changed class ".download" to ".downlinks"
- v1.0.9 (2017-04-20)
- New UserScript Attribute: contributionURL
- New UserScript Attribute: supportURL
- Changed the match and inlcude UserScript attributes to use http(s) instead of wildcards
- v1.0.8 (2017-04-18)
- Added 'p4p.arenabg.ch' to array() 'needleTrackers'-in-a-'haystackTrackers'
- Added 'tracker.pirateparty.gr' to array() 'needleTrackers'-in-a-'haystackTrackers'
- v1.0.7.1 (2017-01-15)
- Added 'tracker.pirateparty.gr' to array() 'needleTrackers'-in-a-'haystackTrackers'
- v1.0.7 (2017-01-15)
- Changed '@grant none' to '@grant GM_addStyle'.
- Changed style '#magnetlinkurlid' to load with function 'GM_addStyle()' instead of more native
javascript. Because of Chrome throwing errors related to style-src not set parameter.
- v1.0.6.3 (2016-09-22)
- Added mirror sites torrentz2.me and torrentzwealmisr.onion.
- v1.0.6.2 (2016-08-28)
- Modified url regex pattern matching to enable the script to run on proxy sites.
- Added the inlcude lines *://torrentz.- vand *://torrentz*.- vto script properties.
- v1.0.6.1 (2016-08-20)
- Added tracker explodie.org and moved 9.rarbg.com to comments section for non-used trackers
- v1.0.6 (2016-08-17)
- updated matching domains to the new player called torrentz2.eu.
- torrentz.eu and all affiliated domains and mirror sites removed to the site suffering a slash back.
- v1.0.5 (2012-11-15)
- update for new domain (torrentz.eu).
- and changing the default trackers (openbittorrent, publicbt, istole.it).
- v1.0.4 (2011-01-01)
- update for new domain (torrentz.eu).
- v1.0.3 (2009-12-30)
- fixed some more problems with 'www.torrentz.com'.
- adding three default trackers to any magnet link.
- v1.0.2 (2009-12-30)
- now both 'www.torrentz.com' and 'torrenz.com' are
correctly treated.
- v1.0.1 (2009-12-05)
- small bugfix (incompatibility with certain custom
css styles).
- v1.0.0 (2009-11-17)
- initial release.
*/
var url;
url = null;
if ((url = location.href.match(/torrentz(2)?(\.([a-z0-9]+))?\.([a-z]{2,8})\/([a-f0-9]{40})/)))
{
if (url !== null)
{
var hash, trackers_a, trackers, title, magnet, head, style, body;
hash = url[5];
// get all the listed trackers for the particular torrent.
trackers_a = document.querySelectorAll( '.trackers > dl > dt' );
trackers = null;
for (var i=0;i<trackers_a.length;++i) {
trackers += '&tr=' + trackers_a[i].innerHTML.replace(/:/g,'%3A').replace(/\//g,'%2F');
}
// read title
title = encodeURIComponent( document.querySelector( '.downurls > h2 > span' ).innerHTML.replace('"','') ).replace('%26amp%3B','and');
if (title.length == 40 && title.match(/[0-9a-z]+/i) && title == hash)
{
var tpb, bitsno;
tpb = document.querySelector('.downlinks a[href^="https://thepiratebay.org"] .n');
bitsno = document.querySelector('.downlinks a[href^="http://bitsnoop.com"] .n');
if(tpb !== null)
{
//if the title is equal to the hash, go for the title from TPB.
title = encodeURIComponent(tpb.innerHTML);
}
else if (bitsno !== null)
{
title = encodeURIComponent(bitsno.innerHTML);
}
}
else if (title === ''||null||undefined)
{
//if the title is still not valied, go for the one from katproxy.com.
title = encodeURIComponent(document.querySelector('.downlinks a[href^="http://katproxy.com"] .n').innerHTML);
}
else if (title === ''||null||undefined)
{
//if the title is (unlikely still) not valid, just resign and set the magnet title to 'unknown torrent'.
title = 'unknown torrent';
}
// add key-definition to title-value
title = '&dn=' + title;
// generate the magnet link
magnet = "magnet:?xt=urn:btih:"+hash+title+trackers;
// add downloadlink
head = document.getElementsByTagName('head')[0];
if (!head)
{
return;
}
GM_addStyle("#magnetlinkurlid { border:1px #4995FF solid; z-index:10000; -moz-border-radius:3px; background:#AACDFF; padding:4px 10px; display:block; position:fixed; right:10px; top:10px; font-family:Verdana; font-size:18px;");
body = document.getElementsByTagName('body')[0];
if (!body)
{
return;
}
style = document.createElement('div');
style.id = 'magnetlinkurlid';
style.innerHTML = '<a href="'+magnet+'">Download</a>';
body.appendChild(style);
}
}