Mod to set the color outside of the canvas

Use the pageColor query parameter to specify a color.
Pass "?pageColor=bg" to use the color in settings.bg (the user-defined canvas background color)
Supports anything that can be a color string, but # has to be %23.
This commit is contained in:
O-01-67 2022-05-17 12:48:00 -04:00 committed by GitHub
parent d665c38f6a
commit 3c2bee69ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

16
mods/page_color.js Normal file
View File

@ -0,0 +1,16 @@
urlParams = new URLSearchParams(window.location.search);
backgroundUseStrings = ["bg","background","settings.bg"]
if(urlParams.get('pageColor') != null) { //null check
color = urlParams.get('pageColor');
if(color === "" || color === null) { //NaN check
color = "black";
};
if(backgroundUseStrings.includes(color.toLowerCase())) {
!settings.bg ? color = "black" : color = settings.bg;
color = settings.bg;
};
};
document.body.style.backgroundColor = color;