Bilibili-Evolved/min/theme-colors.min.js
2018-12-18 21:51:54 +08:00

1 line
1.7 KiB
JavaScript

(()=>{return(e,o)=>{const r={red:"#e57373",pink:"#F06292",purple:"#BA68C8",deepPurple:"#9575CD",indigo:"#7986CB",blue:"#2196F3",lightBlue:"#00A0D8",cyan:"#00ACC1",teal:"#26A69A",green:"#81C784",lightGreen:"#9CCC65",orange:"#FF9800",deepOrange:"#FF7043",brown:"#A1887F",grey:"#757575",blueGrey:"#78909C"};class t{constructor(){this.reloadColor=(()=>{const e=document.querySelector("html");return function(o){const r=new ColorProcessor(o);const t=r.hexToRgba(o+"70");$("div.custom-color-preview").css("background",o).css("box-shadow",`0px 2px 8px 1px rgba(${t.r},${t.g},${t.b},${t.a})`);e.style.setProperty("--theme-color",o);for(let t=10;t<=90;t+=10){e.style.setProperty(`--theme-color-${t}`,r.rgbToString(r.hexToRgba(o+t)))}e.style.setProperty("--foreground-color",r.foreground);e.style.setProperty("--foreground-color-b",r.rgbToString(r.hexToRgba(r.foreground+"b")));e.style.setProperty("--foreground-color-d",r.rgbToString(r.hexToRgba(r.foreground+"d")));e.style.setProperty("--blue-image-filter",r.blueImageFilter);e.style.setProperty("--pink-image-filter",r.pinkImageFilter);e.style.setProperty("--brightness",r.brightness);e.style.setProperty("--invert-filter",r.filterInvert)}})()}setupDom(){$(`input[key='customStyleColor']`).on("change",()=>{this.reloadColor($(`input[key='customStyleColor']`).val())});const e=$(".predefined-colors-grid");for(const o of Object.values(r)){$(`<div class='predefined-colors-grid-block'></div>`).appendTo(e).css("background",o).attr("data-color",o).on("click",e=>{const o=$(e.target).attr("data-color");$(`input[key='customStyleColor']`).val(o).trigger("input").change();$("div.custom-color-preview").on("click")})}$("div.custom-color-preview").on("click",()=>{const e=$(".predefined-colors");e.toggleClass("opened")})}}return{export:t}}})();