mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
1.7 KiB
JavaScript
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=e=>r.rgbToString(r.hexToRgba(e));const l=r.hexToRgba(o+"70");$("div.custom-color-preview").css("background",o).css("box-shadow",`0px 2px 8px 1px rgba(${l.r},${l.g},${l.b},${l.a})`);e.style.setProperty("--theme-color",o);for(let r=10;r<=90;r+=10){e.style.setProperty(`--theme-color-${r}`,t(o+r))}e.style.setProperty("--foreground-color",r.foreground);e.style.setProperty("--foreground-color-b",t(r.foreground+"b"));e.style.setProperty("--foreground-color-d",t(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").click()})}$("div.custom-color-preview").on("click",()=>{const e=$(".predefined-colors");e.toggleClass("opened")})}}return{export:{ThemeColors:t}}}})(); |