Skip to content

Commit 217dc48

Browse files
authored
Merge pull request #179 from Oxy949/feature/hide-custom-css
Hide By CSS Selectors
2 parents 86b2231 + b29fd1f commit 217dc48

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

src/module.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,22 @@ Hooks.on("theatreDockActive", (insertCount) => {
514514
// The "MyTab" module inserts another element with id "pause". Use querySelectorAll to make sure we catch both
515515
document.querySelectorAll("#pause").forEach((ele) => KHelpers.addClass(ele, "theatre-centered"));
516516

517+
518+
517519
if (!game.settings.get(CONSTANTS.MODULE_ID, "autoHideBottom")) {
518520
return;
519521
}
520522
if (!theatre.isSuppressed) {
521523
$("#players").addClass("theatre-invisible");
522524
$("#hotbar").addClass("theatre-invisible");
525+
526+
const customSelectors = game.settings.get(CONSTANTS.MODULE_ID, "suppressCustomCss");
527+
if (customSelectors) {
528+
const selectors = customSelectors.split(";").map(selector => selector.trim());
529+
selectors.forEach(selector => {
530+
$(selector).addClass("theatre-invisible");
531+
});
532+
}
523533
}
524534
});
525535

@@ -577,9 +587,25 @@ Hooks.on("theatreSuppression", (suppressed) => {
577587
if (suppressed) {
578588
$("#players").removeClass("theatre-invisible");
579589
$("#hotbar").removeClass("theatre-invisible");
590+
591+
const customSelectors = game.settings.get(CONSTANTS.MODULE_ID, "suppressCustomCss");
592+
if (customSelectors) {
593+
const selectors = customSelectors.split(";").map(selector => selector.trim());
594+
selectors.forEach(selector => {
595+
$(selector).removeClass("theatre-invisible");
596+
});
597+
}
580598
} else {
581599
$("#players").addClass("theatre-invisible");
582600
$("#hotbar").addClass("theatre-invisible");
601+
602+
const customSelectors = game.settings.get(CONSTANTS.MODULE_ID, "suppressCustomCss");
603+
if (customSelectors) {
604+
const selectors = customSelectors.split(";").map(selector => selector.trim());
605+
selectors.forEach(selector => {
606+
$(selector).addClass("theatre-invisible");
607+
});
608+
}
583609
}
584610
});
585611

src/scripts/Theatre.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,6 +2121,13 @@ export class Theatre {
21212121
document.querySelectorAll("#pause").forEach((ele) => KHelpers.removeClass(ele, "theatre-centered"));
21222122
$("#players").removeClass("theatre-invisible");
21232123
$("#hotbar").removeClass("theatre-invisible");
2124+
const customSelectors = game.settings.get(CONSTANTS.MODULE_ID, "suppressCustomCss");
2125+
if (customSelectors) {
2126+
const selectors = customSelectors.split(";").map(selector => selector.trim());
2127+
selectors.forEach(selector => {
2128+
$(selector).removeClass("theatre-invisible");
2129+
});
2130+
}
21242131
}
21252132
// force a render update
21262133
//app.render();

src/scripts/settings.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,15 @@ export const registerSettings = function () {
204204
default: true,
205205
});
206206

207+
game.settings.register(CONSTANTS.MODULE_ID, "suppressCustomCss", {
208+
name: "Hide By CSS Selectors",
209+
hint: "Hides elements specified by CSS selectors. Multiple selectors should be delimited by a semi-colon (;)",
210+
scope: "world",
211+
config: true,
212+
default: "",
213+
type: String
214+
});
215+
207216
game.settings.register(CONSTANTS.MODULE_ID, "showUIAboveStage", {
208217
name: "Theatre.UI.Settings.showUIAboveStage",
209218
hint: "Theatre.UI.Settings.showUIAboveStageHint",

src/styles/theatre.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,12 @@
16851685
transition: opacity 500ms ease 0ms;
16861686
}
16871687

1688+
/* id.class is utilized to gain priority over styling rules of the "Minimal UI" module */
1689+
.theatre-invisible {
1690+
opacity: 0 !important;
1691+
pointer-events: none !important;
1692+
}
1693+
16881694
/* id.class is utilized to gain priority over styling rules of the "Minimal UI" module */
16891695
#players.theatre-invisible,
16901696
#hotbar.theatre-invisible {

0 commit comments

Comments
 (0)