-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrule34_improved.user.js
More file actions
2237 lines (1912 loc) · 82.2 KB
/
Copy pathrule34_improved.user.js
File metadata and controls
2237 lines (1912 loc) · 82.2 KB
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
// ==UserScript==
// @name Rule34.xxx Improved
// @namespace UserScript
// @version 3.2.4
// @description A lot of improvements for rule34.xxx
// @author Hentiedup, 0xC0LD, usnkw, kekxd
// @match https://rule34.xxx/*
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_setValue
// @icon data:image/ico;base64,AAABAAEAEBAAAAEAIABeAQAAFgAAAIlQTkcNChoKAAAADUlIRFIAAAAQAAAAEAgGAAAAH/P/YQAAAAlwSFlzAAALEwAACxMBAJqcGAAAARBJREFUOMudkjFOw0AQRd86mxugNCTyRaxIkZyCii5FOm5gi3NY5gacgcqFKX0R5NBE3CDgT7XW2llsYCTLO//P35n9u0aSedq8dvwjsjaNrBNnbdoTxhgAynUdEvU8m7qLfNB9kgDIT/srsR/d4pPI7zgzbrDO+kkRV38Su3OqXNfyAxDQ4y4v4mqQA7Jj4wAkYYwhP+3JUO+JzzuNnTv7eHS3+cCDrE3JTdgDH3t8uwub6F/d1K2MGxRxhZ0ShSZydY6z7sWNH00RV7y8Pw+w+9uHa65c19pFR300XwJ0bi4CtLWHfj2FRW73m2TBubmwSpZs7QGAVbKcx9wEv+kWwpBkdtGxL3B/f/0TJsl8A8Ga1pJm8pdUAAAAAElFTkSuQmCC
// @downloadURL https://github.com/kekxd666/rule34xxx-improved/raw/refs/heads/main/rule34_improved.user.js
// @updateURL https://github.com/kekxd666/rule34xxx-improved/raw/refs/heads/main/rule34_improved.user.js
// ==/UserScript==
// Tested on: Violent Monkey
// If you want to edit settings, go to the options page of your account...
// TODO:
// - this whole code needs to be refactored it's ugly (code order, inconsistent naming, need to SOC every func - rm repeating code)... makes it really unmaintainable xd lmao
// - add video support for "super favorites"
// - make slideshow work in favorites
// - make slideshow prefetch a few posts after content so it's not slow
// #region SETTINGS
function getSetting(settingName, settingDefault) {
let value = GM_getValue(settingName, null);
if (value == null) { GM_setValue(settingName, settingDefault); value = settingDefault; }
return value;
}
var setting_autoplayVideos_ = "autoplayVideos"; var setting_autoplayVideos = getSetting(setting_autoplayVideos_, true);
var setting_defaultVideoVolume_ = "defaultVideoVolume"; var setting_defaultVideoVolume = getSetting(setting_defaultVideoVolume_, 1);
var setting_useViewportDependentSize_ = "useViewportDependentSize"; var setting_useViewportDependentSize = getSetting(setting_useViewportDependentSize_, true);
var setting_viewportDependentHeight_ = "viewportDependentHeight"; var setting_viewportDependentHeight = getSetting(setting_viewportDependentHeight_, 70);
var setting_stretchImgVid_ = "stretchImgVid"; var setting_stretchImgVid = getSetting(setting_stretchImgVid_, true);
var setting_trueVideoSize_ = "trueVideoSize"; var setting_trueVideoSize = getSetting(setting_trueVideoSize_, false);
var setting_enableFavOnEnter_ = "enableFavOnEnter"; var setting_enableFavOnEnter = getSetting(setting_enableFavOnEnter_, true);
var setting_hideBlacklistedThumbnails_ = "hideBlacklistedThumbnails"; var setting_hideBlacklistedThumbnails = getSetting(setting_hideBlacklistedThumbnails_, true);
var setting_forceDarkTheme_ = "forceDarkTheme"; var setting_forceDarkTheme = getSetting(setting_forceDarkTheme_, true);
var setting_betterDarkTheme_ = "betterDarkTheme"; var setting_betterDarkTheme = getSetting(setting_betterDarkTheme_, true);
var setting_removeBloat_ = "removeBloat"; var setting_removeBloat = getSetting(setting_removeBloat_, true);
var setting_endlessScrolling_ = "endlessScrolling"; var setting_endlessScrolling = getSetting(setting_endlessScrolling_, true);
var setting_favFilter_ = "favFilter"; var setting_favFilter = getSetting(setting_favFilter_, true);
var setting_showFavPosts_ = "showFavPosts"; var setting_showFavPosts = getSetting(setting_showFavPosts_, true);
var setting_showFavPosts2_ = "showFavPosts2"; var setting_showFavPosts2 = getSetting(setting_showFavPosts2_, false);
var setting_embedVideo_ = "embedVideo"; var setting_embedVideo = getSetting(setting_embedVideo_, true);
var setting_thumbFav_ = "thumbFav"; var setting_thumbFav = getSetting(setting_thumbFav_, true);
var setting_mainPageExtra_ = "mainPageExtra"; var setting_mainPageExtra = getSetting(setting_mainPageExtra_, true);
var setting_mainPageExtraAutoExpand_ = "mainPageExtraAutoExpand"; var setting_mainPageExtraAutoExpand = getSetting(setting_mainPageExtraAutoExpand_, true);
var setting_slideShow_ = "slideShow"; var setting_slideShow = getSetting(setting_slideShow_, true);
var setting_videoVolumeScroll_ = "videoVolumeScroll"; var setting_videoVolumeScroll = getSetting(setting_videoVolumeScroll_, true);
var setting_loopVideo_ = "loopVideo"; var setting_loopVideo = getSetting(setting_loopVideo_, false);
var setting_biggerThumbs_ = "biggerThumbs"; var setting_biggerThumbs = getSetting(setting_biggerThumbs_, true);
var setting_taglistpins_ = "taglistpins"; var setting_taglistpins = getSetting(setting_taglistpins_, ["sort:score", "animated"]);
// #endregion
// #region CSS STYLES
var css_root = `
:root { --favdisplay: inline; }
.fav {
opacity: 0.4;
box-sizing: border-box;
background-clip: padding-box;
padding: 5px;
background: rgba(121, 28, 106, 0.5);
border: 3px dashed hotpink;
}
.sfav {
opacity: 0.4;
box-sizing: border-box;
background-clip: padding-box;
padding: 5px;
background: rgba(28, 121, 47, 0.5);
border: 3px dashed lime;
}
.fav.sfav {
opacity: 0.4;
background-clip: padding-box;
background: linear-gradient(to bottom, green, purple) !important;
border-top: 3px dashed lime;
border-left: 3px dashed lime;
border-right: 3px dashed hotpink;
border-bottom: 3px dashed hotpink;
}
.thumbFav {
position: absolute;
top: 20%;
left: 80%;
width: 20%;
height: 20%;
color: hotpink;
text-align: center;
font: bold 19px arial, serif;
border: 3px solid hotpink;
background-color: rgba(20, 20, 20, 0.8);
transform: translate(-50%, -50%);
display: none;
border-radius: 50%;
}
.r34imp_button {
padding: 1px;
color: lime;
background-color: #7fff0020;
cursor: pointer;
border-color: green;
margin: 3px;
}
.r34imp_slideshow_current {
border: 5px dotted red !important;
box-sizing: border-box;
}
`;
GM_addStyle(css_root);
var css_betterDarkTheme = `
* { --c-bg: #101010; --c-bg-alt: #101010; --c-bg-highlight: #202020; }
body { background-image: none !important; color: white !important; background-color: #101010 !important }
table.highlightable td { border-color: #023C00; }
input[type="text"], input[type="password"], input[type="email"], textarea, select { color: lime; background-color: black; border-color: green; border-style:solid; margin: 1px;}
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, textarea:focus, select:focus { background-color: #101010 !important; }
.awesomplete [hidden] { display: none }
.awesomplete .visually-hidden { position: absolute; }
.awesomplete { display: inline-block; position: relative }
.awesomplete>input { display: block }
.awesomplete>ul:empty { display:none }
.awesomplete>ul {
position: absolute;
z-index: 1;
min-width: 100%;
box-sizing: border-box;
list-style: none;
padding: 0;
margin: 0;
background: black;
padding: 3px;
margin: 0;
color: hotpink;
background: linear-gradient(to top left, #002404, black);
border-color: lime;
border-width: 1px;
text-shadow: none;
}
@supports(transform:scale(0)) {
.awesomplete>ul { transition:.1s cubic-bezier(1,1,1,1); transform-origin:1.43em -.43em; }
.awesomplete>ul[hidden],
.awesomplete>ul:empty { opacity: 0; transform: scale(0); display: block; ransition-timing-function: ease; }
}
.awesomplete>ul:before { display: none }
.awesomplete>ul>li { cursor:pointer; color: hotpink; background: transparent; border: 1px solid transparent; position: relative; padding: 1px; }
.awesomplete>ul>li:hover { cursor:pointer; color: hotpink; background: indigo; border: 1px solid transparent; }
.awesomplete>ul>li[aria-selected=true] { cursor:pointer; color: hotpink; background: indigo; border: 1px solid lime; }
.awesomplete mark { cursor:pointer; color: lime; background: transparent; }
.awesomplete li:hover mark { cursor:pointer; color: lime; background: transparent; }
.awesomplete li[aria-selected=true] mark { cursor:pointer; color: lime; background: transparent; }
.r34imp_slider {
margin: 0 5px 0 5px;
padding: 0;
display: inline-block;
-webkit-appearance: none;
width: 60%;
height: 10px;
border-radius: 5px;
border: solid 1px green;
background: #101010;
opacity: 0.8;
-webkit-transition: .1s;
transition: opacity .1s;
}
.r34imp_slider:hover { opacity: 1; }
.r34imp_slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 10px;
height: 10px;
border-radius: 50%;
background: #4CAF50;
cursor: pointer;
}
.r34imp_slider::-moz-range-thumb {
width: 15px;
height: 15px;
border-radius: 50%;
background: #4CAF50;
cursor: pointer;
}
#delayRange { width: 25% !important; }
.button-remove {
background-color: transparent;
border: none;
color: gray;
cursor: pointer;
}
.button-remove:active {
filter: none !important;
color: black;
background-color: gray;
border-radius: 5px;
}
.checkboxContainer {
display: inline-block;
position: relative;
padding-left: 15px;
margin-bottom: 5px;
margin-right: 5px;
cursor: pointer;
font-size: 22px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
height: 35px;
width: 20px;
}
#trcheckbox {
width: 15px;
height: 15px;
right: 1px;
top: 1px;
padding: 0;
margin: 0px 15px 0px px;
}
#trcheckbox .checkmark {
height: 13px;
width: 13px;
padding: 0 !important;
margin: 0 !important;
}
/* Hide the browser's default checkbox */
.checkboxContainer input {
top: 4px;
left: 6px;
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
/* Create a custom checkbox */
.checkmark {
position: absolute;
top: 3px;
left: 5px;
height: 25px;
width: 25px;
background-color: #202020;
border: 2px green solid;
border-radius: 3px;
transition: all .2s ease;
}
.checkboxContainer:hover input ~ .checkmark { background-color: #404040; }
.checkboxContainer input:checked ~ .checkmark { background-color: lime; }
.checkboxContainer input:checked ~ .checkmark:after { display: block; }
`;
var css_post = `
#postbar {
margin: 0;
padding 30px;
border: solid 1px var(--c-link-soft);
display: inline-block;
width: auto;
background-color: var(--c-bg-highlight);
}
.custom-button {
background-color: transparent;
cursor: pointer;
width: auto;
padding: 3px;
margin: 1px;
border-radius: 20px;
}
.custom-button:hover { background-color: rgba(100,255,100,.2); }
.custom-button:active { background-color: rgba(255,255,255,1); }
#isinfav, #isinfav2 {
display: inline-block;
margin-left: 10px;
font-size: 18px;
background-color: pink;
border: 1px deeppink solid;
}
` + (setting_useViewportDependentSize ?
((setting_stretchImgVid ? `
#gelcomVideoContainer {
width: auto !important;
max-width: 100% !important;
height: ` + setting_viewportDependentHeight + `vh !important;
}` : "") + `
#image {
width: auto !important;
max-width: 100% !important;
` + (setting_stretchImgVid ? "" : "max-") + `height: ` + setting_viewportDependentHeight + `vh !important;
}`) : "");
if (setting_biggerThumbs) {
GM_addStyle(".thumb { width: 250px !important; height: 250px !important; }")
}
// #endregion
// #region UTILS / MISC
// get thumbnail post id
function getPostID(element) {
let id = element.id.replace('s', '').replace('p', '');
if (id != "") {
return id;
}
const link = element.querySelector("a");
return link.id.replace('p', '');
}
function GetThumb(id) {
let contentURL = "";
httpGet("index.php?page=post&s=view&id=" + id, function(response) {
let doc = new DOMParser().parseFromString(response, "text/html");
let as = doc.body.getElementsByTagName("a");
for (let i = 0; i < as.length; i++) {
if (as[i].getAttribute("href").includes("http://saucenao.com/search.php?")) {
contentURL = as[i].getAttribute("href").split("&url=", 2)[1];
break;
}
}
}, false);
return contentURL;
}
// get original image/video url from id
function GetOG(id) {
// get/show content
let contentURL = "";
httpGet("index.php?page=post&s=view&id=" + id, function(response) {
let doc = new DOMParser().parseFromString(response, "text/html");
let metas = doc.body.getElementsByTagName("meta");
for (let i = 0; i < metas.length; i++) {
if (metas[i].getAttribute("property") == "og:image") {
contentURL = metas[i].getAttribute("content");
break;
}
}
}, false);
return contentURL;
}
function favlist_contains(id) {
return GM_getValue("favlist", []).includes(id);
}
function favlist2_contains(postID) {
if (!postID) {
return false;
}
let favlist = GM_getValue("favlist2", []);
for (let i = 0; i < favlist.length; i++) {
if (favlist[i][0] == postID) {
return true;
}
}
return false;
}
function showFavPosts_elementUpdate(element, isfav, isfav2) {
if (isfav && !element.classList.contains("fav")) {
element.style.position = "relative";
element.classList.add("fav");
if (setting_thumbFav) {
element.onmouseenter = null;
element.onmouseleave = null;
}
}
if (isfav2 && !element.classList.contains("sfav")) {
element.classList.add("sfav");
}
if (isfav || isfav2) {
element.style = "display: var(--favdisplay);"
}
}
// add custom css to show that the post is in fav
function showFavPosts_elementCheck(element) {
if (element == null) {
return;
}
let id = getPostID(element);
let isfav = favlist_contains(id);
let isfav2 = favlist2_contains(id);
showFavPosts_elementUpdate(element, isfav, isfav2);
}
// show red heart for fav
function updateSubnavbar_p1(postID) {
let ul_subnavbar = document.getElementById("subnavbar");
for (let i = 0; i < ul_subnavbar.childNodes.length; i++) {
if (ul_subnavbar.childNodes[i].id == "isinfav") {
return;
}
}
if (!favlist_contains(postID)) {
return;
}
let div_isinfav = document.createElement("div");
div_isinfav.id = "isinfav";
div_isinfav.title = "Post is in Favorites."
div_isinfav.innerHTML = "❤️";
ul_subnavbar.appendChild(div_isinfav);
}
// show green heart for super fav
function updateSubnavbar_p2(postID) {
let ul_subnavbar = document.getElementById("subnavbar");
for (let i = 0; i < ul_subnavbar.childNodes.length; i++) {
if (ul_subnavbar.childNodes[i].id == "isinfav2") {
return;
}
}
if (!favlist2_contains(postID)) {
return
}
let div_isinfav2 = document.createElement("div");
div_isinfav2.id = "isinfav2";
div_isinfav2.title = "Post is in Super Favorites."
div_isinfav2.innerHTML = "💚";
ul_subnavbar.appendChild(div_isinfav2);
}
function updateSubnavbar(postID) {
if (!isPage_post || !setting_showFavPosts) {
return;
}
updateSubnavbar_p1(postID);
updateSubnavbar_p2(postID);
}
// add post to favorites, like it & add it to favlist
function favPost(id, callback) {
post_vote(id, 'up'); // like
addFav(id); // add to fav
// wait for server to respond
let timer = setInterval(function() {
let div_notice = document.getElementById("notice");
if (div_notice.innerHTML.includes("You are not logged in")) {
clearInterval(timer);
document.title = id + ": no login?";
return;
}
if (!div_notice.innerHTML.includes("Post added to favorites") && !div_notice.innerHTML.includes("Post already in your favorites")) {
document.title = id + ": ...";
return;
}
if (div_notice.innerHTML.includes("Post added to favorites")) {
document.title = id + ": +";
} else if (div_notice.innerHTML.includes("Post already in your favorites")) {
document.title = id + ": !";
} else {
document.title = id + ": ?";
}
clearInterval(timer);
// add to favlist
if (setting_showFavPosts) {
let favlist = GM_getValue("favlist", []);
if (favlist.includes(id)) {
div_notice.innerHTML += ", Post already in your favlist";
document.title += "!";
} else {
favlist.push(id);
GM_setValue("favlist", favlist);
div_notice.innerHTML += ", Added to favlist";
document.title += "+";
}
callback();
}
}, 100);
}
function favPost2(postID) {
if (favlist2_contains(postID)) {
return;
}
let link = GetThumb(postID);
if (link != "") {
let favlist = GM_getValue("favlist2", []);
favlist.push([postID, link]);
GM_setValue("favlist2", favlist);
updateSubnavbar(postID);
}
}
// get page html
function httpGet(url, callback, async) {
let xhr = new XMLHttpRequest();
xhr.open("GET", url, async);
xhr.onload = function(e) {
if (xhr.readyState === 4) {
// xhr.status === 200
callback(xhr.responseText);
}
};
xhr.onerror = function(e) {
console.error(xhr.statusText);
};
xhr.send(null);
}
function sleep(milliseconds) {
return new Promise(resolve => setTimeout(resolve, milliseconds));
}
var originalTitle = document.title;
var isPage_post = document.location.href.includes("index.php?page=post&s=view");
var isPage_posts = document.location.href.includes("index.php?page=post&s=list");
var isPage_pool = document.location.href.includes("index.php?page=pool&s=show");
var isPage_fav = document.location.href.includes("index.php?page=favorites&s=view");
var isPage_opt = document.location.href.includes("index.php?page=account&s=options");
var isPage_main = (document.location.href == "http://rule34.xxx/" || document.location.href == "https://rule34.xxx/");
// add extra code to remove the id from favlist, when you press the remove button on the favorites page
function showFavPosts_injectRemoveCode(element) {
if (!isPage_fav) {
return;
}
const parent = element.parentElement;
if (parent.querySelector(".button-remove") != null) {
return;
}
const a_remove = parent.childNodes[5];
if (a_remove == null) { return; }
a_remove.remove();
let id = getPostID(element);
let button_remove = document.createElement("button");
button_remove.className = "button-remove";
button_remove.style = "padding-top: 15px;";
button_remove.title = "remove: " + id;
button_remove.innerHTML = "❌ Remove";
button_remove.onclick = function() {
let favlist = GM_getValue("favlist", []);
GM_setValue("favlist", favlist.filter(e => e !== id));
document.location = 'index.php?page=favorites&s=delete&id=' + id;
};
parent.appendChild(button_remove);
}
// if blacklisted remove
function hideBlacklistedThumbnails_check(element) {
if (element == null || element.className != "thumb blacklisted-image") {
return;
}
element.remove();
}
// add fav button on post
function thumbFav_check(element) {
if (element == null || element.classList.contains("fav") || element.classList.contains("4fav")) {
return;
}
element.classList.add("4fav");
element.style.position = "relative";
let button_favOnPost = document.createElement('button');
button_favOnPost.innerHTML = "♥";
button_favOnPost.className = "thumbFav";
button_favOnPost.title = "Add to favorites";
element.appendChild(button_favOnPost);
button_favOnPost.onmousedown = function() {
button_favOnPost.remove();
let id = getPostID(element);
favPost(id, function() {
showFavPosts_elementCheck(element);
updateNavbar(id);
});
}
element.onmouseenter = function() {
button_favOnPost.style.display = "block";
};
element.onmouseleave = function() {
button_favOnPost.style.display = "none";
};
}
function embedDefaultVideo() {
let div_gelcomVideoContainer = document.getElementById("gelcomVideoContainer");
if (!div_gelcomVideoContainer) {
return;
}
// set style of video as the container
let video_og = document.createElement("video");
video_og.id = "videoEmbeded";
video_og.controls = true;
video_og.volume = setting_defaultVideoVolume;
video_og.autoplay = setting_autoplayVideos;
video_og.style.cssText = div_gelcomVideoContainer.style.cssText + (setting_trueVideoSize ? "" : (" max-height: " + setting_viewportDependentHeight + "vh"));
video_og.addEventListener('volumechange', (event) => {
GM_setValue(setting_defaultVideoVolume_, video_og.volume);
setting_defaultVideoVolume = video_og.volume;
});
if (setting_loopVideo) {
video_og.loop = true;
}
if (setting_videoVolumeScroll) {
let current = 0;
let MouseWheelHandler = function(e) {
e.preventDefault();
e.stopPropagation();
e = window.event || e;
let delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
current = current + delta;
let curVol = video_og.volume;
if (delta == 1) {
curVol += 0.05;
} else if (delta == -1) {
curVol -= 0.05;
}
if (curVol > 1) {
video_og.volume = curVol = 1;
} else if (curVol < 0) {
video_og.volume = curVol = 0;
} else {
video_og.volume = curVol;
}
return false;
};
if (video_og.addEventListener) {
// IE9, Chrome, Safari, Opera
video_og.addEventListener("mousewheel", MouseWheelHandler, false);
// Firefox
video_og.addEventListener("DOMMouseScroll", MouseWheelHandler, false);
}
}
// get player src
let video_gelcomVideoPlayer = document.getElementById("gelcomVideoPlayer");
// let link = document.getElementById('stats').nextElementSibling.childNodes[3].childNodes[3].childNodes[0];
video_og.src = video_gelcomVideoPlayer.currentSrc;
div_gelcomVideoContainer.style.display = "none";
div_gelcomVideoContainer.parentNode.insertBefore(video_og, div_gelcomVideoContainer);
// //div_gelcomVideoContainer.remove(); // can't remove or will get a massive error spam in console
//playerCont.parentNode.replaceChild(vid, playerCont);
}
if (setting_hideBlacklistedThumbnails) {
let elements = document.getElementsByClassName("thumb blacklisted-image");
while (elements[0]) {
elements[0].remove();
}
}
if (setting_thumbFav) {
let elements = document.getElementsByClassName("thumb");
for (let i = 0; i < elements.length; i++) {
thumbFav_check(elements[i]);
}
}
// remove clicker ad and other ads
if (setting_removeBloat) {
let a_links = document.getElementsByTagName("a");
for (i = a_links.length - 1; i >= 0; i--) {
//if (items[i].href.includes("clicker")) { items[i].remove(); }
if (a_links[i].href.includes("https://rule34.xxx/hwspecial.php")) {
a_links[i].remove();
}
if (a_links[i].href.includes("https://buymyshit.moneygrubbingwhore.com")) {
a_links[i].remove();
}
// will add more if rule34 adds more
}
}
if (setting_forceDarkTheme) {
document.cookie = "theme=dark; Path=/;"
//Cookie.create('theme', 'dark');
// disable default css
document.querySelectorAll('link[rel=stylesheet]').forEach(function(node) {
if (node.href.includes("desktop.css")) {
node.disabled = true;
}
if (node.href.includes("h2-mobile.css")) {
node.disabled = true;
}
});
// append dark theme
let head = document.getElementsByTagName('head')[0];
let link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'https://rule34.xxx/css/desktop_bip.css?7';
link.media = 'screen';
head.appendChild(link);
// append even better dark theme css
if (setting_betterDarkTheme) {
GM_addStyle(css_betterDarkTheme)
}
}
// #endregion
// #region OPTIONS PAGE
if (isPage_opt) {
let tbody_options = document.body.getElementsByTagName("tbody")[0];
function makeCB(setv_, setv) {
let label = document.createElement("label");
label.className = "checkboxContainer";
let input = document.createElement("input");
input.type = "checkbox";
input.checked = GM_getValue(setv_, setv);
input.addEventListener("change", function() {
GM_setValue(setv_, this.checked);
setv = this.checked;
});
let span = document.createElement("span");
span.className = "checkmark";
label.appendChild(input);
label.appendChild(span);
return label;
}
function makeCB_form(setv_, setv, name, desc) {
let tr = document.createElement("tr");
let th = document.createElement("th");
let label = document.createElement("label");
label.className = "block";
label.innerHTML = name;
th.appendChild(label);
let p = document.createElement("p");
p.innerHTML = desc;
th.appendChild(p);
tr.appendChild(th);
let td = document.createElement("td");
td.appendChild(makeCB(setv_, setv));
tr.appendChild(td);
tbody_options.appendChild(tr);
}
makeCB_form(setting_autoplayVideos_, setting_autoplayVideos, "AutoPlay", "Automatically play the video");
{
let tr = document.createElement("tr");
let th = document.createElement("th");
let label = document.createElement("label");
label.className = "block";
label.innerHTML = "Default Video Volume";
th.appendChild(label);
tr.appendChild(th);
let data = document.createElement("td");
let slider = document.createElement("input");
slider.type = "range";
slider.min = "0";
slider.max = "100";
slider.value = GM_getValue(setting_defaultVideoVolume_, setting_defaultVideoVolume) * 100;
slider.className = "r34imp_slider";
let slider_info = document.createElement("p");
slider_info.style = "display: inline-block;";
slider_info.innerHTML = "Volume: " + slider.value + "%";
slider.oninput = function() {
slider_info.innerHTML = "Volume: " + slider.value + "%";
GM_setValue(setting_defaultVideoVolume_, slider.value / 100);
}
data.appendChild(slider);
data.appendChild(slider_info);
tr.appendChild(data);
tbody_options.appendChild(tr);
} {
let row = document.createElement("tr");
let header = document.createElement("th");
let title = document.createElement("label");
title.className = "block";
title.innerHTML = "Image/Video Height";
let p = document.createElement("p");
p.innerHTML = "Viewport Dependent Height";
header.appendChild(title);
header.appendChild(p);
row.appendChild(header);
let data = document.createElement("td");
let slider = document.createElement("input");
slider.type = "range";
slider.min = 0;
slider.max = 100;
slider.value = GM_getValue(setting_viewportDependentHeight_, setting_viewportDependentHeight);
slider.className = "r34imp_slider";
let slider_info = document.createElement("p");
slider_info.style = "display: inline-block;";
slider_info.innerHTML = slider.value + "%";
slider.oninput = function() {
slider_info.innerHTML = slider.value + "%";
GM_setValue(setting_viewportDependentHeight_, slider.value);
}
data.appendChild(makeCB(setting_useViewportDependentSize_, setting_useViewportDependentSize));
data.appendChild(slider);
data.appendChild(slider_info);
row.appendChild(data);
tbody_options.appendChild(row);
}
makeCB_form(setting_stretchImgVid_, setting_stretchImgVid, "Stretch Image/Video", "This overrides 'True Video Size'");
makeCB_form(setting_trueVideoSize_, setting_trueVideoSize, "True Video Size", "Resizes videos to their true size");
makeCB_form(setting_enableFavOnEnter_, setting_enableFavOnEnter, "Enable Fav On Enter", "Use the ENTER key on your keyboard to add a post to your favorites");
makeCB_form(setting_hideBlacklistedThumbnails_, setting_hideBlacklistedThumbnails, "Hide Blacklisted Thumbnails", "Hide blacklisted thumbnails on the main post page");
makeCB_form(setting_forceDarkTheme_, setting_forceDarkTheme, "Force Dark Theme", "Force rule34's dark theme on every page");
makeCB_form(setting_betterDarkTheme_, setting_betterDarkTheme, "Better Dark Theme", "(must enable 'Force Dark Theme') Use a custom CSS dark theme with the rule34's dark theme");
makeCB_form(setting_removeBloat_, setting_removeBloat, "Remove Bloat", "Removes: hentai clicker game AD, and other bullshit.");
makeCB_form(setting_endlessScrolling_, setting_endlessScrolling, "Endless Scrolling", "When you get to the bottom of the current page it will automatically append the content from the next page on the current page");
makeCB_form(setting_favFilter_, setting_favFilter, "Favorites Filter", "Adds a searchbox for tag(s) in favorites");
makeCB_form(setting_showFavPosts_, setting_showFavPosts, "Show Fav Posts", "Shows you which posts are in your favorites while browsing");
makeCB_form(setting_showFavPosts2_, setting_showFavPosts2, "Hide Fav Posts", "(must enable 'Show Fav Posts') Hides favorites while browsing");
makeCB_form(setting_embedVideo_, setting_embedVideo, "Embed Video", "Replace rule34's player with the default browser player");
makeCB_form(setting_thumbFav_, setting_thumbFav, "Thumb Fav", "Adds a fav button on each post while browsing");
makeCB_form(setting_mainPageExtra_, setting_mainPageExtra, "Main Page Extra", "Adds a button (on the main page) that expands to a form that allows you to bookmark tags and see super favorites");
makeCB_form(setting_mainPageExtraAutoExpand_, setting_mainPageExtraAutoExpand, "Auto Expand Main Page Extra", "Auto click the button that shows forms for bookmarking tags & viewing super favorites");
makeCB_form(setting_slideShow_, setting_slideShow, "Slideshow", "Adds a button in the top right corner, when browsing, to activate slideshow mode");
makeCB_form(setting_videoVolumeScroll_, setting_videoVolumeScroll, "Video Volume Scroll", "Control video volume with mouse scroll wheel, must 'Embed Video' if viewing from post's page...");
makeCB_form(setting_loopVideo_, setting_loopVideo, "Loop video", "Make the player loop the video.")
makeCB_form(setting_biggerThumbs_, setting_biggerThumbs, "Bigger Thumbnails", "Make all thumbnails 250x250 pixels.")
}
// #endregion
// #region FAVORITES PAGE / SEARCHING/FILTERING
if (isPage_fav) {
//// remove stupid <br>s on fav page wtf... why are they here
//let bodyc = document.getElementById("body").children;
//for (let i = 0; i < bodyc.length; i++) { if (bodyc[i].tagName === "BR") { bodyc[i].remove(); } }
// container for all the controls in favorites
let div_favcontrols = document.createElement("div");
div_favcontrols.id = "favcontrols";
div_favcontrols.style = "margin: 2px 5px 10px 5px;"
document.getElementById("header").parentNode.insertBefore(div_favcontrols, document.getElementById("header").nextSibling);
if (setting_favFilter) {
function slideShow_removeContent() {
let elements = document.getElementsByClassName("thumb");
while (elements[0]) {
elements[0].remove();
}
}
let imagesAdded = 0;
let shouldStop = false;
// start search
let base = /(.*)&pid=/gm.exec(document.location.href) == null ? document.location.href : /(.*)&pid=/gm.exec(document.location.href)[1];
let reg = /pid=([0-9]*)/gm;
let paginator = document.getElementById("paginator");
let cont = document.getElementById("favcontrols");
// textbox for tags
let input = document.createElement("input");
input.style = "width: 20%; display: inline-block;";
input.type = "text";
input.addEventListener("keydown", function(event) {
if (event.key === 'Enter') {
event.preventDefault();
main_favFilter();
}
});
// filter/search button
let btn_filter = document.createElement("button");
btn_filter.style = "display: inline-block;";
btn_filter.id = "filterButton";
btn_filter.title = "Start search"
btn_filter.innerHTML = "Filter";
btn_filter.onclick = function() {
main_favFilter();
}
// stop button
let btn_stop = document.createElement("button");
btn_stop.style = "display: inline-block;";
btn_stop.title = "Stop search";
btn_stop.innerHTML = "Stop";
btn_stop.onclick = function() {
shouldStop = true;
}
// help button
let btn_help = document.createElement("button");
btn_help.style = "display: inline-block;";
btn_help.title = "Show help";
btn_help.innerHTML = "Help";
btn_help.onclick = function() {
alert(
"The slider sets the time between requests.\n" +
"This is not an officially supported service.\n" +
"If you make too many requests, you might get temporarily blocked.\n" +
"The recommended time slider delay is 1000ms\n" +
"If the search takes too long try decreasing the time between requests."
);
}
// slider
let slider = document.createElement("input");
slider.type = "range";
slider.min = "0";
slider.max = "4000";
slider.value = 500;
slider.className = "r34imp_slider";
slider.id = "delayRange";
// slider speed label
let txt_speed = document.createElement("p");
txt_speed.style = "display: inline-block;";
txt_speed.innerHTML = "Request Speed: " + slider.value + "ms";
slider.oninput = function() {
txt_speed.innerHTML = "Request Speed: " + slider.value + "ms";
}
// current / max
let txt_curmax = document.createElement("p");
txt_curmax.id = "curmax";
txt_curmax.style = "margin: 0;";
// url - status
let txt_status = document.createElement("p");
txt_status.id = "status";
txt_status.style = "margin: 0;";
// loaded images count
let txt_imageCount = document.createElement("p");
txt_imageCount.id = "imageCount"
txt_imageCount.style = "margin: 0;";
// clear images button
let btn_clear = document.createElement("button");
btn_clear.style = "display: inline-block;";
btn_clear.title = "Hide all content";
btn_clear.innerHTML = "Clear";