mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Fix text replace bug.
This commit is contained in:
parent
be7b9e1272
commit
b465ab47c3
@ -61,7 +61,7 @@ function getStyle(key, settings)
|
||||
settings.filterBrightness = foreground === "#000" ? "0" : "100";
|
||||
for (key of Object.keys(settings))
|
||||
{
|
||||
style = style.replace(`$${key}`, settings[key]);
|
||||
style = style.replace(new RegExp("\\$" + key, "g"), settings[key]);
|
||||
}
|
||||
return style;
|
||||
};
|
||||
|
||||
2
utils/common.min.js
vendored
2
utils/common.min.js
vendored
@ -1 +1 @@
|
||||
function waitForQuery(){const MaxRetry=30;let retry=0;const tryQuery=(query,condition,action,failed)=>{if(retry>=30)failed&&failed();else{const result=query();condition(result)?action(result):(retry++,setTimeout(()=>tryQuery(query,condition,action,failed),500))}};return tryQuery}function getStyle(key,settings){const style=GM_getResourceText(key),replaceCustomColor=(style,settings)=>{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(key of(settings.brightness=`${"#000"===foreground?"100":"0"}%`,settings.filterBrightness="#000"===foreground?"0":"100",Object.keys(settings)))style=style.replace(`$${key}`,settings[key]);return style};return replaceCustomColor(style,settings)}
|
||||
function waitForQuery(){const MaxRetry=30;let retry=0;const tryQuery=(query,condition,action,failed)=>{if(retry>=30)failed&&failed();else{const result=query();condition(result)?action(result):(retry++,setTimeout(()=>tryQuery(query,condition,action,failed),500))}};return tryQuery}function getStyle(key,settings){const style=GM_getResourceText(key),replaceCustomColor=(style,settings)=>{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(key of(settings.brightness=`${"#000"===foreground?"100":"0"}%`,settings.filterBrightness="#000"===foreground?"0":"100",Object.keys(settings)))style=style.replace(new RegExp("\\$"+key,"g"),settings[key]);return style};return replaceCustomColor(style,settings)}
|
||||
Loading…
Reference in New Issue
Block a user