-
Notifications
You must be signed in to change notification settings - Fork 0
/
magnet-booster.js
40 lines (26 loc) · 959 Bytes
/
magnet-booster.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
// ==UserScript==
// @name magnet-booster
// @version 1
// @include http*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
// @grant GM.xmlHttpRequest
// ==/UserScript==
this.$ = this.jQuery = jQuery.noConflict(true);
$(window).load(function(){
// xmlHttpRequest caches requests automatically
GM.xmlHttpRequest({ method: "GET", url: "https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt", onload: function(response) {
console.log("Magnet-Booster: successful request to github");
var magnet = "";
response.response.split("\n").forEach(function(entry) {
if (entry.startsWith("http") || entry.startsWith("udp"))
magnet += "&tr=" + encodeURIComponent(entry);
});
$("a[href^='magnet:']")
.each(function()
{
this.href = this.href + magnet;
}).promise().done(function () {
console.log("Magnet-Booster: updated all magnets on page!");
});
} });
});