diff --git a/src/js/colorModeJS.tw b/src/js/colorModeJS.tw index f45e6f0fbcfaf7dbf4c907b1260fb73a29c7270c..4b68f8a642b0dc102cddff2bd8809b6f0d78245d 100644 --- a/src/js/colorModeJS.tw +++ b/src/js/colorModeJS.tw @@ -1,26 +1,21 @@ :: colorModeJS [script] window.setColors = function(colorMap){ + let props = ["color","backgroundColor","backgroundImage"]; let styleSheetArray = Array.from(document.styleSheets); styleSheetArray.forEach( styleSheet => { let cssRules = Array.from(styleSheet.cssRules); cssRules.forEach( cssRule => { if ( cssRule.type === 1 ){ - let color = cssRule.style.color; - let bgcolor = cssRule.style.backgroundColor; - if ( - color != "" && - color != "inherit" ){ - cssRule.style.color = colorMap[color] || color; - console.log('color: ',color); - } - if ( - bgcolor != "" && - bgcolor != "inherit" && - bgcolor != "transparent" ){ - cssRule.style.backgroundColor = colorMap[bgcolor] || bgcolor; - console.log('color: ',color); - } + props.forEach( propName => { + let currentValue = cssRule.style[propName]; + if ( + currentValue != "" && + currentValue != "inherit" && + currentValue != "transparent"){ + cssRule.style[propName] = colorMap[currentValue] || currentValue; + } + }) } }); });