install proxy server now integrated with installation

This commit is contained in:
SpikeHD 2022-04-21 17:17:00 -07:00
parent fed7490129
commit 88b08b9b1b
3 changed files with 33 additions and 9 deletions

View File

@ -8,7 +8,7 @@
<script src="js/index.js"></script>
</head>
<body>
<div id="firstTimeNotice">
<div id="firstTimeNotice" style="display: none">
<span>
<span class="boldTitle">Looks like this is your first time opening GrassClipper!<br/></span>
First of all, welcome, happy to see you here! :)<br/><br/>
@ -17,7 +17,7 @@
</span>
<div id="firstTimeBtns">
<button class="playBtn" id="firstTimeBtn" onclick="runInstallScript()">Install</button>
<button class="altBtn" id="firstTimeBtn">No thanks</button>
<button class="altBtn" id="firstTimeBtn" onclick="closeFirstTimePopup()">No thanks</button>
</div>
</div>
<div id="settingsPanel" style="display: none;">
@ -41,7 +41,7 @@
<div id="controlBar">
<span id="titleSection">
GrassClipper
<span id="version">0.4.0</span>
<span id="version">0.4.1</span>
</span>
<div id="settingsBtn" onclick="openSettings()">
<img src="icons/cog.svg" />

View File

@ -86,6 +86,9 @@ async function getCfg() {
const cfgStr = await Neutralino.storage.getData('config').catch(e => {
// The data isn't set, so this is our first time opening
Neutralino.storage.setData('config', JSON.stringify(defaultConf))
// Show the first time notice if there is no config
document.querySelector('#firstTimeNotice').style.display = 'block'
})
const config = cfgStr ? JSON.parse(cfgStr) : defaultConf
@ -328,6 +331,17 @@ async function toggleKillSwitch() {
Neutralino.storage.setData('config', JSON.stringify(config))
}
async function closeFirstTimePopup() {
const firstTimePopup = document.querySelector('#firstTimeNotice')
firstTimePopup.style.display = 'none'
}
async function runInstallScript() {
Neutralino.os.execCommand(`${NL_CWD}/scripts/install.cmd "${NL_CWD}"`)
closeFirstTimePopup()
}
/**
* Set the game folder by opening a folder picker
*/

View File

@ -1,25 +1,31 @@
@echo off
set ORIGIN=%1
set ORIGIN=%ORIGIN:"=%
:: Ensure admin
>nul 2>&1 reg query "HKU\S-1-5-19" || (
set params = %*:"="""%
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 "%1" ", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )
)
echo Downloading proxy server...
if not exist "./ext" mkdir "ext"
if not exist "./temp" mkdir "temp"
:: Make sure we are in the right directory
cd "%ORIGIN%"
if not exist "%ORIGIN%/ext" mkdir "%ORIGIN%/ext"
if not exist "%ORIGIN%/temp" mkdir "%ORIGIN%/temp"
:: Begin by retrieving mitmproxy 8.0.0
powershell Invoke-WebRequest -Uri https://snapshots.mitmproxy.org/8.0.0/mitmproxy-8.0.0-windows.zip -OutFile "./temp/mitmproxy-8.0.0-windows.zip"
powershell Invoke-WebRequest -Uri https://snapshots.mitmproxy.org/8.0.0/mitmproxy-8.0.0-windows.zip -OutFile "%ORIGIN%/temp/mitmproxy-8.0.0-windows.zip"
echo Extracting...
:: Extract from temp/ to ext/ with powershell
powershell Expand-Archive -Path "./temp/mitmproxy-8.0.0-windows.zip" -DestinationPath "./ext/" -Force
powershell Expand-Archive -Path "%ORIGIN%/temp/mitmproxy-8.0.0-windows.zip" -DestinationPath "%ORIGIN%/ext/" -Force
del /s /q "./temp"
del /s /q "%ORIGIN%/temp"
echo Running proxy server in order to generate certificates...
@ -32,6 +38,8 @@ ping 127.0.0.1 -n 6 > nul
:: Kill the process
taskkill /f /im mitmdump.exe
echo Adding ceritifcate...
:: Ensure we are elevated for certs
>nul 2>&1 certutil -addstore root %USERPROFILE%\.mitmproxy\mitmproxy-ca-cert.cer || (
echo Certificate install failed, ensure the script is running as Administrator and that the path "%USERPROFILE%\.mitmproxy" exists,
@ -40,3 +48,5 @@ taskkill /f /im mitmdump.exe
echo Done! You can now open GrassClipper.exe!
pause
exit /b