if SpotX was detected

Improvement of the algorithm in cases where SpotX installation has already been detected
This commit is contained in:
amd64fox
2022-05-21 11:35:55 +03:00
parent 29236075a1
commit de6eaaf1d4
2 changed files with 66 additions and 20 deletions

View File

@@ -494,6 +494,7 @@ $test_js = Test-Path -Path $xpui_js_patch
$xpui_js_bak_patch = "$env:APPDATA\Spotify\Apps\xpui\xpui.js.bak"
$xpui_css_bak_patch = "$env:APPDATA\Spotify\Apps\xpui\xpui.css.bak"
$xpui_lic_bak_patch = "$env:APPDATA\Spotify\Apps\xpui\licenses.html.bak"
$spotify_exe_bak_patch = "$env:APPDATA\Spotify\Spotify.bak"
if ($test_spa -and $test_js) {
@@ -515,15 +516,26 @@ if (Test-Path $xpui_js_patch) {
$test_xpui_js_bak = Test-Path -Path $xpui_js_bak_patch
$test_xpui_css_bak = Test-Path -Path $xpui_css_bak_patch
$test_xpui_lic_bak = Test-Path -Path $xpui_lic_bak_patch
$test_spotify_exe_bak = Test-Path -Path $spotify_exe_bak_patch
if ($test_xpui_js_bak -and $test_xpui_css_bak -and $test_xpui_lic_bak) {
Write-Host "SpotX has already been installed, xpui.js and xpui.css restore..."`n
Remove-Item $xpui_js_patch -Recurse -Force
Remove-Item $xpui_css_patch -Recurse -Force
Remove-Item $xpui_lic_patch -Recurse -Force
Rename-Item $xpui_js_bak_patch $xpui_js_patch
Rename-Item $xpui_css_bak_patch $xpui_css_patch
Rename-Item $xpui_lic_bak_patch $xpui_lic_patch
if ($test_xpui_js_bak -or $test_xpui_css_bak) {
if ($test_xpui_js_bak) {
Remove-Item $xpui_js_patch -Recurse -Force
Rename-Item $xpui_js_bak_patch $xpui_js_patch
}
if ($test_xpui_css_bak) {
Remove-Item $xpui_css_patch -Recurse -Force
Rename-Item $xpui_css_bak_patch $xpui_css_patch
}
if ($test_xpui_lic_bak) {
Remove-Item $xpui_lic_patch -Recurse -Force
Rename-Item $xpui_lic_bak_patch $xpui_lic_patch
}
if ($test_spotify_exe_bak) {
Remove-Item $spotifyExecutable -Recurse -Force
Rename-Item $spotify_exe_bak_patch $spotifyExecutable
}
}
else {
Write-Host "SpotX has already been installed, xpui.js and xpui.css not found. `nPlease uninstall Spotify client and run Install.bat again, script is stopped."`n
@@ -605,14 +617,26 @@ If (Test-Path $xpui_spa_patch) {
$zip.Dispose()
if ($test_bak_spa) {
Write-Host "SpotX has already been installed, xpui.spa restore..."`n
Remove-Item $xpui_spa_patch -Recurse -Force
Rename-Item $bak_spa $xpui_spa_patch
$spotify_exe_bak_patch = "$env:APPDATA\Spotify\Spotify.bak"
$test_spotify_exe_bak = Test-Path -Path $spotify_exe_bak_patch
if ($test_spotify_exe_bak) {
Remove-Item $spotifyExecutable -Recurse -Force
Rename-Item $spotify_exe_bak_patch $spotifyExecutable
}
}
else {
Write-Host "SpotX has already been installed, xpui.bak not found, please uninstall Spotify client and run Install.bat again, script is stopped."`n
exit
}
$spotify_exe_bak_patch = "$env:APPDATA\Spotify\Spotify.bak"
$test_spotify_exe_bak = Test-Path -Path $spotify_exe_bak_patch
if ($test_spotify_exe_bak) {
Remove-Item $spotifyExecutable -Recurse -Force
Rename-Item $spotify_exe_bak_patch $spotifyExecutable
}
}
$zip.Dispose()
Copy-Item $xpui_spa_patch $env:APPDATA\Spotify\Apps\xpui.bak

View File

@@ -591,6 +591,7 @@ $xpui_js_bak_patch = "$env:APPDATA\Spotify\Apps\xpui\xpui.js.bak"
$xpui_css_bak_patch = "$env:APPDATA\Spotify\Apps\xpui\xpui.css.bak"
$xpui_lic_bak_patch = "$env:APPDATA\Spotify\Apps\xpui\licenses.html.bak"
$xpui_ru_bak_patch = "$env:APPDATA\Spotify\Apps\xpui\i18n\ru.json.bak"
$spotify_exe_bak_patch = "$env:APPDATA\Spotify\Spotify.bak"
if ($test_spa -and $test_js) {
@@ -618,17 +619,31 @@ if (Test-Path $xpui_js_patch) {
$test_xpui_css_bak = Test-Path -Path $xpui_css_bak_patch
$test_xpui_lic_bak = Test-Path -Path $xpui_lic_bak_patch
$test_xpui_ru_bak = Test-Path -Path $xpui_ru_bak_patch
$test_spotify_exe_bak = Test-Path -Path $spotify_exe_bak_patch
if ($test_xpui_js_bak -or $test_xpui_css_bak) {
if ($test_xpui_js_bak) {
Remove-Item $xpui_js_patch -Recurse -Force
Rename-Item $xpui_js_bak_patch $xpui_js_patch
}
if ($test_xpui_css_bak) {
Remove-Item $xpui_css_patch -Recurse -Force
Rename-Item $xpui_css_bak_patch $xpui_css_patch
}
if ($test_xpui_lic_bak) {
Remove-Item $xpui_lic_patch -Recurse -Force
Rename-Item $xpui_lic_bak_patch $xpui_lic_patch
}
if ($test_xpui_ru_bak) {
Remove-Item $xpui_ru_patch -Recurse -Force
Rename-Item $xpui_ru_bak_patch $xpui_ru_patch
}
if ($test_spotify_exe_bak) {
Remove-Item $spotifyExecutable -Recurse -Force
Rename-Item $spotify_exe_bak_patch $spotifyExecutable
}
if ($test_xpui_js_bak -and $test_xpui_css_bak -and $test_xpui_lic_bak -and $test_xpui_ru_bak) {
Write-Host "SpotX уже был установлен, xpui.js и xpui.css будут восстановлены..."`n
Remove-Item $xpui_js_patch -Recurse -Force
Remove-Item $xpui_css_patch -Recurse -Force
Remove-Item $xpui_lic_patch -Recurse -Force
Remove-Item $xpui_ru_patch -Recurse -Force
Rename-Item $xpui_js_bak_patch $xpui_js_patch
Rename-Item $xpui_css_bak_patch $xpui_css_patch
Rename-Item $xpui_lic_bak_patch $xpui_lic_patch
Rename-Item $xpui_ru_bak_patch $xpui_ru_patch
}
else {
Write-Host "SpotX уже был установлен, xpui.js.bak и xpui.css.bak не найдены. `nУдалите клиент Spotify и снова запустите Install_Rus.bat, скрипт остановлен."`n
@@ -726,9 +741,16 @@ If (Test-Path $xpui_spa_patch) {
$zip.Dispose()
if ($test_bak_spa) {
Write-Host "SpotX уже был установлен, xpui.spa будет восстановлен..."`n
Remove-Item $xpui_spa_patch -Recurse -Force
Rename-Item $bak_spa $xpui_spa_patch
$spotify_exe_bak_patch = "$env:APPDATA\Spotify\Spotify.bak"
$test_spotify_exe_bak = Test-Path -Path $spotify_exe_bak_patch
if ($test_spotify_exe_bak) {
Remove-Item $spotifyExecutable -Recurse -Force
Rename-Item $spotify_exe_bak_patch $spotifyExecutable
}
}
else {
Write-Host "SpotX уже был установлен, xpui.bak не найден. `nУдалите клиент Spotify и снова запустите Install_Rus.bat, скрипт остановлен."`n