-
Notifications
You must be signed in to change notification settings - Fork 2
/
gelbooru-overhaul.user.js
120 lines (100 loc) · 6.66 KB
/
gelbooru-overhaul.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
// ==UserScript==
// @name Gelbooru Overhaul
// @namespace https://github.com/Enchoseon/gelbooru-overhaul-userscript/raw/main/gelbooru-overhaul.user.js
// @version 1.1.1
// @description Various toggleable changes to Gelbooru such as enlarging the gallery, removing the sidebar, and more.
// @author Enchoseon
// @match https://*.gelbooru.com/*
// @run-at document-start
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_download
// @grant GM_addStyle
// @grant GM_addElement
// @grant GM_getResourceText
// @resource css https://github.com/Enchoseon/gelbooru-overhaul-userscript/raw/main/resources/gelbooru-overhaul.css
// @resource css-common https://github.com/Enchoseon/gelbooru-overhaul-userscript/raw/main/resources/gelbooru-overhaul-common.css
// @require https://github.com/Enchoseon/gelbooru-overhaul-userscript/raw/main/resources/gelbooru-overhaul.utils.js
// @require https://github.com/Enchoseon/gelbooru-overhaul-userscript/raw/main/resources/gelbooru-overhaul.configManager.js
// @require https://github.com/Enchoseon/gelbooru-overhaul-userscript/raw/main/resources/gelbooru-overhaul.tweaks.js
// @require https://github.com/Enchoseon/gelbooru-overhaul-userscript/raw/main/resources/gelbooru-overhaul.themeManager.js
// @require https://github.com/Enchoseon/gelbooru-overhaul-userscript/raw/main/resources/gelbooru-overhaul.blacklistManager.js
// @require https://github.com/Enchoseon/gelbooru-overhaul-userscript/raw/main/resources/gelbooru-overhaul.infiniteScrolling.js
// ==/UserScript==
(function () {
"use strict";
try {
utils.onDOMReady(main);
} catch (error) {
alert(error);
}
function main() {
context.pageType = utils.getPageType();;
utils.debugLog("Current page type is " + context.pageType, null, true);
let configManager = new ConfigManager();
context.configManager = configManager;
let themeManager = new ThemeManager();
context.themeManager = themeManager;
let blacklistManager = new BlacklistManager();
context.blacklistManager = blacklistManager;
let infiniteScrolling = new InfiniteScrolling();
context.infiniteScrolling = infiniteScrolling;
configManager.addUpdateListener("advancedBlacklist.enable", applyTweakAdvancedBlacklist);
configManager.addUpdateListener("advancedBlacklist.hideMode", applyCssVariableBlacklist);
configManager.addUpdateListener("advancedBlacklist.hideFilter", applyCssVariableBlacklist);
configManager.addUpdateListener("advancedBlacklist.showOnHover", applyCssVariableBlacklist);
configManager.addUpdateListener("advancedBlacklist.enlargeOnHover", applyCssVariableBlacklist);
configManager.addUpdateListener("advancedBlacklist.entriesOrder", applyVariableBlacklist);
configManager.addUpdateListener("collapsibleSidebar.enable", applyTweakCollapseSidebar);
configManager.addUpdateListener("collapsibleSidebar.width", applyCssVariableGoCollapseSidebar);
configManager.addUpdateListener("collapsibleSidebar.color", applyCssVariableGoCollapseSidebar);
configManager.addUpdateListener("collapsibleSidebar.opacity", applyCssVariableGoCollapseSidebar);
configManager.addUpdateListener("post.center", applyTweakPostCenter);
configManager.addUpdateListener("post.fitTweaks", applyTweakPostFit);
configManager.addUpdateListener("post.fitHorizontallyOnNarrow", applyTweakPostOnNarrow);
configManager.addUpdateListener("post.switchFitOnClick", applyTweakPostClickSwitchFit);
configManager.addUpdateListener("post.autoScroll", applyTweakPostAutoScroll);
configManager.addUpdateListener("thumbs.resizeGallery", applyTweakResizeThumbsGallery);
configManager.addUpdateListener("thumbs.resizeGallerySize", applyCssVariableGoThumbnailResize);
configManager.addUpdateListener("thumbs.resizeMoreLikeThis", applyTweakResizeThumbsMoreLikeThis);
configManager.addUpdateListener("thumbs.resizeMoreLikeThisSize", applyCssVariableGoThumbnailResize);
configManager.addUpdateListener("thumbs.enlargeOnHover", applyTweakEnlargeOnHover);
configManager.addUpdateListener("thumbs.scale", applyCssVariableGoThumbnailEnlarge);
configManager.addUpdateListener("thumbs.highRes", applyTweakLoadHighRes);
configManager.addUpdateListener("thumbs.loader", applyTweakLoadingIndicator);
configManager.addUpdateListener("thumbs.removeTitle", applyTweakRemoveTitle);
configManager.addUpdateListener("thumbs.preventOffScreen", applyTweakPreventOffScreen);
configManager.addUpdateListener("thumbs.roundCorners", applyTweakRoundCorners);
configManager.addUpdateListener("fastDL.thumbs", applyTweakFastDL);
configManager.addUpdateListener("fastDL.post", applyTweakFastDLPost);
configManager.addUpdateListener("infiniteScroll.enable", applyTweakInfiniteScroll);
configManager.addUpdateListener("infiniteScroll.paginatorOnTop", applyTweakPaginatorOnTop);
configManager.addUpdateListener("infiniteScroll.goToTop", applyTweakGoToTop);
configManager.addUpdateListener("darkMode.amoled", (v) => {themeManager.checkForThemeSwitch(v);});
infiniteScrolling.addUpdateListener(e => {
applyTweakEnlargeOnHover(Boolean(configManager.findValueByKey("thumbs.enlargeOnHover")), e);
applyTweakLoadingIndicator(Boolean(configManager.findValueByKey("thumbs.loader")), e);
applyTweakRoundCorners(Boolean(configManager.findValueByKey("thumbs.roundCorners")), e);
applyTweakRemoveTitle(Boolean(configManager.findValueByKey("thumbs.removeTitle")), e);
applyTweakFastDL(Boolean(configManager.findValueByKey("fastDL.thumbs")), e);
applyTweakResizeThumbsGallery(Boolean(configManager.findValueByKey("thumbs.resizeGallery")), e);
if (configManager.findValueByKey("advancedBlacklist.enable")) {
e.forEach(e => e.parentElement.classList.add("go-blacklisted-pending"))
blacklistManager.applyBlacklist(e);
}
});
if (configManager.findValueByKey("advancedBlacklist.enable")) {
let thumbs = utils.getThumbnails();
if (thumbs != undefined) thumbs.forEach(e => e.parentElement.classList.add("go-blacklisted-pending"))
}
configManager.applyConfig();
utils.debugLog("Registering styles");
GM_addStyle(GM_getResourceText("css"));
}
// lazy fix for the back button, don't want to deal with HTML5 stuff
window.onpopstate = function (event) {
if (event && event.state) {
location.reload();
}
};
})();