From cbae9f31c260f4c08140a5e19392366b87619ee1 Mon Sep 17 00:00:00 2001 From: SpikeHD <spikegdofficial@gmail.com> Date: Fri, 29 Apr 2022 22:42:56 -0700 Subject: [PATCH 1/8] use registry login option --- resources/index.html | 10 ++++++++++ resources/js/helpers.js | 1 + resources/js/index.js | 2 ++ resources/js/options.js | 9 +++++++++ resources/style/index.css | 4 ++-- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/resources/index.html b/resources/index.html index f59f5ea..08a74a7 100644 --- a/resources/index.html +++ b/resources/index.html @@ -182,6 +182,16 @@ Choose between using HTTPS or HTTP. </span> </div> + <div class="settingsRow"> + <div class="settingSection"> + <span class="settingLabel", id="registryLoginTitle">Login with Registry</span> + <input type="checkbox" id="registryOption" onchange="toggleRegistryLogin()" /> + </select> + </div> + <span class="settingSubtitle" id="registrySubtitle"> + Instead of copying login tokens when authenticating, you can login via a modification to the registry. Clears the registry data on game close. + </span> + </div> </div> </div> diff --git a/resources/js/helpers.js b/resources/js/helpers.js index c0b31c0..c8457d2 100644 --- a/resources/js/helpers.js +++ b/resources/js/helpers.js @@ -12,6 +12,7 @@ serverLaunchPanel: false, language: 'en', useHttps: true, + registryLogin: true } const cfgStr = await Neutralino.storage.getData('config').catch(e => { // The data isn't set, so this is our first time opening diff --git a/resources/js/index.js b/resources/js/index.js index 3070a54..3b946e9 100644 --- a/resources/js/index.js +++ b/resources/js/index.js @@ -258,10 +258,12 @@ async function openSettings() { const killSwitch = document.querySelector('#killswitchOption') const serverLaunch = document.querySelector('#serverLaunchOption') const httpsCheckbox = document.querySelector('#httpsOption') + const registryCheckbox = document.querySelector('#registryOption') killSwitch.checked = config.enableKillswitch serverLaunch.checked = config.serverLaunchPanel httpsCheckbox.checked = config.useHttps + registryCheckbox.checked = config.registryLogin // Load languages getLanguages() diff --git a/resources/js/options.js b/resources/js/options.js index 1b74f53..693095a 100644 --- a/resources/js/options.js +++ b/resources/js/options.js @@ -81,6 +81,15 @@ async function handleLanguageChange(elm) { Neutralino.storage.setData('config', JSON.stringify(config)) } +async function toggleRegistryLogin() { + const registryCheckbox = document.querySelector('#registryOption') + const config = await getCfg() + + config.registryLogin = registryCheckbox.checked + + Neutralino.storage.setData('config', JSON.stringify(config)) +} + /** * Add the current value of the IP input to the favorites list * OR diff --git a/resources/style/index.css b/resources/style/index.css index ff31870..b3149cb 100644 --- a/resources/style/index.css +++ b/resources/style/index.css @@ -189,7 +189,7 @@ a { flex-direction: column; align-items: center; justify-content: center; - padding: 10px 10%; + padding: 0 10%; } .settingsRow { @@ -206,7 +206,7 @@ a { display:inline-block; font-size: 1em; font-weight: normal; - margin: 10px 0px; + margin: 6px 0px; } .settingSubtitle { From 141f8dbeb2bae676a774f1eedac5ef78f8672c3e Mon Sep 17 00:00:00 2001 From: SpikeHD <spikegdofficial@gmail.com> Date: Fri, 29 Apr 2022 22:45:14 -0700 Subject: [PATCH 2/8] registry login translations --- languages/en.json | 2 ++ resources/index.html | 2 +- resources/js/translation.js | 2 ++ scripts/private_server_launch.cmd | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/languages/en.json b/languages/en.json index a7ecafe..21da443 100644 --- a/languages/en.json +++ b/languages/en.json @@ -28,6 +28,8 @@ "enableServerLauncherSubtitle": "Enable to server launcher tile for launching a local Grasscutter instance.", "httpsOption": "Use HTTPS", "httpsSubtitle": "Choose between using HTTPS or HTTP.", + "registryOption": "Login via Windows Registry", + "registrySubtitle": "Instead of copying login tokens when authenticating, you can login via a modification to the registry. Clears the registry data on game close.", "introSen1": "Looks like this is your first time opening GrassClipper!", "introSen2": "First of all, welcome, happy to see you here! :)", diff --git a/resources/index.html b/resources/index.html index 08a74a7..f7900c8 100644 --- a/resources/index.html +++ b/resources/index.html @@ -184,7 +184,7 @@ </div> <div class="settingsRow"> <div class="settingSection"> - <span class="settingLabel", id="registryLoginTitle">Login with Registry</span> + <span class="settingLabel", id="registryLoginTitle">Login via Windows Registry</span> <input type="checkbox" id="registryOption" onchange="toggleRegistryLogin()" /> </select> </div> diff --git a/resources/js/translation.js b/resources/js/translation.js index 986b03c..ceec561 100644 --- a/resources/js/translation.js +++ b/resources/js/translation.js @@ -58,6 +58,8 @@ async function doTranslation() { set('serverSubtitle', 'enableServerLauncherSubtitle') set('httpsTitle', 'httpsOption') set('httpsSubtitle', 'httpsSubtitle') + set('registryLoginTitle', 'registryOption') + set('registrySubtitle', 'registrySubtitle') // Intro popup const popup = document.getElementById('firstTimeNotice') diff --git a/scripts/private_server_launch.cmd b/scripts/private_server_launch.cmd index 0cc7b12..54a1f7b 100644 --- a/scripts/private_server_launch.cmd +++ b/scripts/private_server_launch.cmd @@ -84,7 +84,7 @@ taskkill /f /im mitmdump.exe echo Done, see you next time :: Just in case the user has corutils installed, use this hacky timeout instead of the timeout command -ping 127.0.0.1 -n 2 > nul +ping 127.0.0.1 -n 1 > nul :: Attempt to kill either taskkill /f /fi "WINDOWTITLE eq Administrator: PS Launcher Script" From 860f88daf51fb6483a3a0dca61c21175f058e5c9 Mon Sep 17 00:00:00 2001 From: SpikeHD <spikegdofficial@gmail.com> Date: Fri, 29 Apr 2022 22:55:59 -0700 Subject: [PATCH 3/8] get mtools and change en translation --- languages/en.json | 8 ++++---- resources/index.html | 4 ++-- resources/js/translation.js | 1 + scripts/install.cmd | 5 +++++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/languages/en.json b/languages/en.json index 21da443..db862fe 100644 --- a/languages/en.json +++ b/languages/en.json @@ -18,12 +18,12 @@ "scriptsSectionTitle": "Scripts", "killswitchOption": "Kill Switch", "killswitchSubtitle": "Only for those very paranoid about bans. Kills the game process *and your internet* if something happens to the proxy.", - "proxyOption": "Proxy", - "proxySubtitle": "Install the proxy server via the install script", + "proxyOption": "Run Installer", + "proxySubtitle": "Install (or reinstall) the proxy server and mtools via the install script.", "updateOption": "Update", "updateSubtitle": "Auto updating is temporarily disabled. Check GitHub for the newest release.", "languageOption": "Language", - "languageSubtitle": "Select your language!", + "languageSubtitle": "Select your language", "enableServerLauncherOption": "Enable Server Launcher", "enableServerLauncherSubtitle": "Enable to server launcher tile for launching a local Grasscutter instance.", "httpsOption": "Use HTTPS", @@ -33,7 +33,7 @@ "introSen1": "Looks like this is your first time opening GrassClipper!", "introSen2": "First of all, welcome, happy to see you here! :)", - "introSen3": "Would you like to run the proxy installer?", + "introSen3": "Would you like to run the first-time installer?", "introSen4": "(required to connect to servers)", "updateBtn": "Update", diff --git a/resources/index.html b/resources/index.html index f7900c8..86db3e9 100644 --- a/resources/index.html +++ b/resources/index.html @@ -137,11 +137,11 @@ </div> <div class="settingsRow"> <div class="settingSection"> - <span class="settingLabel" id="proxyTitle">Install Proxy Server</span> + <span class="settingLabel" id="proxyTitle">Run Installer</span> <button class="smolBtn" onclick="runInstallScript()" id="proxyInstall">Install</button> </div> <span class="settingSubtitle" id="proxySubtitle"> - Install the proxy server via the install script. + Install the proxy server and mtools via the install script. </span> </div> <div class="settingsRow"> diff --git a/resources/js/translation.js b/resources/js/translation.js index ceec561..8411eaf 100644 --- a/resources/js/translation.js +++ b/resources/js/translation.js @@ -75,6 +75,7 @@ async function doTranslation() { introSpan.innerHTML += localeObj.introSen3 + '<br>' introSpan.innerHTML += localeObj.introSen4 + '<br>' + // First time popup set('firstTimeInstallBtn', 'proxyInstallBtn') set('firstTimeDenyBtn', 'proxyInstallDeny') diff --git a/scripts/install.cmd b/scripts/install.cmd index 99e27c3..6e3558d 100644 --- a/scripts/install.cmd +++ b/scripts/install.cmd @@ -10,6 +10,7 @@ cd "%ORIGIN%" if not exist "%ORIGIN%/ext" mkdir "%ORIGIN%/ext" if not exist "%ORIGIN%/temp" mkdir "%ORIGIN%/temp +if not exist "%ORIGIN%/tools" mkdir "%ORIGIN%/tools" :: Begin by retrieving mitmproxy 7.0.4 powershell Invoke-WebRequest -Uri https://snapshots.mitmproxy.org/7.0.4/mitmproxy-7.0.4-windows.zip -OutFile "'%ORIGIN%/temp/mitmproxy-7.0.4-windows.zip'" @@ -44,6 +45,10 @@ echo Adding ceritifcate... echo ============================================================================================================ ) +echo Grabbing registry login tool... + +powershell Invoke-WebRequest -Uri https://github.com/SpikeHD/miHoYoTools/releases/download/v1.0.0/mtools.exe -OutFile "'%ORIGIN%/tools/mtools.exe'" + echo Done! You can now open GrassClipper.exe! pause From 07c331051be36022c8ce053301821d05ac4f4bc1 Mon Sep 17 00:00:00 2001 From: SpikeHD <spikegdofficial@gmail.com> Date: Sat, 30 Apr 2022 00:07:43 -0700 Subject: [PATCH 4/8] get/set/clear registry functions --- .gitignore | 1 + resources/js/helpers.js | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/.gitignore b/.gitignore index 2ccb550..58e3c18 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ bin/ dist/ ext/ temp/ +tools/ resources/js/neutralino.js resources/bg/official diff --git a/resources/js/helpers.js b/resources/js/helpers.js index c8457d2..74b32f0 100644 --- a/resources/js/helpers.js +++ b/resources/js/helpers.js @@ -103,6 +103,32 @@ async function openGrasscutterFolder() { openInExplorer(folder) } +async function getRegistryLoginDetails() { + const results = await Neutralino.os.execCommand('.\\tools\\mtools.exe show') + const out = results.stdErr + + if (!out) return {} + + const parsed = JSON.parse(out) + + return parsed.data +} + +async function clearRegistryLoginDetails() { + createCmdWindow(`.\\tools\\mtools.exe set -a "" -u "" -t "" -d ""`) +} + +async function setRegistryLoginDetails(tokenOrAccount, loginUid) { + const accList = await getRegistryLoginDetails() + const cur = accList.find(a => a.is_login) + + // Required fields: uid, token, account, deviceId + + const { token, deviceId } = cur + + createCmdWindow(`.\\tools\\mtools.exe set -a ${tokenOrAccount} -u ${loginUid} -t ${token} -d ${deviceId}`) +} + /** * Minimize the window */ From 116109a2a7d2fed5bf6ee6a6f044c1d11e67560f Mon Sep 17 00:00:00 2001 From: SpikeHD <spikegdofficial@gmail.com> Date: Sat, 30 Apr 2022 00:20:26 -0700 Subject: [PATCH 5/8] being setting data on login --- resources/js/helpers.js | 4 ++-- resources/js/login.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/resources/js/helpers.js b/resources/js/helpers.js index 74b32f0..4bccccc 100644 --- a/resources/js/helpers.js +++ b/resources/js/helpers.js @@ -120,13 +120,13 @@ async function clearRegistryLoginDetails() { async function setRegistryLoginDetails(tokenOrAccount, loginUid) { const accList = await getRegistryLoginDetails() - const cur = accList.find(a => a.is_login) + const cur = accList.find(a => a.is_login) || accList[0] // Required fields: uid, token, account, deviceId const { token, deviceId } = cur - createCmdWindow(`.\\tools\\mtools.exe set -a ${tokenOrAccount} -u ${loginUid} -t ${token} -d ${deviceId}`) + createCmdWindow(`.\\tools\\mtools.exe set -a "${tokenOrAccount}" -u "${loginUid}" -t "${token}" -d "${deviceId}"`) } /** diff --git a/resources/js/login.js b/resources/js/login.js index 5fd7f8e..b62676c 100644 --- a/resources/js/login.js +++ b/resources/js/login.js @@ -93,7 +93,10 @@ async function login() { await Neutralino.clipboard.writeText(tkData.token) displayLoginAlert(localeObj.alertLoginSuccess || 'Login successful! Token copied to clipboard. Paste this token into the username field of the game to log in.', 'success', 8000); - launchPrivate() + + await setRegistryLoginDetails(tkData.token, tkData.uid) + await launchPrivate() + break; } } From 099794fb39738be53f56d1f03c955d3960463f40 Mon Sep 17 00:00:00 2001 From: SpikeHD <spikegdofficial@gmail.com> Date: Sat, 30 Apr 2022 00:52:31 -0700 Subject: [PATCH 6/8] grab name --- resources/js/helpers.js | 6 +++--- resources/js/login.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/js/helpers.js b/resources/js/helpers.js index 4bccccc..617858e 100644 --- a/resources/js/helpers.js +++ b/resources/js/helpers.js @@ -115,10 +115,10 @@ async function getRegistryLoginDetails() { } async function clearRegistryLoginDetails() { - createCmdWindow(`.\\tools\\mtools.exe set -a "" -u "" -t "" -d ""`) + createCmdWindow(`.\\tools\\mtools.exe set -a "" -u "" -t "" -d "" -n ""`) } -async function setRegistryLoginDetails(tokenOrAccount, loginUid) { +async function setRegistryLoginDetails(tokenOrAccount, loginUid, name) { const accList = await getRegistryLoginDetails() const cur = accList.find(a => a.is_login) || accList[0] @@ -126,7 +126,7 @@ async function setRegistryLoginDetails(tokenOrAccount, loginUid) { const { token, deviceId } = cur - createCmdWindow(`.\\tools\\mtools.exe set -a "${tokenOrAccount}" -u "${loginUid}" -t "${token}" -d "${deviceId}"`) + createCmdWindow(`.\\tools\\mtools.exe set -a "${tokenOrAccount}" -u "${loginUid}" -t "${token}" -d "${deviceId}" -n "${name}"`) } /** diff --git a/resources/js/login.js b/resources/js/login.js index b62676c..9c91636 100644 --- a/resources/js/login.js +++ b/resources/js/login.js @@ -94,7 +94,7 @@ async function login() { displayLoginAlert(localeObj.alertLoginSuccess || 'Login successful! Token copied to clipboard. Paste this token into the username field of the game to log in.', 'success', 8000); - await setRegistryLoginDetails(tkData.token, tkData.uid) + await setRegistryLoginDetails(tkData.token, tkData.uid, username) await launchPrivate() break; From 2ec22dc180c51de1efcc6e2dcfbfc2b158aa4c6f Mon Sep 17 00:00:00 2001 From: SpikeHD <spikegdofficial@gmail.com> Date: Sat, 30 Apr 2022 00:54:14 -0700 Subject: [PATCH 7/8] update mtools --- scripts/install.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install.cmd b/scripts/install.cmd index 6e3558d..8c3deb6 100644 --- a/scripts/install.cmd +++ b/scripts/install.cmd @@ -47,7 +47,7 @@ echo Adding ceritifcate... echo Grabbing registry login tool... -powershell Invoke-WebRequest -Uri https://github.com/SpikeHD/miHoYoTools/releases/download/v1.0.0/mtools.exe -OutFile "'%ORIGIN%/tools/mtools.exe'" +powershell Invoke-WebRequest -Uri https://github.com/SpikeHD/miHoYoTools/releases/download/v1.0.1/mtools.exe -OutFile "'%ORIGIN%/tools/mtools.exe'" echo Done! You can now open GrassClipper.exe! From eb9a0b549188f73be13ecb405eb506ce9c3bfcce Mon Sep 17 00:00:00 2001 From: SpikeHD <spikegdofficial@gmail.com> Date: Sat, 30 Apr 2022 00:55:41 -0700 Subject: [PATCH 8/8] update translation file --- languages/en.json | 2 +- resources/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/languages/en.json b/languages/en.json index db862fe..39cde09 100644 --- a/languages/en.json +++ b/languages/en.json @@ -29,7 +29,7 @@ "httpsOption": "Use HTTPS", "httpsSubtitle": "Choose between using HTTPS or HTTP.", "registryOption": "Login via Windows Registry", - "registrySubtitle": "Instead of copying login tokens when authenticating, you can login via a modification to the registry. Clears the registry data on game close.", + "registrySubtitle": "Instead of copying login tokens when authenticating, you can login via a modification to the registry. Clears the registry data on game close. Registry tool courtesy of Asnxthaony.", "introSen1": "Looks like this is your first time opening GrassClipper!", "introSen2": "First of all, welcome, happy to see you here! :)", diff --git a/resources/index.html b/resources/index.html index 86db3e9..9f7ad71 100644 --- a/resources/index.html +++ b/resources/index.html @@ -189,7 +189,7 @@ </select> </div> <span class="settingSubtitle" id="registrySubtitle"> - Instead of copying login tokens when authenticating, you can login via a modification to the registry. Clears the registry data on game close. + Instead of copying login tokens when authenticating, you can login via a modification to the registry. Clears the registry data on game close. Registry tool courtesy of Asnxthaony. </span> </div> </div>