@echo off
setlocal EnableExtensions EnableDelayedExpansion
title Happ Proxy Installer - Vtornik Cloud
color 0b

echo =========================================================================
echo                 Happ Proxy Installer (Vtornik Cloud)
echo =========================================================================
echo.
echo  [1] Google Chrome
echo  [2] Microsoft Edge
echo  [3] Yandex Browser
echo  [4] Brave Browser
echo  [5] Opera / Opera GX
echo  [0] Exit
echo.
echo =========================================================================
set /p browser_choice="Choose your browser [1-5]: "

if "%browser_choice%"=="1" set target_browser=chrome
if "%browser_choice%"=="2" set target_browser=msedge
if "%browser_choice%"=="3" set target_browser=browser
if "%browser_choice%"=="4" set target_browser=brave
if "%browser_choice%"=="5" set target_browser=opera
if "%browser_choice%"=="0" exit /b 0

if not defined target_browser set target_browser=chrome

echo.
echo [1/3] Downloading extension files...
set DEST_DIR=%LOCALAPPDATA%\HappProxyExtension
if not exist "%DEST_DIR%" mkdir "%DEST_DIR%"

powershell -NoProfile -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri 'https://vtornik.space/download/happ-zip' -OutFile '%TEMP%\happ-temp.zip'; Expand-Archive -Path '%TEMP%\happ-temp.zip' -DestinationPath '%DEST_DIR%' -Force; Remove-Item '%TEMP%\happ-temp.zip' -Force -ErrorAction SilentlyContinue"

echo [2/3] Copying directory path to clipboard...
<nul set /p="%DEST_DIR%" | clip

echo [3/3] Opening browser extensions page...
if "%target_browser%"=="chrome" start chrome "chrome://extensions"
if "%target_browser%"=="msedge" start msedge "edge://extensions"
if "%target_browser%"=="browser" start browser "browser://extensions" 2>nul || start yandex "browser://extensions"
if "%target_browser%"=="brave" start brave "brave://extensions"
if "%target_browser%"=="opera" start opera "opera://extensions"

cls
color 0a
echo =========================================================================
echo           HAPP PROXY EXTENSION IS READY TO LOAD!
echo =========================================================================
echo.
echo  Path copied to clipboard:
echo  %DEST_DIR%
echo.
echo =========================================================================
echo  QUICK 3-STEP INSTRUCTION:
echo =========================================================================
echo.
echo  1. In the top-right corner of the opened browser window, turn ON:
echo     [ Developer mode ]
echo.
echo  2. In the top-left corner, click:
echo     [ Load unpacked ]
echo.
echo  3. Press Ctrl + V (paste path) and click [ Select Folder ]!
echo.
echo =========================================================================
echo  Done! Happ Proxy icon will appear in your browser toolbar.
echo =========================================================================
echo.
pause
