forked from Mayriad/Mayriads-EH-Master-Script
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMayriads-EH-Master-Script.user.js
5068 lines (4721 loc) · 264 KB
/
Mayriads-EH-Master-Script.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
// ==UserScript==
// @name Mayriad's EH Master Script
// @namespace https://github.com/Mayriad
// @version 2.2.2
// @author Mayriad
// @description Adds dozens of features to E-Hentai
// @icon https://e-hentai.org/favicon.ico
// @updateURL https://openuserjs.org/meta/Mayriad/Mayriads_EH_Master_Script.meta.js
// @downloadURL https://openuserjs.org/install/Mayriad/Mayriads_EH_Master_Script.user.js
// @supportURL https://github.com/Mayriad/Mayriads-EH-Master-Script
// @match https://e-hentai.org/*
// @match https://exhentai.org/*
// @match https://repo.e-hentai.org/*
// @match https://upld.e-hentai.org/*
// @match https://forums.e-hentai.org/*
// @match https://hentaiverse.org/*
// @connect self
// @connect e-hentai.org
// @connect ehtracker.org
// @connect hentaiverse.org
// @connect *
// @run-at document-start
// @grant GM.setValue
// @grant GM.getValue
// @grant GM.xmlHttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_xmlhttpRequest
// @grant GM_download
// @copyright 2015-2022, Mayriad (https://github.com/Mayriad)
// @license GPL-3.0-or-later; https://www.gnu.org/licenses/gpl-3.0-standalone.html
// ==/UserScript==
/**
* @author Mayriad
* @copyright 2015-2022 Mayriad
* @license GNU General Public License v3.0 or later
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see
* <https://www.gnu.org/licenses/>.
*/
// Userscript download: https://openuserjs.org/scripts/Mayriad/Mayriads_EH_Master_Script
// GitHub repository: https://github.com/Mayriad/Mayriads-EH-Master-Script
// User manual: https://github.com/Mayriad/Mayriads-EH-Master-Script/blob/master/README.md
// Support thread: https://forums.e-hentai.org/index.php?showtopic=233955
/* global GM, alert, XPathResult, MutationObserver, DOMParser, Blob */
;(function () {
'use strict'
// JSDoc definitions -------------------------------------------------------------------------------------------------
/**
* A callback function that handles a click mouse event.
*
* @callback clickEventHandler
* @param {MouseEvent} [clickEvent] - The event object passed to this event handler on click.
*/
// Initialisation ----------------------------------------------------------------------------------------------------
// Violentmonkey now also supports GM.* aliases that are compatible with GM API v4, but GM.download() is still not
// supported. Therefore, GM.download() can be used to check the userscript engine.
const api = {
setValue: GM.setValue,
getValue: GM.getValue,
xmlHttpRequest: GM.xmlHttpRequest,
info: GM.info
}
if (typeof GM.download !== 'undefined') {
// Tampermonkey
api.download = GM.download
api.version = 'v4'
} else {
// Violentmonkey
api.version = 'v3'
}
// Initialise the settings using the default values below before reading actual settings from the userscript storage.
let settings = {
applyDarkTheme: {
featureEnabled: false
},
applyLightTheme: {
featureEnabled: false
},
relocateMpvThumbnails: {
featureEnabled: true
},
hideMpvToolbar: {
featureEnabled: true
},
applyAdditionalFilters: {
featureEnabled: false,
ratedFilterEnabled: false,
ratedFilterStars: '',
ratedFilterExceptionEnabled: false,
ratedFilterExceptions: 'the favorite list and the popular list',
favoritedFilterEnabled: false,
favoritedFilterCategories: '',
favoritedFilterExceptionEnabled: false,
titleFilterEnabled: false,
titleFilterType: 'one of the keywords',
titleFilterKeywords: '',
titleFilterExceptionEnabled: false,
titleFilterExceptions: 'the favorite list and the popular list'
},
applyTextFilters: {
featureEnabled: false,
commentatorFilterEnabled: false,
commentatorFilterUsernames: '',
commentFilterEnabled: false,
commentFilterKeywords: '',
posterFilterEnabled: false,
posterFilterType: 'forum posts',
posterFilterUsernames: '',
postFilterEnabled: false,
postFilterType: 'forum posts',
postFilterKeywords: '',
spamFilterEnabled: false
},
applyDesignFixes: {
featureEnabled: true
},
improveNavigationBar: {
featureEnabled: true,
unreadCountsEnabled: true
},
addVigilanteLinks: {
featureEnabled: true
},
showAlternativeRating: {
featureEnabled: true,
hideStarsEnabled: false
},
addGuideLinks: {
featureEnabled: true
},
applySubjectiveFixes: {
featureEnabled: true
},
emptyCategoryFilter: {
featureEnabled: false
},
fitThumbnailTitles: {
featureEnabled: true
},
colourCodeGalleries: {
featureEnabled: true
},
fitViewerToScreen: {
featureEnabled: true
},
fitMpvToScreen: {
featureEnabled: true,
makeDefaultEnabled: true,
mpsModeEnabled: false,
seamlessModeEnabled: false
},
useAutomatedDownloads: {
featureEnabled: false,
torrentDownloadEnabled: true,
torrentRequirementsEnabled: true,
minimumSeedNumber: 3,
ignoreRequirementsSize: 2048,
personalisedTorrentEnabled: true,
apiTorrentDownloadEnabled: true,
archiveDownloadEnabled: true,
archiveDownloadType: 'original archive',
appendIdentifiersEnabled: false,
pageDownloadEnabled: true,
pageDownloadNumber: 3,
pageRangeDownloadEnabled: true,
downloadProtectionEnabled: true,
hideThumbnailEnabled: true,
downloadAlertsEnabled: true
},
openGalleriesSeparately: {
featureEnabled: true,
directMpvEnabled: false
},
addJumpButtons: {
featureEnabled: true,
jumpButtonStyle: 'slide-in rectangular buttons',
jumpBehaviourStyle: 'smoothly'
},
parseExternalLinks: {
featureEnabled: true
},
removeMpvTooltips: {
featureEnabled: false
},
collectDawnReward: {
featureEnabled: true
},
script: {
version: api.info.script.version,
filterButtonEnabled: false,
firefoxCompatibilityEnabled: false,
buttonTooltipEnabled: true
}
}
// These persistent variables are stored and used separately from the settings, and the values below are their default
// values.
let values = {
improveNavigationBar: {
lastKarmaRead: ''
},
useAutomatedDownloads: {
pagesToDownload: {}
},
collectDawnReward: {
lastCollectedReward: 0
},
script: {
version: api.info.script.version
}
}
// These are the possible values for the setting keys that accept pre-defined options, and hence also for the
// corresponding option selectors in the control panel.
const options = {
applyAdditionalFilters: {
ratedFilterExceptions: ['the favorite list', 'the popular list', 'the favorite list and the popular list'],
titleFilterType: ['one of the keywords', 'one match with the regular expression'],
titleFilterExceptions: ['the favorite list', 'the popular list', 'the favorite list and the popular list']
},
applyTextFilters: {
posterFilterType: ['forum posts', 'forum threads', 'forum posts and threads'],
postFilterType: ['forum posts', 'forum threads', 'forum posts and threads']
},
useAutomatedDownloads: {
archiveDownloadType: ['original archive', 'resample archive', 'H@H 780x', 'H@H 980x', 'H@H 1280x',
'H@H 1600x', 'H@H 2400x', 'H@H original']
},
addJumpButtons: {
jumpButtonStyle: ['fade-in circular buttons', 'slide-in rectangular buttons'],
jumpBehaviourStyle: ['smoothly', 'instantly']
}
}
// These are the notification messages that will be shown to the user when needed.
const messages = {
applyAdditionalFilters: {
ratedFilterStars: {
emptyInputError: 'Since the rated gallery filter has been enabled, please enter the numbers of stars to ' +
'hide the galleries to which you have given these stars.',
invalidInputError: 'Invalid input detected. Please enter the numbers of stars in a proper format to hide ' +
'the galleries to which you have given these stars. Please note that the possible numbers are 0.5, 1.0, ' +
'1.5, 2.0 ... 4.5, 5.0. You can omit the leading zero in a decimal and the decimal part in an integer, ' +
'but you must separate the numbers by comma.'
},
favoritedFilterCategories: {
emptyInputError: 'Since the favorited gallery filter has been enabled, please enter the favorite ' +
'categories to hide the galleries you have added to these categories.',
invalidInputError: 'Invalid input detected. Please enter the favorite categories in a proper format to ' +
'hide the galleries you have added to these categories. Please note that the names of these categories ' +
'must agree with the actual categories you are using.'
},
titleFilterKeywords: {
emptyInputError: 'Since the gallery title filter has been enabled, please enter the title keywords to ' +
'hide the galleries that have at least one of these keywords in their displayed titles shown in gallery ' +
'lists.',
invalidInputError: 'Since the gallery title filter has been enabled, please enter the regular expression ' +
'to hide the galleries whose title has at least one match with this regular expression.'
}
},
applyTextFilters: {
commentatorFilterUsernames: {
emptyInputError: 'Since the gallery commentator filter has been enabled, please enter the usernames of the ' +
'commentators to hide all comments they made.'
},
commentFilterKeywords: {
emptyInputError: 'Since the gallery comment filter has been enabled, please enter the keywords to hide the ' +
'comments that contain any of these keywords.'
},
posterFilterUsernames: {
emptyInputError: 'Since the forum poster filter has been enabled, please enter the usernames of the ' +
'posters to hide all posts they made.'
},
postFilterKeywords: {
emptyInputError: 'Since the gallery comment filter has been enabled, please enter the keywords to hide the ' +
'posts that contain any of these keywords.'
}
},
useAutomatedDownloads: {
minimumSeedNumber: {
emptyInputError: 'Since torrent download has been enabled, please enter the minimum number of seeds that ' +
'will be required before a torrent can be considered healthy and viable. Entering 0 would remove this ' +
'minimum seed number requirement.',
invalidInputError: 'Invalid input detected. Please note that the setting for the minimum number of seeds ' +
'required only accepts a number between 1 and 9, inclusive.'
},
ignoreRequirementsSize: {
emptyInputError: 'Since torrent download has been enabled, please enter the gallery size above which the ' +
'torrent requirements do not apply. This should be the largest gallery size that you are willing to ' +
'download as an archive when there is also a torrent available as a fallback option.',
invalidInputError: 'Invalid input detected. Please note that the gallery size above which the torrent ' +
'requirements do not apply only accepts a number between 0 and 9999, inclusive. This should be the largest ' +
'gallery size that you are willing to download as an archive when there is also a torrent available as a ' +
'fallback option.'
},
pageDownloadNumber: {
emptyInputError: 'Since the page download button has been enabled, please enter the number of concurrent ' +
'gallery downloads per tab to be allowed in this mode. A high number might cause temporary bans.',
invalidInputError: 'Invalid input detected. Please note that the number of concurrent gallery downloads per ' +
'tab requires a number between 1 and 9, inclusive. A high number might cause temporary bans.'
},
runtime: {
// Unavailable download errors:
networkError: 'A download failed due to a network connection error. Please try again after your network ' +
'recovers',
serviceUnavailableError: 'A download failed, because the server was unavailable and the website failed to ' +
'respond. The repair ponies are on the case, so please wait for a few minutes and try again.',
backendFetchError: 'A download failed, because the server was unavailable and the website failed to ' +
'respond. Please wait for a few hours and try again.',
unavailableArchiverError: 'An archive download failed, because the archiver for this gallery is unavailable ' +
'at the moment. Please wait for a few hours and try again.',
unavailableTorrentError: 'A torrent download failed, because the torrent is not available at the moment. ' +
'Please try again after a few minutes or manually download the personalised torrent instead.',
// Failed download errors:
unavailableGalleryError: 'A download failed, because the gallery is removed or not available.',
downloadedBytesError: 'An archive download failed, because you have clocked too many downloaded bytes on ' +
'this archive link and it is no longer usable. You can wait for it to expire after a few days and then buy ' +
'the archive again, or manually cancel the current link in the archive selection popup and buy the archive ' +
'again immediately.',
expiredSessionError: 'An archive download failed, because you purchased this archive a week ago and the ' +
'expiry of that session stopped the current download. Please try again after one day.',
illegalFilenameError: 'A download failed, because the name of the file being downloaded contains ' +
'one or more illegal characters not accepted by GM.download(). Please manually download this gallery.',
// Temporary ban errors:
heavyLoadError: 'A download is stopped, because you have been warned by the site for loading too many pages ' +
'and/or images too quickly. Please slow down and wait for a while before continuing with the download.',
temporaryBanError: 'A download failed, because you have been temporarily banned from EH for loading too many' +
'pages and/or images too quickly. Please wait until the ban is lifted.',
// Setup errors:
notLoggedInError: 'An archive/H@H download failed, because you are not logged in. Please log in first ' +
'before attempting an automated archive/H@H download.',
autoSelectHathError: 'A H@H download failed, because you have selected to use the H@H downloader, but you ' +
'are using an archiver setting that auto-selects the doggie bag archive to download in your EH gallery ' +
'settings. Please note that you can only use the master script to download via the H@H downloader if your ' +
'archiver settings is on "manual select"',
unqualifiedHathError: 'A H@H download failed, because you have selected to use the H@H downloader, but you ' +
'do not qualify for this downloader. Please note that you will only be entitled to use this downloader if ' +
'you are running a H@H client.',
gmDownloadFileExtensionError: 'An file download failed, because the extension of this file is not in the ' +
'whitelist for GM.download() in Tampermonkey advanced settings. This means you have either not added ' +
'.torrent to this list or removed .zip from it. Please ensure both extensions are whitelisted in the ' +
'"downloads beta" section in Tampermonkey advanced settings.',
gmDownloadNotEnabledError: 'A download attempt failed, because the GM.download() function is not enabled ' +
'or does not have permission. Please check the "downloads beta" section in your Tampermonkey settings.',
gmDownloadNotSupportedError: 'A download attempt failed, because the GM.download() function is not ' +
'supported by your userscript engine or browser. Please note that this download method is only supported ' +
'by Tampermonkey running on certain browsers.',
crossOriginNotAllowedError: 'A download attempt failed, because this script is not allowed to access ' +
'cross-origin archive servers. Archives are served from random cross-origin servers, so this script needs ' +
'to be granted access to all domains at all times in Tampermonkay.',
unknownError: 'The download cannot be initiated for some unknown reason.'
}
}
}
// These are common variables used in feature functions.
const windowUrl = window.location.href
// Most page types can be determined from URL but not all, and the display mode can only be determined from the
// "interactive" ready state onwards in all gallery lists except for gallery toplists, so these variables will not be
// used in functions that run at the "loading" ready state.
let pageType
let displayMode
/**
* Reads settings and values from storage and runs the script.
*/
;(async function () {
/**
* Loads saved data from the userscript storage and decides whether default, saved, or updated data should be used.
*
* @param {string} savedDataName - The name to be used by GM.getValue() to retrive the saved data from storage.
* @param {Object} defaultData - A hard-coded object literal with default values from the start of the script.
* @returns {Object} An object literal that could be the saved data, updated saved data, or default data.
*/
const loadData = async function (savedDataName, defaultData) {
let savedData = await api.getValue(savedDataName)
if (typeof savedData === 'undefined') {
// Use the default data when nothing has been saved.
return defaultData
}
savedData = JSON.parse(savedData)
if (savedData.script.version === defaultData.script.version) {
// Use the saved data directly when the version and hence the script have not changed.
return savedData
} else {
// Update the keys of the saved data after a script update and use the updated data.
const updatedData = updateKeys(renameKeys(savedData, 2), defaultData, 2)
// Update the userscript storage as well so that the data do not need to be updated everytime this script runs.
updatedData.script.version = defaultData.script.version
api.setValue(savedDataName, JSON.stringify(updatedData))
return updatedData
}
}
/**
* Renames keys of an object literal while keeping their values by creating new properties and removing old ones.
*
* It is easier to do this task in a separate function that runs before updateData(). This function always runs in
* loadData() but does nothing when the rename list is empty.
*
* @param {Object} data - An object literal whose keys will be renamed when needed.
* @param {number} levelsToCheck - An integer n, which means the function will check up to keys on the nth level.
* @returns {Object} An object literal whose keys have been renamed where necessary.
*/
const renameKeys = function (data, levelsToCheck) {
// This object should contain "old name": "new name" pairs.
const renames = {
useDownloadShortcuts: 'useAutomatedDownloads'
}
// Make no change and directly return the same object when nothing needs to be renamed.
if (Object.keys(renames).length === 0) {
return data
}
for (const oldName of Object.keys(renames)) {
for (const key of Object.keys(data)) {
// Try to find and rename the target property on one level in one branch, and use recursion where applicable.
// The search is rather thorough because it assumes the same property can exist on multiple levels in multiple
// branches.
if (key === oldName) {
const newName = renames[oldName]
data[newName] = data[oldName]
delete data[oldName]
if (levelsToCheck > 1) {
data[newName] = renameKeys(data[newName], levelsToCheck - 1)
}
// Break the loop since the same key cannot exist twice on one level in one branch.
break
} else if (levelsToCheck > 1) {
data[key] = renameKeys(data[key], levelsToCheck - 1)
}
}
}
return data
}
/**
* Checks a previously saved data object against a default one recursively to update its keys after a script update.
*
* @param {Object} savedData - A previously saved object literal read from the userscript storage.
* @param {Object} defaultData - A hard-coded object literal with default values from the start of the script.
* @param {number} levelsToCheck - An integer n, which means the function will check up to keys on the nth level.
* @returns {Object} An object literal whose keys and values are adjusted to match the defaults where necessary.
*/
const updateKeys = function (savedData, defaultData, levelsToCheck) {
const keyUnion = [...new Set([...Object.keys(savedData), ...Object.keys(defaultData)])]
for (const key of keyUnion) {
if (typeof savedData[key] === 'undefined') {
// Check for newly added keys that only exist in the default data. The default values will be added to the
// saved data.
savedData[key] = defaultData[key]
} else if (typeof defaultData[key] === 'undefined') {
// Check for removed keys that no longer exist in the default data. These keys will be removed from the saved
// data.
delete savedData[key]
} else {
if (levelsToCheck > 1) {
// Check the keys under this key when this key is consistent between the two data objects.
savedData[key] = updateKeys(savedData[key], defaultData[key], levelsToCheck - 1)
}
}
}
return savedData
}
// Load settings and values from storage before running feature functions.
settings = await loadData('settings', settings)
values = await loadData('values', values)
// Run feature functions at two different ready states.
runFeaturesAtLoading()
scheduleForInteractive(runFeaturesAtInteractive)
})()
// Feature functions -------------------------------------------------------------------------------------------------
/**
* Runs feature functions at the "loading" ready state, which belong to feature function group 1.
*/
const runFeaturesAtLoading = function () {
// Function that are supposed to run at this ready state can often fail to run on Firefox. If the Firefox
// compatibility mode is enabled, then they will be loaded at the "interactive" ready state to ensure they will
// always be able to run, at the cost of causing noticeable visual changes when they are loaded.
if (!settings.script.firefoxCompatibilityEnabled) {
// Group 1: functions that can run before DOM elements are loaded.
settings.applyDarkTheme.featureEnabled && applyDarkTheme()
settings.applyLightTheme.featureEnabled && applyLightTheme()
settings.relocateMpvThumbnails.featureEnabled && relocateMpvThumbnails()
settings.hideMpvToolbar.featureEnabled && hideMpvToolbar()
}
}
/**
* Applies a full, scientific dark theme to the entire gallery system on the applicable domain.
*
* This theme is mainly scientifically produced by summarising colour differences between style sheets. Custom styles
* are added to cover unique pages, inline styles and style tags from document.head.
*/
const applyDarkTheme = function () {
// This feature is only applicable to EH, and it covers the entire EH.
if (!windowUrl.includes('e-hentai.org') || windowUrl.includes('forums.e-hentai.org')) {
return
}
// These are the colour differences programmatically extracted from two 0360 style sheets. They do not cover
// everything because there are unique pages, inline styles and head styles.
let scientificDarkStyles = `
body { color: #f1f1f1; background: #34353b }
a { color: #DDDDDD }
a:hover { color: #EEEEEE }
/* input */
input, select, option, optgroup, textarea { color: #f1f1f1; background-color: #34353b }
input[type = "button"], input[type = "submit"] { border: 2px solid #8d8d8d }
select { border: 2px solid #8d8d8d }
input[type = "button"]:enabled:hover, input[type = "submit"]:enabled:hover, select:enabled:hover,
input[type = "button"]:enabled:focus, input[type = "submit"]:enabled:focus, select:enabled:focus
{ background-color: #43464e !important; border-color: #aeaeae !important }
input[type = "button"]:enabled:active, input[type = "submit"]:enabled:active
{ background: radial-gradient(#1a1a1a, #43464e) !important; border-color: #c3c3c3 !important }
input[type = "text"], input[type = "date"], input[type = "password"], textarea { border: 2px solid #8d8d8d }
input:disabled, select:disabled, textarea:disabled { color: #8a8a8a; -webkit-text-fill-color: #8a8a8a }
input::placeholder, textarea::placeholder { color: #8a8a8a; -webkit-text-fill-color: #8a8a8a }
input[type = "text"]:enabled:hover, input[type = "date"]:enabled:hover, input[type = "password"]:enabled:hover,
textarea:enabled:hover, input[type = "text"]:enabled:focus, input[type = "date"]:enabled:focus,
input[type = "password"]:enabled:focus, textarea:enabled:focus { background-color: #43464e }
input[type = "file"] { border: 2px solid #8d8d8d }
.lc:hover input:enabled ~ span, .lr:hover input:enabled ~ span, .lc input:enabled:focus ~ span,
.lr input:enabled:focus ~ span { background-color: #43464e !important; border-color: #aeaeae !important }
.lc input:disabled ~ span, .lr input:disabled ~ span { border-color: #5c5c5c !important }
.lc > span { background-color: #34353b; border: 2px solid #8d8d8d }
.lc > span:after { border: solid #f1f1f1 }
.lr > span { background-color: #34353b; border: 2px solid #8d8d8d }
.lr > span:after { background: #f1f1f1 }
/* misc */
.br { color: #FF3333 }
.stuffbox { background: #4f535b; border: 1px solid #000000 }
/* rating */
img.th { border: 1px solid #000000 }
div.ido { background: #4f535b; border: 1px solid #000000 }
/* index search/navigation */
.searchwarn { color: #FB7878 }
.searchnav div > span { color: #777 }
/* shared table stuff */
div.itg { border-top: 2px ridge #3c3c3c; border-bottom: 2px ridge #3c3c3c }
table.itg { border: 2px ridge #3c3c3c }
table.itg > tbody > tr > th { background: #40454b }
table.itg > tbody > tr:nth-child(2n + 1), table.itg > tbody > tr:nth-child(2n + 1) .glthumb,
table.itg > tbody > tr:nth-child(2n + 1) .glcut { background: #363940 }
table.itg > tbody > tr:nth-child(2n + 2), table.itg > tbody > tr:nth-child(2n + 2) .glthumb,
table.itg > tbody > tr:nth-child(2n + 2) .glcut { background: #3c414b }
table.mt { border: 1px solid #000000; background: #40454b }
table.mt > tbody > tr:nth-child(2n + 1) { background: #363940 }
table.mt > tbody > tr:nth-child(2n + 2) { background: #3c414b }
tr.gtr, table.mt > tbody > tr:first-child { background: #40454b !important }
td.itd { border-right: 1px solid #6f6f6f4d }
/* login boxes */
div.d { border: 1px solid #000000; background: #4f535b }
div.ds { border: 1px solid #000000; background: #4f535b }
/* index */
div.idi { border: 2px ridge #3c3c3c }
/* gallery list */
a:visited .glink, a:active .glink { color: #BBBBBB }
a:hover .glink { color: #EEEEEE }
.glname a :not(.glink), a .glname :not(.glink) { color: #dddddd }
.glcat { border-right: 1px solid #6f6f6f4d }
.glthumb { border: 2px solid #6f6f6f4d }
.glthumb > div:nth-child(1) { border: 1px solid #000000 }
.gltc > tbody > tr > td, .glte > tbody > tr > td { border-right: 1px solid #6f6f6f4d }
.gltm > tbody > tr > td { border-right: 1px solid #6f6f6f4d }
.gl1c, .gl2c, .gl3c, .gl4c, .glfc { border-top: 1px solid #6f6f6f4d; border-bottom: 1px solid #6f6f6f4d }
.gl1e, .gl2e, .glfe { border-top: 1px solid #6f6f6f4d; border-bottom: 1px solid #6f6f6f4d }
.gl1e > div { border: 1px solid #000000 }
.gl4e { border-left: 1px solid #6f6f6f4d }
.gld { border-left: 1px solid #6f6f6f4d }
.gl1t { border-right: 1px solid #6f6f6f4d; border-bottom: 1px solid #6f6f6f4d }
.gl3t { border: 1px solid #000000 }
.gl1t:nth-child(2n + 1) { background: #363940 }
.gl1t:nth-child(2n + 2) { background: #3c414b }
/* category buttons */
.ct1 { background: #777777; border-color: #777777 } /* misc */
.ct2 { background: #9E2720; border-color: #9E2720 } /* doujinshi */
.ct3 { background: #DB6C24; border-color: #DB6C24 } /* manga */
.ct4 { background: #D38F1D; border-color: #D38F1D } /* artistcg */
.ct5 { background: #6A936D; border-color: #617C63 } /* gamecg */
.ct6 { background: #325CA2; border-color: #325CA2 } /* imageset*/
.ct7 { background: #6A32A2; border-color: #6A32A2 } /* cosplay */
.ct8 { background: #A23282; border-color: #A23282 } /* asianporn */
.ct9 { background: #5FA9CF; border-color: #5FA9CF } /* nonh */
.cta { background: #AB9F60; border-color: #AB9F60 } /* western */
/* page selector */
table.ptt { color: #f1f1f1 }
table.ptt td { background: #34353b; border: 1px solid #000000 }
table.ptt td:hover { color: #000000; background: #43464e }
table.ptb { color: #f1f1f1 }
table.ptb td { background: #34353b; border: 1px solid #000000 }
table.ptb td:hover { color: #000000; background: #43464e }
td.ptds { color: #000000 !important; background: #43464e !important }
td.ptdd:hover { color: #C2A8A4 !important; background: #34353b !important }
/* gallery */
a.tup { color: #00E639 }
a.tdn { color: #FF3333 }
span.tup { color: #00E639 }
span.tdn { color: #FF3333 }
div.gm { background: #4f535b; border: 1px solid #000000 }
div#gmid { background: #4f535b }
div#gd1 div { border: 1px solid #000000 }
div#gd2 { background: #4f535b }
h1#gj { color: #b8b8b8; border-bottom: 1px solid #000000 }
div#gd4 { border-left: 1px solid #000000; border-right: 1px solid #000000 }
div#gdt { background: #4f535b; border: 1px solid #000000 }
div#gdt img { border: 1px solid #000000 }
.g3 a { color: #FF4A4A }
div.gt { border: 1px solid #989898; background: #4f535b }
div.gtl { border: 1px dashed #8c8c8c; background: #4f535b }
div.gtw { border: 1px dotted #8c8c8c; background: #4f535b }
#gds { background: #4f535b }
#grl { color: #FF3333 }
div.c2 { background: #34353b; border: 1px solid #4f535b }
div.ths { border: 1px solid #989898; background: #4f535b }
div.tha { border: 1px solid #706563 }
div.tha:hover { background: #4f535b; color: #000000 }
div.thd { border: 1px solid #706563; color: #706563 }
/* image pages */
div.sni { background: #4f535b; border: 1px solid #000000 }`
// These are extracted from the style tags in document.head, including the first checkbox fix.
scientificDarkStyles += `
/* keep the ticks in checkboxes */
.lc > span:after { border-width: 0 3px 3px 0 !important; }
/* page-specific */`
if (/e-hentai\.org\/g\/\d+\/[0-9a-z]+\/\?act=expunge/.test(windowUrl)) {
scientificDarkStyles += `
#gdt.exp_outer { border-color: #000000; }
.exp_entry { border-color: #8d8d8d; }
.exp_table { border-color: #34353b; }`
} else if (/e-hentai\.org\/mpv\//.test(windowUrl)) {
scientificDarkStyles += `
div.mi0 { background: #43464e; border: 1px solid #34353b; }`
} else if (windowUrl.includes('favorites.php')) {
scientificDarkStyles += `
div.fp:hover { background:#43464e; }
div.fps { background:#43464e; }
@supports (display:grid) {
@media screen and (max-width:1080px) {
.gl1t:nth-child(8n + 1), .gl1t:nth-child(8n + 3), .gl1t:nth-child(8n + 6), .gl1t:nth-child(8n + 8)
{ background: #363940; }
.gl1t:nth-child(8n + 2), .gl1t:nth-child(8n + 4), .gl1t:nth-child(8n + 5), .gl1t:nth-child(8n + 7)
{ background: #3c414b; }
}
}`
} else if (windowUrl.includes('mytags')) {
scientificDarkStyles += `
#usertags_mass > div { border-top: 1px solid #34353b; }
.jscolor { border: 1px solid #8d8d8d; }
.tagcomplete-items { border: 1px solid #8d8d8d; }
.tagcomplete-items div { background-color: #4f535b; }
.tagcomplete-items div:not(:last-child) { border-bottom: 1px solid #5e5e5e; }
.tagcomplete-items div:last-child { border-bottom: 1px solid #8d8d8d; }
.tagcomplete-items div:hover { background-color: #43464e; }
.tagcomplete-active { background-color: #f1f1f1 !important; color: #4f535b }`
} else if (windowUrl.includes('managegallery')) {
scientificDarkStyles += `
td.l { border-bottom: 1px solid #f1f1f1; border-right: 1px dashed #f1f1f1; }
td.r { border-bottom: 1px solid #f1f1f1; }
td#d { border-right: 1px dashed #f1f1f1; }
div[id ^= "cell_"] { background: #5f636b; border: 1px solid #34353b; }`
// The upload list also has styles in document.head, but they are the same on both sides. There are only two
// effective colour properties, but they only fit the light theme, so a fix is added to the design fixes feature
// for the dark theme.
} else if (windowUrl.includes('bounty.php?bid=')) {
scientificDarkStyles += `
span.scr { color: red; }
span.scb { color: blue; }
span.scg { color: green; }
span.sco { color: #FF8C00; }
div#x { border-color: #34353b; background: #43464e; }
div#g th { border-bottom-color: #000000; }
div#h th { border-bottom-color: #000000; }`
} else if (windowUrl.includes('bounty.php?act=top')) {
scientificDarkStyles += `
span.scr { color: red; }
span.scb { color: blue; }
span.scg { color: green; }
span.sco { color: #FF8C00; }
div#t img { border-color: black; }
div#f span { color: #f1f1f1; }
div.d4 { border-color: #000000; }
div.d5 { border-color: #000000; }`
} else if (windowUrl.includes('gallerytorrents.php')) {
scientificDarkStyles += `
table#ett { background: #43464e; border: 1px solid #34353b; }
div#etd { background: #43464e; border: 1px solid #34353b; }`
} else if (windowUrl.includes('archiver.php')) {
scientificDarkStyles += `
div#db { border: 1px solid #000000; background: #4f535b; }`
}
// These styles cover the styles not included in the default dark styles in style sheet and style tags, so they
// cannot be scientifically produced. Some of them also override the scientific styles.
let customDarkStyles = `
/* cover event pane */
#eventpane { background: #4f535b !important; border-color: #000000 !important; }
/* use consistent round cornors */
div.ido, .stuffbox { border-radius: 9px; }`
if (/e-hentai\.org\/g\/\d+\/[0-9a-z]+/.test(windowUrl)) {
// The first two rules replicate the default dark style. The last rule below targets the content warning div when
// it is there; otherwise it targets the eventpane or .gm, but it will not have an effect beacuse these elements
// already use this background colour.
customDarkStyles += `
div#tagpopup { background: #4f535b; border: 1px solid #000000 }
div#tagpopup h2:hover { color: #ffffff }
img.ygm { filter: brightness(100); }
#nb + div { background: #4f535b !important }`
} else if (/e-hentai\.org\/mpv\//.test(windowUrl)) {
customDarkStyles += `
div.mi2, div.mi3, div#bar3 img { filter: invert(0.8); }`
} else if (windowUrl.includes('gallerytorrents.php')) {
customDarkStyles += `
#torrentinfo > div + div { border-top-color: #000000 !important; }`
} else if (windowUrl.includes('archiver.php')) {
scientificDarkStyles += `
#hathdl_form + table td { border-color: #f1f1f1 !important; }`
} else if (windowUrl.includes('home.php')) {
customDarkStyles += `
div.homebox { border-color: #000000; }
div.homebox td { border-right-color: #000000 !important; }`
} else if (windowUrl.includes('stats.php')) {
customDarkStyles += `
.stuffbox table { background: #4f535b !important; border-color: #000000 !important; }
tr > td.stdk, tr > td.stdv { border-color: #000000; }`
if (windowUrl.includes('gid')) {
// For the gallery ranking table on the EH-only public gallery statistics page:
customDarkStyles += `
table th { border-bottom-color: #000000 !important; }`
}
} else if (windowUrl.includes('bitcoin.php')) {
customDarkStyles += `
#coinselector > div[onclick] { background-color: #4f535b; }
#coinselector > div[onclick]:hover { background-color: #43464e; }
#coinselector > div[onclick]:hover > a { color: #ffffff; }
#douter > #coinselector > div { border-color: #000000; }
#adon { border-top-color: #000000; }
#adon > div:nth-child(3) { border-left-color: #000000; }
#tdon th { border-bottom-color: #000000; }
#dlvl { background-color: #34353b; }
#houter { border-top-color: #000000; }
#houter > div:nth-child(2) { border-left-color: #000000; }`
} else if (windowUrl.includes('exchange.php')) {
customDarkStyles += `
.stuffbox h2 { border-bottom-color: #000000; }`
} else if (windowUrl.includes('logs.php?t=credits')) {
customDarkStyles += `
#lb + div { border-radius: 9px; background: #4f535b !important; border-color: #000000 !important; }
#lb + div th { border-bottom-color: #000000 !important; };`
} else if (windowUrl.includes('logs.php?t=karma')) {
customDarkStyles += `
#lb + div + div { border-radius: 9px; background: #4f535b !important; border-color: #000000 !important; }
#lb + div + div th { border-bottom-color: #000000 !important; };`
} else if (windowUrl === 'https://e-hentai.org/bounty.php') {
// Colour the page number arrow when it is not clickable.
customDarkStyles += `
td.ptdd, td.ptdd:hover { color: #73767c !important; }`
} else if (windowUrl.includes('bounty.php?act=top')) {
// Colour the arrow for the previous page when it is not clickable on the three bounty toplists. The page number
// has no limit so only one arrow needs a fix.
customDarkStyles += `
div#p > span { color: #73767c; }`
} else if (windowUrl.includes('bounty.php?bid=')) {
// Fix the colour of the PM icon.
customDarkStyles += `
img.ygm { filter: brightness(100); }`
} else if (windowUrl.includes('bounty_post.php')) {
customDarkStyles += `
div.d4, div.d5 { border-color: #000000; }
#b.stuffbox td.l, #b.stuffbox td.r { border-bottom-color: #000000; }`
} else if (windowUrl.includes('news.php')) {
customDarkStyles += `
.nwo h2, .nwo .newstitle { border-bottom-color: #000000; }`
} else if (windowUrl.includes('karma.php')) {
customDarkStyles += `
body > div:first-child { border-radius: 9px; background: #4f535b !important; border-color: #000000 !important; }
#as { padding-bottom: 0 !important; background: #4f535b !important; border-color: #aeaeae !important; }`
} else if (windowUrl.includes('tools/track_expunge')) {
// Using the brightness filter seems to disfigure the text in anchor elements on Firefox, so a more hardcoded
// approach is used below. It is likely caused by bitmap conversion of ClearType text. Revoked expunge petitions
// will still appear disfigured because they cannot be identified via CSS. If Firefox fixes this problem with
// ClearType, then a simple filter will be enough.
customDarkStyles += `
/* cover everything but avoid application to usernames */
td:not(:nth-child(3)) { filter: brightness(2); }
/* avoid application to conflict gallery */
body > div > div > table > tbody > tr:nth-child(4) > td:nth-child(2),
/* avoid application to entire tables */
body > div > div > table > tbody > tr:nth-child(5) > td:nth-child(2),
body > div > div > table > tbody > tr:nth-child(8) > td:nth-child(2) { filter: none; }`
} else if (windowUrl.includes('tools/track_rename')) {
customDarkStyles += `
/* cover submitted rename titles */
body > div > div > div > div:nth-child(1),
/* cover the vote details but avoid application to current and original titles and usernames */
body > div > div:nth-child(3) td:not(:nth-child(3)),
body > div > div:nth-child(5) td:not(:nth-child(3)) { filter: brightness(2); }`
} else if (windowUrl.includes('tools/tagapprove')) {
customDarkStyles += `
.sources { border: 1px solid #000000; background: #4f535b; }`
}
const scientificDarkStylesElement = appendStyleText(document.documentElement, 'scientificDarkStyles',
scientificDarkStyles)
appendStyleText(document.documentElement, 'customDarkStyles', customDarkStyles)
/**
* Appends the styles whose applicability can only be determined at the "interactive" ready state.
*/
const addStylesAtInteractive = function () {
// The existing "displayMode" variable is not used due to its asynchronous assignment.
const displayMode = document.querySelector('.searchnav option[selected = "selected"]')
if (displayMode !== null && displayMode.textContent.toLowerCase() === 'thumbnail') {
// These are extracted from the style tag in document.head of the search index in the thumbnail display mode.
scientificDarkStylesElement.textContent += `
@supports(display:grid) {
@media screen and (max-width:1080px) {
.gl1t:nth-child(8n + 1), .gl1t:nth-child(8n + 3), .gl1t:nth-child(8n + 6), .gl1t:nth-child(8n + 8)
{ background: #363940; }
.gl1t:nth-child(8n + 2), .gl1t:nth-child(8n + 4), .gl1t:nth-child(8n + 5), .gl1t:nth-child(8n + 7)
{ background: #3c414b; }
}
@media screen and (max-width:860px) {
.gl1t:nth-child(2n + 1) { background: #363940; }
.gl1t:nth-child(2n + 2) { background: #3c414b; }
}
}`
}
}
scheduleForInteractive(addStylesAtInteractive)
}
/**
* Applies a full, scientific light theme to the entire gallery system on the applicable domain.
*
* This theme is mainly scientifically produced by summarising colour differences between style sheets. Custom styles
* are added to cover inline styles and style tags from document.head.
*/
const applyLightTheme = function () {
// This feature is only applicable to EX, and it covers the entire EX.
if (!windowUrl.includes('exhentai.org')) {
return
}
// These are the colour differences programmatically extracted from two 0360 style sheets. They do not cover
// everything because there are inline styles and head styles.
let scientificLightStyles = `
body { color: #5C0D11; background: #E3E0D1 }
a { color: #5C0D11 }
a:hover { color: #8F4701 }
/* input */
input, select, option, optgroup, textarea { color: #5C0D12; background-color: #EDEADA }
input[type = "button"], input[type = "submit"] { border: 2px solid #B5A4A4 }
select { border: 2px solid #B5A4A4 }
input[type = "button"]:enabled:hover, input[type = "submit"]:enabled:hover, select:enabled:hover,
input[type = "button"]:enabled:focus, input[type = "submit"]:enabled:focus, select:enabled:focus
{ background-color: #F3F0E0 !important; border-color: #977273 !important }
input[type = "button"]:enabled:active, input[type = "submit"]:enabled:active
{ background: radial-gradient(#D7D3C2, #F3F0E0) !important; border-color: #5C0D12 !important }
input[type = "text"], input[type = "date"], input[type = "password"], textarea { border: 2px solid #B5A4A4 }
input:disabled, select:disabled, textarea:disabled { color: #C2A8A4; -webkit-text-fill-color: #C2A8A4 }
input::placeholder, textarea::placeholder { color: #9F746F; -webkit-text-fill-color: #9F746F }
input[type = "text"]:enabled:hover, input[type = "date"]:enabled:hover, input[type = "password"]:enabled:hover,
textarea:enabled:hover, input[type = "text"]:enabled:focus, input[type = "date"]:enabled:focus,
input[type = "password"]:enabled:focus, textarea:enabled:focus { background-color: #F3F0E0 }
input[type = "file"] { border: 2px solid #B5A4A4 }
.lc:hover input:enabled ~ span, .lr:hover input:enabled ~ span, .lc input:enabled:focus ~ span,
.lr input:enabled:focus ~ span { background-color: #F3F0E0 !important; border-color: #977273 !important }
.lc input:disabled ~ span, .lr input:disabled ~ span { border-color: #DBD4D3 !important }
.lc > span { background-color: #EDEADA; border: 2px solid #B5A4A4 }
.lc > span:after { border: solid #5C0D12 }
.lr > span { background-color: #EDEADA; border: 2px solid #B5A4A4 }
.lr > span:after { background: #5C0D12 }
/* misc */
.br { color: #FF0000 }
.stuffbox { background: #EDEBDF; border: 1px solid #5C0D12 }
/* rating */
img.th { border: 1px solid #5C0D12 }
div.ido { background: #EDEBDF; border: 1px solid #5C0D12 }
/* index search/navigation */
.searchwarn { color: #D71F1F }
.searchnav div > span { color: #CCCCCC }
/* shared table stuff */
div.itg { border-top: 2px ridge #5C0D12; border-bottom: 2px ridge #5C0D12 }
table.itg { border: 2px ridge #5C0D12 }
table.itg > tbody > tr > th { background: #E0DED3 }
table.itg > tbody > tr:nth-child(2n + 1), table.itg > tbody > tr:nth-child(2n + 1) .glthumb,
table.itg > tbody > tr:nth-child(2n + 1) .glcut { background: #F2F0E4 }
table.itg > tbody > tr:nth-child(2n + 2), table.itg > tbody > tr:nth-child(2n + 2) .glthumb,
table.itg > tbody > tr:nth-child(2n + 2) .glcut { background: #EDEBDF }
table.mt { border: 1px solid #5C0D12; background: #E0DED3 }
table.mt > tbody > tr:nth-child(2n + 1) { background: #F2F0E4 }
table.mt > tbody > tr:nth-child(2n + 2) { background: #EDEBDF }
tr.gtr, table.mt > tbody > tr:first-child { background: #EBE8DD !important }
td.itd { border-right: 1px solid #D9D7CC }
/* login boxes */
div.d { border: 1px solid #5C0D12; background: #EDEBDF }
div.ds { border: 1px solid #5C0D12; background: #EDEBDF }
/* index */
div.idi { border: 2px ridge #5C0D12 }
/* gallery list */
a:visited .glink, a:active .glink { color: #8F6063 }
a:hover .glink { color: #8F4701 }
.glname a :not(.glink), a .glname :not(.glink) { color: #5C0D11 }
.glcat { border-right: 1px solid #D9D7CC }
.glthumb { border: 2px solid #D9D7CC }
.glthumb > div:nth-child(1) { border: 1px solid #5C0D12 }
.gltc > tbody > tr > td, .glte > tbody > tr > td { border-right: 1px solid #D9D7CC }
.gltm > tbody > tr > td { border-right: 1px solid #D9D7CC }
.gl1c, .gl2c, .gl3c, .gl4c, .glfc { border-top: 1px solid #D9D7CC; border-bottom: 1px solid #D9D7CC }
.gl1e, .gl2e, .glfe { border-top: 1px solid #D9D7CC; border-bottom: 1px solid #D9D7CC }
.gl1e > div { border: 1px solid #5C0D12 }
.gl4e { border-left: 1px solid #D9D7CC }
.gld { border-left: 1px solid #D9D7CC }
.gl1t { border-right: 1px solid #D9D7CC; border-bottom: 1px solid #D9D7CC }
.gl3t { border: 1px solid #5C0D12 }
.gl1t:nth-child(2n + 1) { background: #F2F0E4 }
.gl1t:nth-child(2n + 2) { background: #EDEBDF }
/* category buttons */
.ct1 { background: radial-gradient(#707070, #9e9e9e); border: 1px solid #707070 } /* misc */
.ct2 { background: radial-gradient(#fc4e4e, #f26f5f); border: 1px solid #fc4e4e } /* doujinshi */
.ct3 { background: radial-gradient(#e78c1a, #fcb417); border: 1px solid #e78c1a } /* manga */
.ct4 { background: radial-gradient(#c7bf07, #dde500); border: 1px solid #c7bf07 } /* artistcg */
.ct5 { background: radial-gradient(#1a9317, #05bf0b); border: 1px solid #1a9317 } /* gamecg */
.ct6 { background: radial-gradient(#2756aa, #5f5fff); border: 1px solid #2756aa } /* imageset*/
.ct7 { background: radial-gradient(#8800c3, #9755f5); border: 1px solid #8800c3 } /* cosplay */
.ct8 { background: radial-gradient(#b452a5, #fe93ff); border: 1px solid #b452a5 } /* asianporn */
.ct9 { background: radial-gradient(#0f9ebd, #08d7e2); border: 1px solid #0f9ebd } /* nonh */
.cta { background: radial-gradient(#5dc13b, #14e723); border: 1px solid #5dc13b } /* western */
/* page selector */
table.ptt { color: #5C0D12 }
table.ptt td { background: #E3E0D1; border: 1px solid #5C0D12 }
table.ptt td:hover { color: #9B4E03; background: #F2EFDF }
table.ptb { color: #5C0D12 }
table.ptb td { background: #E3E0D1; border: 1px solid #5C0D12 }
table.ptb td:hover { color: #9B4E03; background: #F2EFDF }
td.ptds { color: #9B4E03 !important; background: #F2EFDF !important }
td.ptdd:hover { color: #C2A8A4 !important; background: #E3E0D1 !important }
/* gallery */
a.tup { color: green }
a.tdn { color: red }
span.tup { color: green }
span.tdn { color: red }
div.gm { background: #EDEBDF; border: 1px solid #5C0D12 }
div#gmid { background: #EDEBDF }
div#gd1 div { border: 1px solid #5C0D12 }
div#gd2 { background: #EDEBDF }
h1#gj { color: #9F8687; border-bottom: 1px solid #5C0D12 }
div#gd4 { border-left: 1px solid #5C0D12; border-right: 1px solid #5C0D12 }
div#gdt { background: #EDEBDF; border: 1px solid #5C0D12 }
div#gdt img { border: 1px solid #5C0D12 }
.g3 a { color: #FF0000 }
div.gt { border: 1px solid #806769; background: #F2EFDF }
div.gtl { border: 1px dashed #9a7c7e; background: #F2EFDF }
div.gtw { border: 1px dotted #9a7c7e; background: #F2EFDF }
#gds { background: #F2EFDF }
#grl { color: #FF0000 }
div.c2 { background: #E3E0D1; border: 1px solid #F2EFDF }
div.ths { border: 1px solid #806769; background: #F2EFDF }
div.tha { border: 1px solid #C2A8A4 }
div.tha:hover { background: #F2EFDF; color: #9B4E03 }
div.thd { border: 1px solid #C2A8A4; color: #C2A8A4 }
/* image pages */
div.sni { background: #EDEBDF; border: 1px solid #5C0D12 }`
// These are extracted from the style tags in document.head, including the first checkbox fix.
scientificLightStyles += `
/* keep the ticks in checkboxes */
.lc > span:after { border-width: 0 3px 3px 0 !important; }
/* page-specific */`
if (/exhentai\.org\/g\/\d+\/[0-9a-z]+\/\?act=expunge/.test(windowUrl)) {
scientificLightStyles += `
#gdt.exp_outer { border-color: #5C0D12; }
.exp_entry { border-color: #B5A4A4; }
.exp_table { border-color: #5C0D12; }`
} else if (/exhentai\.org\/mpv\//.test(windowUrl)) {
scientificLightStyles += `
div.mi0 { background: #F2EFDF; border: 1px solid #E3E0D1; }`
} else if (windowUrl.includes('favorites.php')) {