mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
978 B
JavaScript
1 line
978 B
JavaScript
function waitForQuery(){const MaxRetry=settings.maxQueryRetry;let retry=0;const tryQuery=(query,condition,action,failed)=>{if(retry>=MaxRetry)failed&&failed();else{const result=query();condition(result)?action(result):(retry++,setTimeout(()=>tryQuery(query,condition,action,failed),settings.queryInterval))}};return tryQuery}function getStyle(name){const style=GM_getResourceText(name);function replaceCustomColor(style){const foreground=(()=>{const regex=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(settings.customStyleColor),color=regex?{r:parseInt(regex[1],16),g:parseInt(regex[2],16),b:parseInt(regex[3],16)}:void 0;if(color){const grey=1-(.299*color.r+.587*color.g+.114*color.b)/255;return grey<.35?"#000":"#fff"}return"#fff"})();for(name of(settings.brightness=`${"#000"===foreground?"100":"0"}%`,settings.filterBrightness="#000"===foreground?"0":"100",settings))style=style.replace(`$${name}`,settings[name]);return style}return replaceCustomColor(style,foreground)} |