Mod now supports triplets that are missing a #

so FF0000 will become #FF0000 and be used
This commit is contained in:
O-01-67 2022-05-17 13:27:28 -04:00 committed by GitHub
parent 3c2bee69ed
commit b3176a8c0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 1 deletions

View File

@ -13,4 +13,23 @@ if(urlParams.get('pageColor') != null) { //null check
};
};
document.body.style.backgroundColor = color;
color_Would_Be_A_Triplet_If_It_Started_With_An_Octothorpe = null;
color_Is_Supported_As_A_Background_By_The_Browser = null;
if( /^#([0-9A-F]{3}){1,2}$/i.test("#" + color) ) {
color_Would_Be_A_Triplet_If_It_Started_With_An_Octothorpe = true
} else {
color_Would_Be_A_Triplet_If_It_Started_With_An_Octothorpe = false
}
if( CSS.supports('background',color) ) {
color_Is_Supported_As_A_Background_By_The_Browser = true
} else {
color_Is_Supported_As_A_Background_By_The_Browser = false
}
if(color_Is_Supported_As_A_Background_By_The_Browser == false && color_Would_Be_A_Triplet_If_It_Started_With_An_Octothorpe == true) {
color = "#" + color
}
document.body.style.background = color;