Add support for custom background colors

This commit is contained in:
nuttylmao
2025-03-27 04:27:47 +11:00
parent 8774d44397
commit 93caa5b36d
4 changed files with 44 additions and 3 deletions
+1
View File
@@ -13,6 +13,7 @@
<ul id="messageList"> <ul id="messageList">
</ul> </ul>
<div id="alertBox"></div> <div id="alertBox"></div>
<div id="background"></div>
<div id="IPutThisHereSoICanCalculateHowBigEachMessageIsSupposedToBeBeforeIAddItToTheMessageList"> <div id="IPutThisHereSoICanCalculateHowBigEachMessageIsSupposedToBeBeforeIAddItToTheMessageList">
</div> </div>
</div> </div>
+10
View File
@@ -26,6 +26,8 @@ const showUsername = GetBooleanParam("showUsername", true);
const showMessage = GetBooleanParam("showMessage", true); const showMessage = GetBooleanParam("showMessage", true);
const font = urlParams.get("font") || ""; const font = urlParams.get("font") || "";
const fontSize = urlParams.get("fontSize") || "18"; const fontSize = urlParams.get("fontSize") || "18";
const background = urlParams.get("background") || "#000000";
const opacity = urlParams.get("opacity") || "0.5";
const hideAfter = GetIntParam("hideAfter") || 0; const hideAfter = GetIntParam("hideAfter") || 0;
const excludeCommands = GetBooleanParam("excludeCommands", true); const excludeCommands = GetBooleanParam("excludeCommands", true);
@@ -49,6 +51,14 @@ const showStreamElementsTips = GetBooleanParam("showStreamElementsTips", true);
document.body.style.fontFamily = font; document.body.style.fontFamily = font;
document.body.style.fontSize = `${fontSize}px`; document.body.style.fontSize = `${fontSize}px`;
// Set the background color
const opacity255 = Math.round(parseFloat(opacity) * 255);
let hexOpacity = opacity255.toString(16);
if (hexOpacity.length < 2) {
hexOpacity = "0" + hexOpacity;
}
document.documentElement.style.setProperty('--background', `${background}${hexOpacity}`);
// Get a list of chatters to ignore // Get a list of chatters to ignore
const ignoreUserList = ignoreChatters.split(',').map(item => item.trim().toLowerCase()) || []; const ignoreUserList = ignoreChatters.split(',').map(item => item.trim().toLowerCase()) || [];
+19
View File
@@ -74,6 +74,25 @@
"defaultValue": 18, "defaultValue": 18,
"group": "Appearance" "group": "Appearance"
}, },
{
"id": "background",
"label": "Background",
"description": "",
"type": "color",
"defaultValue": "#000000",
"group": "Appearance"
},
{
"id": "opacity",
"label": "Background Opacity",
"description": "",
"type": "number",
"defaultValue": "0.85",
"min": 0,
"max": 1,
"step": ".01",
"group": "Appearance"
},
{ {
"id": "hideAfter", "id": "hideAfter",
"label": "Hide After", "label": "Hide After",
+14 -3
View File
@@ -62,12 +62,23 @@ html {
line-height: 1.7em; line-height: 1.7em;
width: 100%; width: 100%;
text-align: center; text-align: center;
bottom: calc(-1 * var(--margin) - 2em); }
#background {
position: absolute;
bottom: 0;
right: 50%;
transform: translateX(50%);
width: 100%;
height: 1.7em;
background: var(--background);
bottom: calc(-1 * var(--margin));
z-index: -100;
} }
@keyframes showAlertBox { @keyframes showAlertBox {
0% { 0% {
bottom: calc(-1 * var(--margin) - 2em); bottom: calc(-1 * var(--margin) - 1.7em);
} }
100% { 100% {
bottom: 0px; bottom: 0px;
@@ -79,7 +90,7 @@ html {
bottom: 0px; bottom: 0px;
} }
100% { 100% {
bottom: calc(-1 * var(--margin) - 2em); bottom: calc(-1 * var(--margin) - 1.7em);
} }
} }