Add patch.ps1

This commit is contained in:
dahyeon committed 2026-03-02 08:07:45 +00:00
commit 9630d66d18
1 file changed
+60
+60
View File
@@ -0,0 +1,60 @@
$ErrorActionPreference = "Stop"
$ResourcesDir = Join-Path $env:LOCALAPPDATA "Programs\Mingo\resources"
$AsarPath = Join-Path $ResourcesDir "app.asar"
$BackupPath = Join-Path $ResourcesDir ("app.asar.bak-" + (Get-Date -Format "yyyyMMdd-HHmmss"))
$UnpackedDir = Join-Path $ResourcesDir "app_unpacked"
$AssetsDir = Join-Path $UnpackedDir "out\renderer\assets"
$MonoValue = '"D2Coding", Consolas, monospace'
$UiValue = '"Asta Sans","Microsoft GothicNeo","Segoe UI","Malgun Gothic",sans-serif'
# 1. Backup
Copy-Item $AsarPath $BackupPath -Force
Write-Host "Backup created: $BackupPath"
# 2. Extract
if (Test-Path $UnpackedDir) {
Remove-Item $UnpackedDir -Recurse -Force
}
New-Item -ItemType Directory -Path $UnpackedDir | Out-Null
asar extract $AsarPath $UnpackedDir
# 3. Find CSS
$CssFile = Get-ChildItem $AssetsDir -Filter "index-*.css" |
Sort-Object Length -Descending |
Select-Object -First 1
if (-not $CssFile) {
throw "index-*.css not found."
}
$CssPath = $CssFile.FullName
Write-Host "Patching CSS: $CssPath"
$Content = Get-Content $CssPath -Raw
# Replace mono variable
$Content = [regex]::Replace(
$Content,
'(?m)^\s*--font-family-mono\s*:\s*[^;]+;\s*$',
" --font-family-mono: $MonoValue;",
1
)
# Replace body font-family inside body block
$Content = [regex]::Replace(
$Content,
'(?ms)(body\s*\{.*?)(^\s*font-family\s*:\s*[^;]+;\s*$)(.*?\})',
"`$1 font-family: $UiValue;`n`$3",
1
)
Set-Content -Path $CssPath -Value $Content -Encoding UTF8
# 4. Pack
Set-Location $ResourcesDir
asar pack $UnpackedDir $AsarPath
Write-Host "Done ✅"
Write-Host "If anything breaks, restore: $BackupPath"