-
Notifications
You must be signed in to change notification settings - Fork 10
/
Rarbg-Enhancer-UserScript.user.js
2785 lines (2503 loc) · 134 KB
/
Rarbg-Enhancer-UserScript.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// prettier-ignore
var meta = {
rawmdb: function () {
// ==UserScript==
// @name RARBG Enhancer
// @namespace https://github.com/FarisHijazi
// @version 1.6.35
// @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
// with some code from https://greasyfork.org/en/users/2160-darkred
// @grant unsafeWindow
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_download
// @grant GM_xmlhttpRequest
// @grant GM_registerMenuCommand
// @icon https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://rarbg.to&size=16
// @run-at document-idle
// @updateUrl https://github.com/FarisHijazi/Rarbg-Enhancer-UserScript/raw/master/Rarbg-Enhancer-UserScript.user.js
// @downloadURL https://github.com/FarisHijazi/Rarbg-Enhancer-UserScript/raw/master/Rarbg-Enhancer-UserScript.user.js
// @require https://code.jquery.com/jquery-3.4.0.min.js
// @require https://unpkg.com/[email protected]/dist/infinite-scroll.pkgd.min.js
// @require https://raw.githubusercontent.com/ccampbell/mousetrap/master/mousetrap.min.js
// @require https://raw.githubusercontent.com/mitchellmebane/GM_fetch/master/GM_fetch.js
// @require https://raw.githubusercontent.com/antimatter15/ocrad.js/master/ocrad.js
// @require https://raw.githubusercontent.com/sizzlemctwizzle/GM_config/2207c5c1322ebb56e401f03c2e581719f909762a/gm_config.js
// @include https://*rarbg.*
// @include /https?:\/\/.{0,8}rarbg.*\.\/*/
// @include /https?:\/\/.{0,8}rargb.*\.\/*/
// @include /https?:\/\/.*u=MTcyLjIxLjAuMXw6Ly9yYXJiZy50by90b3JyZW50LzIyMDg3MjYwfE1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS83OS4wLjM5NDUuMTMwIFNhZmFyaS81MzcuMzZ8ODc4MDQz.*/
// @include https://www.rarbggo.to/
// @include https://www.rarbg.is
// @include https://proxyrarbg.org
// @include https://rarbg.com
// @include https://rarbg.to
// @include https://rarbg2018.org
// @include https://rarbg2019.org
// @include https://rarbg2020.org
// @include https://rarbg2021.org
// @include https://rarbgaccess.org
// @include https://rarbgaccessed.org
// @include https://rarbgcdn.org
// @include https://rarbgcore.org
// @include https://rarbgdata.org
// @include https://rarbgenter.org
// @include https://rarbgget.org
// @include https://rarbggo.org
// @include https://rarbgindex.org
// @include https://rarbgmirror.com
// @include https://rarbgmirror.org
// @include https://rarbgmirrored.org
// @include https://rarbgp2p.org
// @include https://rarbgproxied.org
// @include https://rarbgproxies.org
// @include https://rarbgproxy.com
// @include https://rarbgproxy.org
// @include https://rarbgprx.org
// @include https://rarbgto.org
// @include https://rarbgtor.org
// @include https://rarbgtorrents.org
// @include https://rarbgunblock.com
// @include https://rarbgunblock.org
// @include https://rarbgunblocked.org
// @include https://rarbgway.org
// @include https://rarbgweb.org
// @include https://unblockedrarbg.org
// @include https://www.rarbg.is
// @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
);
throw new Error(
"Another script is trying to execute but @nodups is set. Stopping execution.\n" + meta.namespace + meta.name
);
}
}
unsafeWindow.scriptMetas.push(meta);
console.log("Script:", meta.name, "meta:", meta);
// AddColumn() and add magnetLinks() code taken from: https://greasyfork.org/en/scripts/23493-rarbg-torrent-and-magnet-links/code
/**
* Sequence of function calls
*
* appendColumn()
* -> appendColumnSingle()
* -> addDlAndMl()
* observeDocument(dealWithTorrents)
* */
// pollyfill for Element.before() and Element.after(): (since some browsers like MS Edge don't already have them)
if (Element.prototype.before === undefined) {
Element.prototype.before = function (newNode) {
if (this.parentElement) {
return this.parentElement.insertBefore(newNode, this);
}
};
}
if (Element.prototype.after === undefined) {
Element.prototype.after = function (newNode) {
if (this.parentElement) {
return this.parentElement.insertBefore(newNode, this.nextSibling);
}
};
}
// "Set" operations
/** this - other
* @param other
* @returns {Set} containing what this has but other doesn't */
Set.prototype.difference = function (other) {
if (!other.has) other = new Set(other);
return new Set(Array.from(this).filter((x) => !other.has(x)));
};
/**
* {}
*/
let titleGroups = {};
const catCodeMap = {
Movies: "48;17;44;45;47;50;51;52;42;46".split(";"),
XXX: "4".split(";"),
Music: "23;24;25;26".split(";"),
"TV shows": "18;41;49".split(";"),
Software: "33;34;43".split(";"),
Games: "27;28;29;30;31;32;40;53".split(";"),
"Non XXX":
"2;14;15;16;17;21;22;42;18;19;41;27;28;29;30;31;32;40;23;24;25;26;33;34;43;44;45;46;47;48;49;50;51;52;54".split(
";"
),
};
// categories map, given the category number (in the URL), returns the name of it
const codeToCatMap = reverseMapping(catCodeMap);
// converts key to a category code (number in URL)
const catKeyMap = {
v: "Movies",
s: "TV shows",
m: "Music",
w: "Software",
x: "XXX",
g: "Games",
n: "Non XXX",
};
const ICON_DESCRIPTION_WIDE = "https://i.imgur.com/xreLTXq.gif";
const ICON_DESCRIPTION_TALL = "https://i.imgur.com/6gG2QGj.gif";
const ICON_THUMBNAILS_WIDE = "https://i.imgur.com/9xh3vuU.gif";
const ICON_THUMBNAILS_TALL = "https://i.imgur.com/XMV45fY.gif";
const ICON_THUMBNAILS = "https://i.imgur.com/nA2dRWu.gif";
const ICON_DESCRIPTION = "https://i.imgur.com/UxbSq2o.gif";
const ICON_MORE_BLUE = "https://i.imgur.com/FGwOuVT.gif";
const ICON_EXTRA_GREEN = "https://i.imgur.com/HU6J9kS.gif";
const BLACKLISTED_IMG_URLS = new Set([
"https://shotcan.com/images/finalec40346aca02aa34.png",
"https://img.trafficimage.club/content/images/system/logo_1575804241329_3ec4e4.png",
"https://pacific.picturedent.org/images/archive/galaxxxylogo.png",
"https://worldmkv.com/wp-content/uploads/2017/10/Icon.jpg",
"https://torrentgalaxy.to", // not an image
]);
const SearchEngines = {
google: {
name: "Google",
imageSearchUrl: (q) => `https://www.google.com/search?&hl=en&tbm=isch&q=${encodeURIComponent(q)}`,
},
ddg: {
name: "DuckDuckGo",
imageSearchUrl: (q) =>
`https://duckduckgo.com/?q=${encodeURIComponent(q)}&atb=v73-5__&iar=images&iax=images&ia=images`,
},
yandex: {
name: "Yandex",
imageSearchUrl: (q) => `https://yandex.com/images/search?text=${encodeURIComponent(q)}`,
},
};
const debug = false; // debugmode (setting this to false will disable the console logging)
// main
(function () {
"use strict";
const TORRENT_ICO = "https://dyncdn.me/static/20/img/16x16/download.png";
const MAGNET_ICO =
"data:image/png;base64,R0lGODlhDAAMAPcAAAAAAGNjY97e3v8AAP8ICP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////yH5BAEAAAUALAAAAAAMAAwAAAhMAAEIHEhwoICDAgQiTAhgoUKEDw9GZDhgAAEAAQIAIMBRYMWLBQps7Aig4gCMGjleLGlSoMqVJj++xMhSZscABTSyJIkzZE6CPQsEBAA7";
const trackers =
"http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710";
const isOnSingleTorrentPage = !!matchSite(/\/torrent\//);
const isOnThreatDefencePage = /threat_defence/i.test(location.href);
var title = createElement(
'<div><div><a href="https://github.com/FarisHijazi/Rarbg-Enhancer-UserScript">Rarbg-Enhancer-UserScript Settings</a><pre style=" font-size: medium; ">You can get to this options page by pressing "ctrl+/" or by navigating to the menu as shown bellow</pre></div><img src="https://github.com/FarisHijazi/Rarbg-Enhancer-UserScript/raw/master/screenshots/rarbg-options.png"></div>'
);
GM_config.init({
id: "GM_config",
title: title,
css: "#GM_config_section_1 .config_var, #GM_config_section_2 .config_var, #GM_config_section_3 .config_var { margin: 5% !important;display: inline !important; }",
fields: {
thumbnailLink: {
section: [
GM_config.create("Rarbg Settings"),
"here you can configure settings for the rarbg-enhancer-userscript. Be aware that the page will reload after saving",
],
label: "thumbnailLink",
default: "torrentPageLink",
title: "where should clicking the thumbnail take you",
options: ["magnetLink", "torrentLink", "torrentPageLink", "img"],
type: "radio",
},
addThumbnails: {
label: "addThumbnails",
default: true,
title: "if set to false, the content thumbnails will not be used, magnet or torrent thumbnails will be used isntead",
type: "checkbox",
},
showGeneratedSearchQuery: {
label: "showGeneratedSearchQuery",
default: false,
title: "",
type: "checkbox",
},
addCategoryWithSearch: {
label: "addCategoryWithSearch",
default: true,
title: 'when searching for a movie title like "X-men", will become "X-men movie"',
type: "checkbox",
},
showTorrentDownloadIcon: {
label: "showTorrentDownloadIcon",
default: false,
title: "show the .torrent file download icon next to the magnet link (this doesn't really work anymore)",
type: "checkbox",
},
largeThumbnails: {
label: "largeThumbnails",
default: true,
title: "",
type: "checkbox",
},
alwaysFetchExtraThumbnails: {
label: "alwaysFetchExtraThumbnails",
title: "automatically press fetch extra thumbnails",
type: "checkbox",
default: true,
},
ImageSearchEngine: {
label: "ImageSearchEngine",
default: "google",
title: "",
options: Array.from(Object.keys(SearchEngines)),
type: "radio",
},
infiniteScrolling: {
label: "infiniteScrolling",
default: true,
title: "",
type: "checkbox",
},
mirrors: {
label: "mirrors",
default: meta.include.join("\n"),
title: "",
type: "textarea",
},
imgScale: {
label: "imgScale",
default: 50,
title: "",
type: "float",
},
imgHoverPopupScale: {
label: "imgHoverPopupScale",
default: 3.0,
title: "",
type: "float",
},
hideRecommendedTorrents: {
label: "hideRecommendedTorrents",
default: false,
title: "",
type: "checkbox",
},
autoExitIndexPhp: {
label: "autoExitIndexPhp",
default: true,
title: "",
type: "checkbox",
},
deduplicateTorrents: {
label: "deduplicateTorrents",
default: false,
title: "attempt to remove duplicates when there are multiple torrents of the same item",
type: "checkbox",
},
staticSearchbar: {
label: "staticSearchbar",
default: false,
title: "",
type: "checkbox",
},
includeDescriptionsButton: {
label: "includeDescriptionsButton",
default: true,
title: "add a link for each row to search for getting the description thumbnails",
type: "checkbox",
},
includeSearchForImagesButton: {
label: "includeSearchForImagesButton",
default: true,
title: "add a link for each row to search for images using a search engine (google, ddg, yandex..)",
type: "checkbox",
},
isFirstVisit: {
type: "hidden",
default: true,
},
thumbnailHoverSound: {
label: "thumbnailHoverSound",
type: "checkbox",
title: "play sound when hovering over thumbnail",
default: true,
},
// blocking
"block Movies": {
label: "block Movies",
default: false,
type: "checkbox",
title: "Movies",
section: "Block categories",
},
"block TV shows": { label: "block TV shows", default: false, type: "checkbox", title: "TV shows" },
"block Music": { label: "block Music", default: false, type: "checkbox", title: "Music" },
"block Software": { label: "block Software", default: false, type: "checkbox", title: "Software" },
"block XXX": { label: "block XXX", default: true, type: "checkbox", title: "XXX" },
"block Games": { label: "block Games", default: false, type: "checkbox", title: "Games" },
hideEmptyTorrentLinks: {
label: "hide torrents without download or magnet",
default: true,
type: "checkbox",
title: "Removes the row of the torrent that has no magnet link or download link",
},
},
events: {
open: function (doc) {},
save: function (values) {
// All the values that aren't saved are passed to this function
// for (i in values) alert(values[i]);
location.reload();
},
},
});
// override fetching description images
// FIXME: maybe update this later
// GM_config.set("alwaysFetchExtraThumbnails", true);
if (!GM_config.get("mirrors")) {
GM_config.save();
}
if (typeof GM_registerMenuCommand !== "undefined") {
GM_registerMenuCommand("Rarbg options", () => {
GM_config.open();
});
}
Math.clamp = function (a, min, max) {
return a < min ? min : a > max ? max : a;
};
let searchEngine = {};
initSearchEngine();
// click to verify browser
document.querySelectorAll('a[href^="/threat_defence.php?defence=1"]').forEach((a) => a.click());
const searchBox = document.querySelector('#searchinput, input[id="keywords"]');
const isOnTop10page = location.pathname.startsWith("/top");
const isOnIndexPage = searchBox !== null || isOnTop10page;
const isOnWrongTorrentLinkPage =
getElementsByXPath(
'(/html/body/table[3]/tbody/tr/td[2]/div/table/tbody/tr[2]/td/div[contains(., "The link you followed is wrong. Please try again!")])'
).length > 0;
const getTorrentLinks = () => Array.from(document.querySelectorAll("table > tbody > tr.lista2 a[title]"));
var row_others = getElementsByXPath('(//tr[contains(., "Others:")])[last()]').pop();
if (!!document.querySelector("thead.table1head")) {
// therarbg: https://the.rarbg.club/get-posts/category:Movies:time:10D/
var tbodyEls = document.querySelectorAll("tbody");
} else {
var tbodyEls =
isOnSingleTorrentPage && row_others
? [row_others.parentElement.querySelector("tbody")]
: Array.from(document.querySelectorAll("tbody")).filter((tbody) => {
let tds = Array.from(tbody.querySelector("tr")?.querySelectorAll("td") || []);
return tds.length >= 8 && tds[0].innerText.trim() === "Cat.";
});
}
if (!tbodyEls.length) console.warn("tbody element not found!");
var thumbnailsCssBlock = addCss("");
// language=CSS
addCss(
`
a.torrent-ml:not([href^=magnet]) {
filter: grayscale(0.6);
}
/*this keeps the tableCells in the groups at equal heights*/
table.groupTable > tbody > tr > td {
height: 10px !important;
}
/*the horsey suggestion thumbnails*/
.suggestion-thumbnail {
max-width: 100px;
max-height: 100px;
}
a.torrent-ml, a.torrent-dl {
display: table-cell;
padding: 5px;
}
a.torrent-ml > img, a.torrent-dl > img {
max-width: 30px;
}
/*add margin*/
td.lista > * {
margin: 10px;
}
a.search:link { color: red; }
a.search:visited { color: green; }
a.search:hover { color: hotpink; }
a.search:active { color: blue; }
.zoom {
transition: transform .2s; /* Animation */
margin: 0 auto;
}
.zoom:hover {
/* (150% zoom - Note: if the zoom is too large, it will go outside of the viewport) */
transform: scale(${GM_config.get("imgHoverPopupScale")});
}
a.extra-tb {
background: white;
}
.row{
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
}
`
);
updateCss();
/** Plays audio
* @author https://stackoverflow.com/a/17762789/7771202 */
const PlaySound = (function () {
const df = document.createDocumentFragment();
return function Sound(src) {
var snd = new Audio(src);
df.appendChild(snd); // keep in fragment until finished playing
snd.addEventListener("ended", function () {
df.removeChild(snd);
});
snd.play();
return snd;
};
})();
let snd = function () {};
snd.play = function () {};
if (GM_config.get("thumbnailHoverSound")) {
// sound file from: http://freesound.org/data/previews/166/166186_3034894-lq.mp3
// noinspection JSUnusedAssignment
snd = PlaySound(
"data:audio/wav;base64," +
"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"
);
}
// === end of variable declarations ===
function decrementImageSize(e) {
GM_config.set("imgScale", Math.max(GM_config.get("imgScale") - 50, 0));
toggleThumbnailSize("update only");
}
function incrementImageSize(e) {
GM_config.set("imgScale", Math.min(GM_config.get("imgScale") + 50, 400));
toggleThumbnailSize("update only");
}
$(document).ready(function main() {
if (isOnThreatDefencePage) {
// OnThreatDefencePage: check for captcha
if (document.querySelector("#solve_string")) {
console.log("Rarbg threat defence page");
try {
// solveCaptcha(OCRAD);
unsafeEval(solveCaptcha, OCRAD);
} catch (e) {
console.error("Error occurred while trying to solve captcha:\n", e);
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 textEl = img.previousElementSibling.previousElementSibling.previousElementSibling;
textEl.innerText += "Could not auto-solve capthca";
// prettier-ignore
/* tesseract.js
* https://tesseract.projectnaptha.com/
* https://cdn.jsdelivr.net/gh/naptha/[email protected]/dist/tesseract.min.js
*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Tesseract=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var process=module.exports={};var cachedSetTimeout;var cachedClearTimeout;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function"){cachedSetTimeout=setTimeout}else{cachedSetTimeout=defaultSetTimout}}catch(e){cachedSetTimeout=defaultSetTimout}try{if(typeof clearTimeout==="function"){cachedClearTimeout=clearTimeout}else{cachedClearTimeout=defaultClearTimeout}}catch(e){cachedClearTimeout=defaultClearTimeout}})();function runTimeout(fun){if(cachedSetTimeout===setTimeout){return setTimeout(fun,0)}if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout){cachedSetTimeout=setTimeout;return setTimeout(fun,0)}try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}function runClearTimeout(marker){if(cachedClearTimeout===clearTimeout){return clearTimeout(marker)}if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout){cachedClearTimeout=clearTimeout;return clearTimeout(marker)}try{return cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}var queue=[];var draining=false;var currentQueue;var queueIndex=-1;function cleanUpNextTick(){if(!draining||!currentQueue){return}draining=false;if(currentQueue.length){queue=currentQueue.concat(queue)}else{queueIndex=-1}if(queue.length){drainQueue()}}function drainQueue(){if(draining){return}var timeout=runTimeout(cleanUpNextTick);draining=true;var len=queue.length;while(len){currentQueue=queue;queue=[];while(++queueIndex<len){if(currentQueue){currentQueue[queueIndex].run()}}queueIndex=-1;len=queue.length}currentQueue=null;draining=false;runClearTimeout(timeout)}process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1){for(var i=1;i<arguments.length;i++){args[i-1]=arguments[i]}}queue.push(new Item(fun,args));if(queue.length===1&&!draining){runTimeout(drainQueue)}};function Item(fun,array){this.fun=fun;this.array=array}Item.prototype.run=function(){this.fun.apply(null,this.array)};process.title="browser";process.browser=true;process.env={};process.argv=[];process.version="";process.versions={};function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.prependListener=noop;process.prependOnceListener=noop;process.listeners=function(name){return[]};process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")};process.umask=function(){return 0}},{}],2:[function(require,module,exports){module.exports={name:"tesseract.js",version:"1.0.13",description:"Pure Javascript Multilingual OCR",main:"src/index.js",scripts:{start:'concurrently --kill-others "watchify src/index.js -t [ envify --NODE_ENV development ] -t [ babelify --presets [ es2015 ] ] -o dist/tesseract.dev.js --standalone Tesseract" "watchify src/browser/worker.js -t [ envify --NODE_ENV development ] -t [ babelify --presets [ es2015 ] ] -o dist/worker.dev.js" "http-server -p 7355"',build:"browserify src/index.js -t [ babelify --presets [ es2015 ] ] -o dist/tesseract.js --standalone Tesseract && browserify src/browser/worker.js -t [ babelify --presets [ es2015 ] ] -o dist/worker.js && uglifyjs dist/tesseract.js --source-map -o dist/tesseract.min.js && uglifyjs dist/worker.js --source-map -o dist/worker.min.js",release:"npm run build && git commit -am 'new release' && git push && git tag `jq -r '.version' package.json` && git push origin --tags && npm publish"},browser:{"./src/node/index.js":"./src/browser/index.js"},author:"",license:"Apache-2.0",devDependencies:{"babel-preset-es2015":"^6.16.0",babelify:"^7.3.0",browserify:"^13.1.0",concurrently:"^3.1.0",envify:"^3.4.1","http-server":"^0.9.0",pako:"^1.0.3","uglify-js":"^3.4.9",watchify:"^3.7.0"},dependencies:{"file-type":"^3.8.0","isomorphic-fetch":"^2.2.1","is-url":"1.2.2","jpeg-js":"^0.2.0","level-js":"^2.2.4","node-fetch":"^1.6.3","object-assign":"^4.1.0","png.js":"^0.2.1","tesseract.js-core":"^1.0.2"},repository:{type:"git",url:"https://github.com/naptha/tesseract.js.git"},bugs:{url:"https://github.com/naptha/tesseract.js/issues"},homepage:"https://github.com/naptha/tesseract.js"}},{}],3:[function(require,module,exports){(function(process){"use strict";var defaultOptions={corePath:"https://cdn.jsdelivr.net/gh/naptha/[email protected]/index.js",langPath:"https://tessdata.projectnaptha.com/3.02/"};if(process.env.NODE_ENV==="development"){console.debug("Using Development Configuration");defaultOptions.workerPath=location.protocol+"//"+location.host+"/dist/worker.dev.js?nocache="+Math.random().toString(36).slice(3)}else{var version=require("../../package.json").version;defaultOptions.workerPath="https://cdn.jsdelivr.net/gh/naptha/tesseract.js@"+version+"/dist/worker.js"}exports.defaultOptions=defaultOptions;exports.spawnWorker=function spawnWorker(instance,workerOptions){if(window.Blob&&window.URL){var blob=new Blob(['importScripts("'+workerOptions.workerPath+'");']);var worker=new Worker(window.URL.createObjectURL(blob))}else{var worker=new Worker(workerOptions.workerPath)}worker.onmessage=function(e){var packet=e.data;instance._recv(packet)};return worker};exports.terminateWorker=function(instance){instance.worker.terminate()};exports.sendPacket=function sendPacket(instance,packet){loadImage(packet.payload.image,function(img){packet.payload.image=img;instance.worker.postMessage(packet)})};function loadImage(image,cb){if(typeof image==="string"){if(/^\#/.test(image)){return loadImage(document.querySelector(image),cb)}else if(/(blob|data)\:/.test(image)){var im=new Image;im.src=image;im.onload=function(e){return loadImage(im,cb)};return}else{var xhr=new XMLHttpRequest;xhr.open("GET",image,true);xhr.responseType="blob";xhr.onload=function(e){return loadImage(xhr.response,cb)};xhr.onerror=function(e){if(/^https?:\/\//.test(image)&&!/^https:\/\/crossorigin.me/.test(image)){console.debug("Attempting to load image with CORS proxy");loadImage("https://crossorigin.me/"+image,cb)}};xhr.send(null);return}}else if(image instanceof File){var fr=new FileReader;fr.onload=function(e){return loadImage(fr.result,cb)};fr.readAsDataURL(image);return}else if(image instanceof Blob){return loadImage(URL.createObjectURL(image),cb)}else if(image.getContext){return loadImage(image.getContext("2d"),cb)}else if(image.tagName==="IMG"||image.tagName==="VIDEO"){var c=document.createElement("canvas");c.width=image.naturalWidth||image.videoWidth;c.height=image.naturalHeight||image.videoHeight;var ctx=c.getContext("2d");ctx.drawImage(image,0,0);return loadImage(ctx,cb)}else if(image.getImageData){var data=image.getImageData(0,0,image.canvas.width,image.canvas.height);return loadImage(data,cb)}else{return cb(image)}throw new Error("Missing return in loadImage cascade")}}).call(this,require("_process"))},{"../../package.json":2,_process:1}],4:[function(require,module,exports){"use strict";module.exports=function circularize(page){page.paragraphs=[];page.lines=[];page.words=[];page.symbols=[];page.blocks.forEach(function(block){block.page=page;block.lines=[];block.words=[];block.symbols=[];block.paragraphs.forEach(function(para){para.block=block;para.page=page;para.words=[];para.symbols=[];para.lines.forEach(function(line){line.paragraph=para;line.block=block;line.page=page;line.symbols=[];line.words.forEach(function(word){word.line=line;word.paragraph=para;word.block=block;word.page=page;word.symbols.forEach(function(sym){sym.word=word;sym.line=line;sym.paragraph=para;sym.block=block;sym.page=page;sym.line.symbols.push(sym);sym.paragraph.symbols.push(sym);sym.block.symbols.push(sym);sym.page.symbols.push(sym)});word.paragraph.words.push(word);word.block.words.push(word);word.page.words.push(word)});line.block.lines.push(line);line.page.lines.push(line)});para.page.paragraphs.push(para)})});return page}},{}],5:[function(require,module,exports){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var adapter=require("../node/index.js");var jobCounter=0;module.exports=function(){function TesseractJob(instance){_classCallCheck(this,TesseractJob);this.id="Job-"+ ++jobCounter+"-"+Math.random().toString(16).slice(3,8);this._instance=instance;this._resolve=[];this._reject=[];this._progress=[];this._finally=[]}_createClass(TesseractJob,[{key:"then",value:function then(resolve,reject){if(this._resolve.push){this._resolve.push(resolve)}else{resolve(this._resolve)}if(reject)this.catch(reject);return this}},{key:"catch",value:function _catch(reject){if(this._reject.push){this._reject.push(reject)}else{reject(this._reject)}return this}},{key:"progress",value:function progress(fn){this._progress.push(fn);return this}},{key:"finally",value:function _finally(fn){this._finally.push(fn);return this}},{key:"_send",value:function _send(action,payload){adapter.sendPacket(this._instance,{jobId:this.id,action:action,payload:payload})}},{key:"_handle",value:function _handle(packet){var data=packet.data;var runFinallyCbs=false;if(packet.status==="resolve"){if(this._resolve.length===0)console.log(data);this._resolve.forEach(function(fn){var ret=fn(data);if(ret&&typeof ret.then=="function"){console.warn("TesseractJob instances do not chain like ES6 Promises. To convert it into a real promise, use Promise.resolve.")}});this._resolve=data;this._instance._dequeue();runFinallyCbs=true}else if(packet.status==="reject"){if(this._reject.length===0)console.error(data);this._reject.forEach(function(fn){return fn(data)});this._reject=data;this._instance._dequeue();runFinallyCbs=true}else if(packet.status==="progress"){this._progress.forEach(function(fn){return fn(data)})}else{console.warn("Message type unknown",packet.status)}if(runFinallyCbs){this._finally.forEach(function(fn){return fn(data)})}}}]);return TesseractJob}()},{"../node/index.js":3}],6:[function(require,module,exports){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var adapter=require("./node/index.js");var circularize=require("./common/circularize.js");var TesseractJob=require("./common/job");var version=require("../package.json").version;var create=function create(){var workerOptions=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var worker=new TesseractWorker(Object.assign({},adapter.defaultOptions,workerOptions));worker.create=create;worker.version=version;return worker};var TesseractWorker=function(){function TesseractWorker(workerOptions){_classCallCheck(this,TesseractWorker);this.worker=null;this.workerOptions=workerOptions;this._currentJob=null;this._queue=[]}_createClass(TesseractWorker,[{key:"recognize",value:function recognize(image){var _this=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return this._delay(function(job){if(typeof options==="string")options={lang:options};options.lang=options.lang||"eng";job._send("recognize",{image:image,options:options,workerOptions:_this.workerOptions})})}},{key:"detect",value:function detect(image){var _this2=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return this._delay(function(job){job._send("detect",{image:image,options:options,workerOptions:_this2.workerOptions})})}},{key:"terminate",value:function terminate(){if(this.worker)adapter.terminateWorker(this);this.worker=null;this._currentJob=null;this._queue=[]}},{key:"_delay",value:function _delay(fn){var _this3=this;if(!this.worker)this.worker=adapter.spawnWorker(this,this.workerOptions);var job=new TesseractJob(this);this._queue.push(function(e){_this3._queue.shift();_this3._currentJob=job;fn(job)});if(!this._currentJob)this._dequeue();return job}},{key:"_dequeue",value:function _dequeue(){this._currentJob=null;if(this._queue.length){this._queue[0]()}}},{key:"_recv",value:function _recv(packet){if(packet.status==="resolve"&&packet.action==="recognize"){packet.data=circularize(packet.data)}if(this._currentJob.id===packet.jobId){this._currentJob._handle(packet)}else{console.warn("Job ID "+packet.jobId+" not known.")}}}]);return TesseractWorker}();module.exports=create()},{"../package.json":2,"./common/circularize.js":4,"./common/job":5,"./node/index.js":3}]},{},[6])(6)});
function solveCaptchaTesseract(Tesseract) {
Tesseract.recognize(container.querySelector("img"), {
tessedit_char_whitelist: "123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXY",
}).then(function (result) {
console.log("result", result, "\n", result.text);
document.querySelector("#solve_string").value = result;
return result;
});
}
unsafeEval(solveCaptchaTesseract, Tesseract);
}
}
} else {
// on torrent(s) page
if (isOnSingleTorrentPage) {
let mainTorrentLink = document.querySelector(
"a[onmouseover], body > table:nth-child(6) > tbody > tr > td:nth-child(2) > div > table > tbody > tr:nth-child(2) > td > div > table > tbody > tr:nth-child(1) > td > a:nth-child(2)"
);
addImageSearchAnchor(mainTorrentLink, mainTorrentLink.innerText);
const relatedTorrent = document.querySelector(".lista_related");
if (relatedTorrent) {
const tr_tableHeader = relatedTorrent.closest("table").querySelector("tbody > tr");
const thumbsHeader = tr_tableHeader.firstElementChild.cloneNode();
thumbsHeader.innerText = "thumbnail";
tr_tableHeader.firstElementChild.before(thumbsHeader);
}
document.querySelectorAll(".js-modal-url").forEach(async function (a) {
if (!!a.querySelector("img")) return;
if (a.pathname.length < 2) return;
new Set(await getImagesFromUrl(a.href)).forEach((url) => {
var img = document.createElement("img");
img.src = url;
img.classList.add("descrimg");
var div = document.createElement("div");
div.appendChild(img);
a.appendChild(div);
});
replaceAllImageHosts();
});
// adding thumbnails
for (const torrent of document.querySelectorAll('a[href^="/torrent/"]')) {
//creating and adding thumbnails
const cell = document.createElement("td");
const thumbnailLink = document.createElement("a");
const thumbnailImg = document.createElement("img");
thumbnailLink.href = torrent.href;
cell.classList.add("thumbnail-cell");
cell.classList.add("preview-image");
cell.appendChild(thumbnailLink);
// thumbnail
thumbnailImg.classList.add("preview-image");
let thumb = extractThumbnailSrc(torrent);
thumbnailImg.setAttribute("smallSrc", thumb);
thumbnailImg.setAttribute("bigSrc", getLargeThumbnail(thumb));
setThumbnail(thumbnailImg);
thumbnailLink.appendChild(thumbnailImg);
torrent.closest("tr").firstElementChild.before(cell);
thumbnailImg.style.width = "auto";
thumbnailImg.style["max-height"] = "500px";
thumbnailImg.style["max-width"] = "400px";
// thumbnailImg.style['margin-bottom'] = '20px';
}
replaceAllImageHosts();
replaceAllImageHosts(document.querySelectorAll(".js-modal-url > img"));
// putting the "Description:" row before the "Others:" row
var poster = getElementsByXPath('(//tr[contains(., "Poster:")])[last()]')[0];
if (poster) poster.after(getElementsByXPath('(//tr[contains(., "Description:")])[last()]')[0]);
// remove VPN row
const vpnR = getElementsByXPath('(//tr[contains(., "VPN:")])[last()]');
if (vpnR && vpnR[0]) {
vpnR[0].remove();
}
void 0;
} else if (isOnIndexPage) {
if (isOnTop10page) {
function removeTop100(catcodes, slash_category) {
try {
var a = document.querySelector(
'body > table:nth-child(6) > tbody > tr > td:nth-child(2) > div > table > tbody > tr:nth-child(2) > td > a[href$="/top100.php?category[]=' +
catcodes.join("&category[]=") +
'"]'
);
// delete 3 elements before and 3 elements after and delete self
a.previousElementSibling.previousElementSibling.previousElementSibling.remove();
a.previousElementSibling.previousElementSibling.remove();
a.previousElementSibling.remove();
a.nextElementSibling.nextElementSibling.nextElementSibling.remove();
a.nextElementSibling.nextElementSibling.remove();
a.nextElementSibling.remove();
a.remove();
var h1Rss = document.querySelector(
'body > table > tbody > tr > td:nth-child(2) > div > table > tbody > tr:nth-child(2) > td > h1 > a[href$="/rssdd.php?categories=' +
catcodes.join(";") +
'"]'
).parentElement;
h1Rss.nextElementSibling.remove();
h1Rss.remove();
} catch (e) {
console.warn(e);
}
}
if (GM_config.get("block Movies"))
removeTop100("14;15;16;17;21;22;42;44;45;46;47;48".split(";"), "movies");
if (GM_config.get("block XXX")) removeTop100("4".split(";"), "xxx");
if (GM_config.get("block TV shows")) removeTop100("18;19;41".split(";"), "tv");
if (GM_config.get("block Music")) removeTop100("23;24;25;26".split(";"), "music");
if (GM_config.get("block Games")) removeTop100("27;28;29;30;31;32;40".split(";"), "pc-games");
}
// if on torrent page (index)
if (searchBox) {
searchBox.onkeyup = updateSearch;
const searchContainer = searchBox.closest("form").closest("div");
// making checkbox (fixed searchbar)
const moreBtn = searchContainer.querySelector(
'tr:nth-child(1) > td:nth-child(3), [id="filterBtn"]'
);
moreBtn &&
moreBtn.after(
$(
'<td><input id="static-checkbox" type="checkbox"><label for="static-checkbox" style="display: block;">fixed searchbar</label></td>'
)[0]
);
const checkbox = document.querySelector("#static-checkbox");
checkbox.onchange = function (e) {
const searchContainer = searchBox.closest("form").closest("div");
if (checkbox.checked) {
searchContainer.style.position = "fixed";
searchContainer.style.top = "0";
searchContainer.style.left = "702px";
} else {
searchContainer.style.position = "";
searchContainer.style.top = "";
searchContainer.style.left = "";
}
GM_config.set("staticSearchbar", checkbox.checked);
GM_config.write();
};
}
if (GM_config.get("staticSearchbar")) {
checkbox.click();
}
if (GM_getValue("isFirstVisit", true)) {
console.log("is first visit");
GM_config.open();
GM_setValue("isFirstVisit", false);
}
for (const tbodyEl of tbodyEls) {
const mldlCol = appendColumn(tbodyEl, "ML DL<br>Download all", "File", addDlAndMl);
mldlCol.header.addEventListener("click", downloadAllTorrents);
}
if (GM_config.get("infiniteScrolling") && !isOnTop10page) {
// infiniteScrolling
(function makeInfiniteScroll() {
const tbody = [
"div.content-rounded table.lista-rounded tbody:nth-child(1) tr:nth-child(2) td:nth-child(1) > table.lista2t:nth-child(9) > tbody",
".lista2t > tbody",
];
const nav = [
"#pager_links",
"td:nth-child(2) div.content-rounded table.lista-rounded tbody:nth-child(1) > tr:nth-child(3)",
];
var nextPageSelectors = ['a[title="next page"]'];
const indexOfCurrentPage = [...document.querySelectorAll("#pager_links > *")]
.map((x) => x.tagName)
.indexOf("B");
if (indexOfCurrentPage >= 0) {
nextPageSelectors = [
...nextPageSelectors,
`#pager_links > a:nth-child(${indexOfCurrentPage + 2})`,
];
}
// finding the "next page" link
const pageLinks = document.querySelectorAll("#pager_links > a");
const pageTextsIndex = [...pageLinks].map((a) => a.innerText).indexOf(">>");
if (pageTextsIndex >= 0) {
nextPageSelectors = [
...nextPageSelectors,
`#pager_links > a:nth-child(${pageTextsIndex + 2})`,
`#pager_links > a:nth-child(${pageTextsIndex + 1})`,
];
}
nextPageSelectors = [...nextPageSelectors, "#pager_links > a:last-child"];
const container =
tbodyEls[0].parentElement || getElementsByXPath("//table[@class='lista2t']")[0];
const infscrollOptions = {
path: nextPageSelectors.join(", "),
append: tbody.join(", "), // the table
hideNav: nav.join(", "),
scrollThreshold: 600,
};
console.log("infinitescroll options:", infscrollOptions);
const infScroll = new InfiniteScroll(container, infscrollOptions);
// upon appending a new page
infScroll.on("append", function (response, path, items) {
if (items.length) {
const lista2s = items[0].querySelectorAll(".lista2");
for (const lista2 of lista2s) {
tbodyEls[0].appendChild(lista2);
const columnCells = Array.from(lista2.childNodes).filter(
(x) => x.nodeName !== "#text"
);
appendColumnCell(columnCells[1]);
}
}
try {
// remove extra appended headers
tbodyEls[0].nextElementSibling.remove();
} catch (error) {}
// filter the new torrents that just arrived
updateSearch();
});
})();
}
} else if (isOnWrongTorrentLinkPage) {
// this torrent link has failed, then we have to go to the torrent page and download it
const torrentPageUrl = new URL(location.href).searchParams.get("tpageurl"); // get the previously injected page url here
if (torrentPageUrl) {
fetchDoc(torrentPageUrl).then((doc) => {
const torrentDownloadLink = doc.querySelector("td.lista a[onmouseover]");
location.assign(torrentDownloadLink.href);
document.addEventListener("DOMContentLoaded", () => document.close());
document.addEventListener("load", () => document.close());
setTimeout(() => window.close(), 1000);
});
} else {
console.warn('"tpageurl" is not in the location params!');
window.close();
}
} else if (/\/index\d+\.php/.test(location.pathname)) {
if (GM_config.get("autoExitIndexPhp")) {
location.assign("/torrents.php");
}
}
(function onLoad() {
console.log("loaded");
document.body.onclick = null; // remove annoying click listeners
// remove annoying search description
const searchDescription = document.querySelector("#SearchDescription");
if (searchDescription) searchDescription.remove();
// remove annoying signup form that doesn't work
const signinForm = document.querySelector('form[action="/login"]');
if (signinForm) signinForm.remove();
const signinTab = document.querySelector(
"body > table:nth-child(5) > tbody > tr > td > table > tbody > tr > td.header4"
);
if (signinTab) signinTab.remove();
if (GM_config.get("hideRecommendedTorrents")) {
// remove recommended torrents
const recTor = document.querySelector('tr > [valign="top"] > [onmouseout="return nd();"]');
if (recTor) recTor.closest("div").remove();
}
// remove "recommended torrents" title
const recTitle = getElementsByXPath('(//text()[contains(., "Recommended torrents :")])/../../..')[0];
if (recTitle) recTitle.remove();
// scroll the table to view (top of screen will be the first torrent)
const mainTable = document.querySelector(
"body > table:nth-child(6) > tbody > tr > td:nth-child(2) > div > table > tbody > tr:nth-child(1) > td > table.lista2t"
);
if (mainTable) mainTable.scrollIntoView();
// adding a dropdown list for mirrors
(function addMirrorsDropdown() {
const blankTab = document.querySelector("td.header:nth-child(1)");
if (!blankTab) return;
const mirrorsTab = document.createElement("td");
mirrorsTab.className = "header3";
mirrorsTab.innerText = "Switch to mirror site:";
function openAllMirrors() {
console.log("opening all mirrors");
for (const hostnames of mirrorsTab.querySelectorAll("option.mirrors-option")) {
window.open(extractUrlFromMirrorHost(hostnames), "_blank");
}
}
function extractUrlFromMirrorHost(hostnameText) {
const split = location.href.split("/").slice(2);
split[0] = hostnameText;
return split.join("/");
}
const mirrorsSelect = document.createElement("select");
mirrorsSelect.onchange = function () {
if (!this.value) return;
console.log("this:", this);
if (this.value === "Open ALL mirrors") {
openAllMirrors();
} else {
location.assign(extractUrlFromMirrorHost(this.value));
}
};
mirrorsTab.appendChild(mirrorsSelect);
for (const mirror of GM_config.get("mirrors").split("\n")) {
const option = document.createElement("option");
option.className = "mirrors-option";
option.value = mirror;
try {
option.innerText = new URL(mirror).hostname;
if (option.innerText !== location.hostname) {
mirrorsSelect.appendChild(option);
}
} catch (e) {}
}
// adding another last one (which would be THIS hostsname's url)
const option_thisHostname = document.createElement("option");
option_thisHostname.innerText = location.hostname;
option_thisHostname.setAttribute("selected", "");
mirrorsSelect.appendChild(option_thisHostname);
// another option to open ALL the hostnames in the new tab
const option_openAllMirrors = document.createElement("option");
option_openAllMirrors.innerText = "Open ALL mirrors";
option_openAllMirrors.id = "open-all-mirrors";
option_openAllMirrors.setAttribute("selected", "");
option_openAllMirrors.onclick = openAllMirrors;
mirrorsSelect.appendChild(option_openAllMirrors);
mirrorsSelect.selectedIndex--;
blankTab.after(mirrorsTab);
})();
// create settings tab
if (!document.querySelector("#settingsTab")) {
var lastTab = document.querySelector(
"tbody > tr > td > table > tbody > tr > td:last-child[class^='header3']" +
", body > div.topnav > div.postContUp > button:last-child"
);
var settingsTab = lastTab.cloneNode();
settingsTab.id = "settingsTab";
settingsTab.onclick = function (e) {
GM_config.open();
};
var a = document.createElement("a");
a.innerText = "⚙️ Script Settings";
settingsTab.appendChild(a);
settingsTab.style["background-color"] = "green";
lastTab.after(settingsTab);
}
})();
observeDocument((target) => {
if (isOnIndexPage) {
for (const tbodyEl of tbodyEls) {
const newCol = appendColumn(tbodyEl, "Thumbnails", "Cat.", addThumbnailColumn);
if (!newCol.header.querySelector(".decrementImageSizeBtn")) {
var decrementImageSizeBtn = createElement(
'<a href="#" style="margin: 2px" class="decrementImageSizeBtn">(-)</a>'
);
decrementImageSizeBtn.addEventListener("click", decrementImageSize);
var incrementImageSizeBtn = createElement(
'<a href="#" style="margin: 2px" class="incrementImageSizeBtn">(+)</a>'
);
incrementImageSizeBtn.addEventListener("click", incrementImageSize);
var nobr = document.createElement("nobr");
newCol.header.appendChild(nobr);
nobr.appendChild(decrementImageSizeBtn);
nobr.appendChild(incrementImageSizeBtn);
}
}
}
dealWithTorrents(target);
// group torrents
titleGroups = updateTorrentGroups();
for (const [torrentTitle, torrentAnchors] of Object.entries(titleGroups)) {
if (torrentAnchors.length > 1) {
if (GM_config.get("deduplicateTorrents")) {
Array.from(torrentAnchors)
.slice(1)
.forEach((el) => el.parentElement.parentElement.remove());
}
}
}
// remove links for adds that cover the screen
for (const x of document.querySelectorAll(
'[style*="2147483647"], a[href*="https://s4yxaqyq95.com/"]'
)) {
console.debug("removed redirect element:", x);
x.remove();
}
});
}
});
(function bindKeys() {
if (typeof Mousetrap === "undefined") return;
Mousetrap.bind(["space"], (e) => {
solveCaptcha(); // TODO: remove this, this is just for debugging
});
Mousetrap.bind("ctrl+/", function (e) {
GM_config.open();
});
Mousetrap.bind(["/"], (e) => {
console.log("clicking search input");
e.preventDefault();
const searchBar = document.querySelector("#searchinput");
searchBar.click();
searchBar.scrollIntoView();
searchBar.select();
searchBar.setSelectionRange(searchBar.value.length, searchBar.value.length);
});