@echo off
rem Fanshun ERP extension - auto-update setup (run ONCE, no admin needed)
rem What it does: registers the extension update source in Chrome/Edge policy,
rem so the browser installs and updates it by itself from now on.
setlocal
set "APPID=gbbgngocfglofjhdmodldakeihbbhcmn"
set "URL=https://www.fanshun.vip/api/extension/update.xml"
set "JSON={\"installation_mode\":\"normal_installed\",\"update_url\":\"%URL%\"}"

echo Registering update source for Chrome...
reg add "HKCU\Software\Policies\Google\Chrome\ExtensionSettings\%APPID%" /ve /t REG_SZ /d "%JSON%" /f >nul 2>&1
if %errorlevel%==0 (echo   OK) else (echo   FAILED - run this file as administrator)

echo Registering update source for Edge...
reg add "HKCU\Software\Policies\Microsoft\Edge\ExtensionSettings\%APPID%" /ve /t REG_SZ /d "%JSON%" /f >nul 2>&1
if %errorlevel%==0 (echo   OK) else (echo   FAILED - run this file as administrator)

echo.
echo Done. Now:
echo   1. Close and reopen Chrome / Edge - the extension installs by itself.
echo   2. Open chrome://extensions and REMOVE the old unpacked "Fanshun ERP"
echo      (keep only the policy-installed one), then reload ERP page once.
echo   3. Open ERP and log in once - the extension picks up your session.
echo After that, every new version is downloaded by the browser automatically.
echo.
pause
