-
Notifications
You must be signed in to change notification settings - Fork 10
/
Rarbg-CAPTCHA-solver.user.js
212 lines (202 loc) · 8.89 KB
/
Rarbg-CAPTCHA-solver.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
// prettier-ignore
var meta = {
rawmdb: function () {
// ==UserScript==
// @name RARBG CAPTCHA solver
// @namespace https://github.com/FarisHijazi
// @version 1.1
// @description Auto-solve CAPTCHA, infinite scroll, add a magnet link shortcut and thumbnails of torrents,
// @description adds a image search link in case you want to see more pics of the torrent, and more!
// @author Faris Hijazi
// @grant unsafeWindow
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_download
// @grant GM_xmlhttpRequest
// @icon https://www.google.com/s2/favicons?domain=rarbg.com
// @run-at document-idle
// @require https://code.jquery.com/jquery-3.4.0.min.js
// @require https://raw.githubusercontent.com/antimatter15/ocrad.js/master/ocrad.js
// @include https://*rarbg.*
// @include /https?:\/\/.{0,8}rarbg.*\.\/*/
// @include /https?:\/\/.{0,8}rargb.*\.\/*/
// @include /https?:\/\/.*u=MTcyLjIxLjAuMXw6Ly9yYXJiZy50by90b3JyZW50LzIyMDg3MjYwfE1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS83OS4wLjM5NDUuMTMwIFNhZmFyaS81MzcuMzZ8ODc4MDQz.*/
// @include https://www.rarbg.is
// @include https://rarbg.to/*
// @include http://rarbg-to.pbproxy.red
// @include http://rarbg-to.pbproxy2.co
// @include http://rarbg-to.proxydude.red
// @include http://rarbg-to.proxydude.xyz
// @include http://rarbg.bypassed.team
// @include http://rarbg.com.torrentprox.com
// @include http://rarbg4-to.unblocked.lol
// @include http://rarbgaccess.org
// @include http://rarbgmirror.xyz/*
// @include http://rarbgto.org
// @include https://rarbg.bypassed.cab
// @include https://rarbg.bypassed.plus
// @include https://rarbg.immunicity.cab
// @include https://rarbg.immunicity.cool
// @include https://rarbg.immunicity.host
// @include https://rarbg.immunicity.plus
// @include https://rarbg.immunicity.team
// @include https://rarbg.proxydude.win
// @include https://rarbg.unblockall.xyz
// @include https://rarbg.unblocked.bet
// @include https://rarbg.unblocked.cab
// @include https://rarbg.unblocked.cool
// @include https://rarbg.unblocked.lol
// @include https://rarbg.unblocked.plus
// @include https://rarbg.unblocked.pub
// @include https://rarbg.unblocked.red
// @include https://rarbg.unblocked.st
// @include https://rarbg.unblocked.st/*
// @include https://rarbg.unblocked.team
// @include https://rarbg.unblockedall.site
// @include https://rarbg.unblocker.cc
// @include https://rarbg.unblocker.win
// @include https://rarbg.unblockmy.link
// @include https://rarbg.unblockmy.site
// @include https://rarbg.unlockproj.party
// @include http://rarbgmirror.xyz
// @include https://rarbgaccess.org
// @include https://rarbgmirror.com
// @include https://rarbgproxy.org
// @include https://rarbgprx.org
// @include https://rarbgunblock.com
// @include https://rarbgmirror.org
// @include https://rarbgto.org
// @include https://rarbgunblock.com/*
// @include https://filesdownloader.com/proxify.php?proxy=ZmlsZXNkb3dubG9hZGVyLmNvbQ==&site=aHR0cDovL3JhcmJnLnRvLw==
// @include https://freeanimesonline.com/proxify.php?proxy=ZnJlZWFuaW1lc29ubGluZS5jb20=&site=aHR0cDovL3JhcmJnLnRvLw==
// @include https://freeproxy.io/proxify.php?proxy=ZnJlZXByb3h5Lmlv&site=aHR0cDovL3JhcmJnLnRvLw==
// @include https://freeproxy.io/rarbg-proxy
// @include https://siteget.net/proxify.php?proxy=c2l0ZWdldC5uZXQ=&site=aHR0cDovL3JhcmJnLnRvLw==
// @include https://siteget.net/rarbg-proxy
// @include https://sitenable.ch/proxify.php?proxy=c2l0ZW5hYmxlLmNo&site=aHR0cDovL3JhcmJnLnRvLw==
// @include https://sitenable.co/proxify.php?proxy=c2l0ZW5hYmxlLmNv&site=aHR0cDovL3JhcmJnLnRvLw==
// @include https://sitenable.info/proxify.php?proxy=c2l0ZW5hYmxlLmluZm8=&site=aHR0cDovL3JhcmJnLnRvLw==
// @include https://sitenable.info/rarbg-proxy
// @include https://sitenable.pw/proxify.php?proxy=c2l0ZW5hYmxlLnB3&site=aHR0cDovL3JhcmJnLnRvLw==
// @include https://sitenable.pw/rarbg-proxy
// @include https://sitenable.top/proxify.php?proxy=c2l0ZW5hYmxlLnRvcA==&site=aHR0cDovL3JhcmJnLnRvLw==
// @include https://sitenable.top/rarbg-proxy
// @noframes
// ==/UserScript==
}
};
if (meta.rawmdb && meta.rawmdb.toString && (meta.rawmdb = meta.rawmdb.toString())) {
var kv,
row = /\/\/\s+@(\S+)\s+(.+)/g;
while ((kv = row.exec(meta.rawmdb)) !== null) {
if (meta[kv[1]]) {
if (typeof meta[kv[1]] == "string") meta[kv[1]] = [meta[kv[1]]];
meta[kv[1]].push(kv[2]);
} else meta[kv[1]] = kv[2];
}
}
meta.window = this;
if (typeof unsafeWindow === "undefined") {
var unsafeWindow = window;
}
unsafeWindow.scriptMetas = unsafeWindow.scriptMetas || [];
if (meta.hasOwnProperty("nodups")) {
if (new Set(unsafeWindow.scriptMetas.map((meta) => meta.namespace + meta.name)).has(meta.namespace + meta.name)) {
console.warn(
"Another script is trying to execute but @nodups is set. Stopping execution.\n",
meta.namespace + meta.name
);
return;
}
}
unsafeWindow.scriptMetas.push(meta);
console.log("Script:", meta.name, "meta:", meta);
function solveCaptcha(OCRAD) {
console.log("solving captcha...");
const container = document.querySelector("tbody > :nth-child(2)");
const img = container.querySelector("img");
const captcha = document.querySelector("#solve_string");
const submitBtn = document.querySelector("#button_submit");
const url = new URL(location.href);
function uriToImageData(uri) {
return new Promise(function (resolve, reject) {
if (uri == null) return reject();
var canvas = document.createElement("canvas"),
context = canvas.getContext("2d"),
image = new Image();
image.addEventListener(
"load",
function () {
canvas.width = image.width;
canvas.height = image.height;
context.drawImage(image, 0, 0, canvas.width, canvas.height);
resolve(context.getImageData(0, 0, canvas.width, canvas.height));
},
false
);
image.src = uri;
});
}
function getBase64Image(img, excludeUrlProtocol = false) {
// Create an empty canvas element
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
// Copy the image contents to the canvas
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
// Get the data-URL formatted image
// Firefox supports PNG and JPEG. You could check img.src to
// guess the original format, but be aware the using "image/jpg"
// will re-encode the image.
var dataURL = canvas.toDataURL("image/png");
return (excludeUrlProtocol && dataURL.replace(/^data:image\/(png|jpg);base64,/, "")) || dataURL;
}
console.log("solveCAPTHA fetching image ...");
return new Promise((resolve) => {
// wait for image to load
if (img.complete) {
return resolve();
}
img.onload = resolve;
})
.then(() =>
uriToImageData(getBase64Image(img)).then((imageData) => {
if (img.naturalHeight === 0 && img.naturalWidth === 0) {
console.warn("image hasn't loaded, refreshing to new captha page");
url.searchParams.set("defence", "1");
location.assign(url.toString());
return;
}
console.log("feeding image to OCR ...");
var imageText = OCRAD(imageData);
console.log("OCRAD result:", imageText);
if (!imageText) {
throw Error("OCRAD result is empty");
}
captcha.value = imageText;
submitBtn.display = "";
submitBtn.click();
})
)
.catch((e) => {
console.error(e);
url.searchParams.set("defence", "1");
location.assign(url.toString());
});
}
(function () {
"use strict";
const isOnThreatDefencePage = /threat_defence/i.test(location.href);
$(document).ready(function main() {
// click to verify browser
document.querySelectorAll('a[href^="/threat_defence.php?defence=1"]').forEach((a) => a.click());
if (isOnThreatDefencePage) {
// OnThreatDefencePage: check for captcha
if (document.querySelector("#solve_string")) {
console.log("Rarbg threat defence page");
solveCaptcha(OCRAD);
}
}
});
})();