Skip to content

Commit

Permalink
adapt font in game notices and remove bold font in zzz
Browse files Browse the repository at this point in the history
  • Loading branch information
Scighost committed Jan 19, 2025
1 parent dad5509 commit 5a80a31
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Starward/Features/GameLauncher/GameNoticeWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ private async void CoreWebView2_DOMContentLoaded(CoreWebView2 sender, CoreWebVie
miHoYoGameJSSDK.closeWebview = () => chrome.webview.postMessage({ "action": "close" });
miHoYoGameJSSDK.openInBrowser = (url) => chrome.webview.postMessage({ "action": "url", "param": url });
miHoYoGameJSSDK.openInWebview = (url) => chrome.webview.postMessage({ "action": "url", "param": url });
function RemoveBg() {
let root = document.getElementById("root");
if (root === null) {
Expand All @@ -194,7 +195,33 @@ function RemoveBg() {
}
}
}
function modifyAllFontFaces() {
for (let sheet of document.styleSheets) {
try {
for (let i = sheet.cssRules.length - 1; i >= 0; i--) {
const rule = sheet.cssRules[i];
if (rule instanceof CSSFontFaceRule) {
if (rule.style.fontFamily.includes("bh3")) {
let src = rule.style.getPropertyValue("src").replace("http://127.0.0.1:1221/font", "https://webstatic.mihoyo.com/bh3/upload/announcement/font");
rule.style.setProperty("src", src);
} else if (rule.style.fontFamily.includes("ys")) {
let src = rule.style.getPropertyValue("src").replace("http://127.0.0.1:1221/font", "https://sdk.mihoyo.com/hk4e/fonts");
rule.style.setProperty("src", src);
} else if (rule.style.fontFamily.includes("rpg")) {
let src = rule.style.getPropertyValue("src").replace("http://127.0.0.1:1221/font", "https://sdk.mihoyo.com/hkrpg/fonts");
rule.style.setProperty("src", src);
} else if (rule.style.fontFamily.includes("nap")) {
sheet.deleteRule(i);
}
}
}
} catch (e) { }
}
}
RemoveBg();
modifyAllFontFaces();
""";
await webview.CoreWebView2.ExecuteScriptAsync(script);
await Task.Delay(300);
Expand Down

0 comments on commit 5a80a31

Please sign in to comment.