caps_enhancer/auto-update.bat
2026-03-23 15:36:40 +03:00

41 lines
1.3 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
setlocal
set VERSION_URL=https://git.ihateamerica.ru/caps_enhancer/version.json
set ZIP_URL=https://git.ihateamerica.ru/caps_enhancer/caps-enhancer.zip
set EXT_DIR=%~dp0
:: Читаем локальную версию из manifest.json
for /f "delims=" %%v in ('powershell -NoProfile -Command "(Get-Content '%EXT_DIR%manifest.json' | ConvertFrom-Json).version"') do set LOCAL_VER=%%v
:: Читаем удалённую версию
for /f "delims=" %%v in ('curl -sf "%VERSION_URL%"') do set REMOTE_JSON=%%v
for /f "delims=" %%v in ('powershell -NoProfile -Command "'%REMOTE_JSON%' | ConvertFrom-Json | Select-Object -ExpandProperty version"') do set REMOTE_VER=%%v
if not defined REMOTE_VER (
echo [ОШИБКА] Не удалось получить версию с сервера.
goto :end
)
if "%LOCAL_VER%"=="%REMOTE_VER%" (
echo [OK] Версия актуальная: %LOCAL_VER%
goto :end
)
echo [INFO] Обновление: %LOCAL_VER% --^> %REMOTE_VER%
set TMP_ZIP=%TEMP%\caps-enhancer-update.zip
curl -f "%ZIP_URL%" -o "%TMP_ZIP%"
if errorlevel 1 (
echo [ОШИБКА] Не удалось скачать ZIP.
goto :end
)
tar -xf "%TMP_ZIP%" -C "%EXT_DIR%" --overwrite
del "%TMP_ZIP%"
echo [OK] Обновлено до версии %REMOTE_VER%. Перезагрузи расширение в Chrome.
:end
endlocal
pause