param ( [Parameter(HelpMessage = 'Remove podcasts from homepage.')] [switch]$podcasts_off, [Parameter(HelpMessage = 'Do not remove podcasts from homepage.')] [switch]$podcasts_on, [Parameter(HelpMessage = 'Block Spotify automatic updates.')] [switch]$block_update_on, [Parameter(HelpMessage = 'Do not block Spotify automatic updates.')] [switch]$block_update_off, [Parameter(HelpMessage = 'Enable clear cache.')] [switch]$cache_on, [Parameter(HelpMessage = 'Specify the number of days. Default is 7 days.')] [int16]$number_days = 7, [Parameter(HelpMessage = 'Do not enable cache clearing.')] [switch]$cache_off, [Parameter(HelpMessage = 'Automatic uninstallation of Spotify MS if it was found.')] [switch]$confirm_uninstall_ms_spoti, [Parameter(HelpMessage = 'Overwrite outdated or unsupported version of Spotify with the recommended version.')] [switch]$confirm_spoti_recomended_over, [Parameter(HelpMessage = 'Uninstall outdated or unsupported version of Spotify and install the recommended version.')] [switch]$confirm_spoti_recomended_unistall, [Parameter(HelpMessage = 'Installation without ad blocking for premium accounts.')] [switch]$premium, [Parameter(HelpMessage = 'Automatic launch of Spotify after installation is complete.')] [switch]$start_spoti, [Parameter(HelpMessage = 'Experimental features operated by Spotify.')] [switch]$exp_spotify, [Parameter(HelpMessage = 'Experimental features of SpotX are not included')] [switch]$exp_standart, [Parameter(HelpMessage = 'Do not hide the icon of collaborations in playlists.')] [switch]$hide_col_icon_off, [Parameter(HelpMessage = 'Do not enable the made for you button on the left sidebar.')] [switch]$made_for_you_off, [Parameter(HelpMessage = 'Do not enable enhance playlist.')] [switch]$enhance_playlist_off, [Parameter(HelpMessage = 'Do not enable enhance liked songs.')] [switch]$enhance_like_off, [Parameter(HelpMessage = 'Do not enable new discography on artist.')] [switch]$new_artist_pages_off, [Parameter(HelpMessage = 'Do not enable new lyrics.')] [switch]$new_lyrics_off, [Parameter(HelpMessage = 'Do not enable exception playlists from recommendations.')] [switch]$ignore_in_recommendations_off, [Parameter(HelpMessage = 'Enable audio equalizer for Desktop.')] [switch]$equalizer_off, [Parameter(HelpMessage = 'Enable showing a new and improved device picker UI.')] [switch]$device_new_off, [Parameter(HelpMessage = 'Enabled the new home structure and navigation.')] [switch]$enablenavalt, [Parameter(HelpMessage = 'Select the desired language to use for installation. Default is the detected system language.')] [Alias('l')] [string]$Language ) # Ignore errors from `Stop-Process` $PSDefaultParameterValues['Stop-Process:ErrorAction'] = [System.Management.Automation.ActionPreference]::SilentlyContinue function Format-LanguageCode { # Normalizes and confirms support of the selected language. [CmdletBinding()] [OutputType([string])] param ( [string]$LanguageCode ) begin { $supportLanguages = @( 'en', 'ru' ) } process { # Trim the language code down to two letter code. switch -Regex ($LanguageCode) { '^en' { $returnCode = 'en' break } '^(ru|py)' { $returnCode = 'ru' break } Default { $returnCode = $PSUICulture.Remove(2) break } } # Confirm that the language code is supported by this script. if ($returnCode -NotIn $supportLanguages) { # If the language code is not supported default to English. $returnCode = 'en' } } end { return $returnCode } } function Set-ScriptLanguageStrings { #Sets the language strings to be used. [CmdletBinding()] [OutputType([object])] param ( [Parameter(Mandatory = $true, HelpMessage = 'Two letter language code.')] [string]$LanguageCode ) begin { # Define language strings. $langStringsEN = [PSCustomObject]@{ Author = "Author:" Incorrect = "Oops, an incorrect value," Incorrect2 = "enter again through " Download = "Error downloading" Download2 = "Will re-request in 5 seconds..." Download3 = "Error again" Download4 = "Check your network settings and run the installation again" Download5 = "Downloading Spotify" Download6 = "Failed web request via curl" StopScrpit = "Script is stopped" MsSpoti = "The Microsoft Store version of Spotify has been detected which is not supported" MsSpoti2 = "Uninstall Spotify Windows Store edition [Y/N]" MsSpoti3 = "Automatic uninstalling Spotify MS..." MsSpoti4 = "Uninstalling Spotify MS..." Prem = "Modification for premium account..." DownBts = "Downloading latest patch BTS..." OldV = "Found outdated version of Spotify" OldV2 = "Your Spotify {0} version is outdated, it is recommended to upgrade to {1}" OldV3 = "Want to update ? [Y/N]" AutoUpd = "Automatic update to the recommended version" DelOrOver = "Do you want to uninstall the current version of {0} or install over it? Y [Uninstall] / N [Install Over]" DelOld = "Uninstalling old Spotify..." NewV = "Unsupported version of Spotify found" NewV2 = "Your Spotify {0} version hasn't been tested yet, currently it's a stable {1} version" NewV3 = "Do you want to continue with {0} version (errors possible) ? [Y/N]" Recom = "Do you want to install the recommended {0} version ? [Y/N]" DelNew = "Uninstalling an untested Spotify..." DownSpoti = "Downloading and installing Spotify" DownSpoti2 = "Please wait..." PodcatsOff = "Off Podcasts" PodcastsOn = "On Podcasts" PodcatsSelect = "Do you want to disable podcasts from the main page? [Y/N]" DowngradeNote = "It is recommended to block because there was a downgrade of Spotify" UpdBlock = "Spotify updates blocked" UpdUnblock = "Spotify updates are not blocked" UpdSelect = "Want to block Spotify updates? [Y/N]" CacheOn = "Clear cache enabled ({0})" CacheOff = "Clearing the cache is not enabled" CacheSelect = "Want to set up automatic cache cleanup? [Y/N]" CacheDays = "Cache older: XX days to be cleared " CacheDays2 = "Enter the number of days from 1 to 100" NoVariable = "Didn't find variable" NoVariable2 = "in xpui.js" NoVariable3 = "in licenses.html" NoVariable4 = "in html" ModSpoti = "Patching Spotify..." Error = "Error" FileLocBroken = "Location of Spotify files is broken, uninstall the client and run the script again" Spicetify = "Spicetify detected" NoRestore = "SpotX has already been installed, xpui.js and xpui.css not found. `nPlease uninstall Spotify client and run Install.bat again" ExpSpotify = "Experimental features operated by Spotify" ExpStandart = "Experimental features of SpotX are not included" NoRestore2 = "SpotX has already been installed, xpui.bak not found. `nPlease uninstall Spotify client and run Install.bat again" UpdateBlocked = "Spotify updates are already blocked" UpdateError = "Failed to block updates" NoSpotifyExe = "Could not find Spotify.exe" InstallComplete = "installation completed" HostInfo = "Unwanted URLs found in hosts file" HostBak = "Backing up hosts.bak..." HostDel = "Trying to remove unwanted URLs from the original hosts file..." HostError = "Something went wrong while editing the hosts file, edit it manually" } $langStringsRU = [PSCustomObject]@{ Author = "Автор:" Incorrect = "Ой, некорректное значение," Incorrect2 = "повторите ввод через" Download = "Ошибка загрузки" Download2 = "Повторный запрос через 5 секунд..." Download3 = "Опять ошибка" Download4 = "Проверьте настройки вашей сети и снова запустите установку" Download5 = "Загрузка Spotify" Download6 = "Неудачный веб-запрос через curl" StopScrpit = "Cкрипт остановлен" MsSpoti = "Обнаружена версия Spotify из Microsoft Store, которая не поддерживается" MsSpoti2 = "Хотите удалить Spotify Microsoft Store ? [Y/N]" MsSpoti3 = "Автоматическое удаление Spotify MS..." MsSpoti4 = "Удаление Spotify MS..." Prem = "Модификация для премиум аккаунта..." DownBts = "Загружаю последний патч BTS..." OldV = "Найдена устаревшая версия Spotify" OldV2 = "Ваша версия Spotify {0} устарела, рекомендуется обновиться до {1}" OldV3 = "Обновить ? [Y/N]" AutoUpd = "Автоматическое обновление до рекомендуемой версии" DelOrOver = "Вы хотите удалить текущую версию {0} или установить поверх нее? Y [Удалить] / N [Поверх]" DelOld = "Удаление устаревшего Spotify..." NewV = "Найдена неподдерживаемая версия Spotify" NewV2 = "Ваша версия Spotify {0} еще не тестировалась, стабильная версия сейчас {1}" NewV3 = "Хотите продолжить с {0} (возможны ошибки) ? [Y/N]" Recom = "Хотите установить рекомендуемую {0} версию ? [Y/N]" DelNew = "Удаление неподдерживаемого Spotify..." DownSpoti = "Загружаю и устанавливаю Spotify" DownSpoti2 = "Пожалуйста подождите..." PodcatsOff = "Подкасты отключены" PodcastsOn = "Подкасты не отключены" PodcatsSelect = "Хотите отключить подкасты c главной страницы ? [Y/N]" DowngradeNote = "Рекомендуется заблокировать т.к. было понижение версии Spotify" UpdBlock = "Обновления Spotify заблокированы" UpdUnblock = "Обновления Spotify не заблокированы" UpdSelect = "Хотите заблокировать обновления Spotify ? [Y/N]" CacheOn = "Очистка кеша включена ({0})" CacheOff = "Очистка кеша не включена" CacheSelect = "Хотите установить автоматическую очистку кеша ? [Y/N]" CacheDays = "Кэш старше: XX дней будет очищен" CacheDays2 = "Пожалуйста, введите количество дней от 1 до 100" NoVariable = "Не нашел переменную" NoVariable2 = "в xpui.js" NoVariable3 = "в licenses.html" NoVariable4 = "в html" NoVariable5 = "в ru.json" ModSpoti = "Модифицирую Spotify..." Error = "Ошибка" FileLocBroken = "Расположение файлов Spotify нарушено, удалите клиент и снова запустите скрипт" Spicetify = "Обнаружен Spicetify" NoRestore = "SpotX уже был установлен, но файлы для восстановления xpui.js.bak и xpui.css.bak не найдены. `nУдалите клиент Spotify и снова запустите Install.bat" ExpSpotify = "Экспериментальные функции управляются Spotify" ExpStandart = "Экспериментальные функции SpotX не включены" NoRestore2 = "SpotX уже был установлен, но файл для восстановления xpui.bak не найден. `nУдалите клиент Spotify и снова запустите Install.bat" UpdateBlocked = "Обновления Spotify уже заблокированы" UpdateError = "Не удалось заблокировать обновления" NoSpotifyExe = "Spotify.exe не найден" InstallComplete = "Установка завершена" HostInfo = "В файле hosts найдены нежелательные Url-адреса" HostBak = "Создаю резервную кописю hosts.bak..." HostDel = "Попытка удалить нежелательные Url-адреса из оригинального файла hosts..." HostError = "Что-то пошло не так при редактировании файла hosts, отредактируйте его вручную" } } process { # Assign language strings. switch ($LangCode) { 'en' { $langStrings = $langStringsEN break } 'ru' { $langStrings = $langStringsRU break } Default { # Default to English if unable to find a match. $langStrings = $langStringsEN break } } } end { return $langStrings } } # Set language code for script. $langCode = Format-LanguageCode -LanguageCode $Language # Set script language strings. $lang = Set-ScriptLanguageStrings -LanguageCode $langCode # Set variable 'ru'. if ($langCode -eq 'ru') { $ru = $true } Write-Host "*****************" Write-Host ($lang).Author"" -NoNewline Write-Host "@Amd64fox" -ForegroundColor DarkYellow Write-Host "*****************"`n # Sending a statistical web query to cutt.ly $ErrorActionPreference = 'SilentlyContinue' $cutt_url = "https://cutt.ly/DK8UQub" try { Invoke-WebRequest -Uri $cutt_url | Out-Null } catch { Start-Sleep -Milliseconds 2300 try { Invoke-WebRequest -Uri $cutt_url | Out-Null } catch { } } $spotifyDirectory = "$env:APPDATA\Spotify" $spotifyDirectory2 = "$env:LOCALAPPDATA\Spotify" $spotifyExecutable = "$spotifyDirectory\Spotify.exe" $exe_bak = "$spotifyDirectory\Spotify.bak" $chrome_elf = "$spotifyDirectory\chrome_elf.dll" $chrome_elf_bak = "$spotifyDirectory\chrome_elf_bak.dll" $cache_folder = "$env:APPDATA\Spotify\cache" $spotifyUninstall = "$env:TEMP\SpotifyUninstall.exe" $upgrade_client = $false function incorrectValue { Write-Host ($lang).Incorrect"" -ForegroundColor Red -NoNewline Write-Host ($lang).Incorrect2"" -NoNewline Start-Sleep -Milliseconds 1000 Write-Host "3" -NoNewline Start-Sleep -Milliseconds 1000 Write-Host " 2" -NoNewline Start-Sleep -Milliseconds 1000 Write-Host " 1" Start-Sleep -Milliseconds 1000 Clear-Host } function Check_verison_clients($param2) { # checking the recommended version for spotx if ($param2 -eq "online") { $ProgressPreference = 'SilentlyContinue' # Hiding Progress Bars $readme = Invoke-WebRequest -UseBasicParsing -Uri https://raw.githubusercontent.com/amd64fox/SpotX/main/README.md $v = $readme.RawContent | Select-String "Recommended official version \[\d+\.\d+\.\d+\.\d+\]" -AllMatches $ver = $v.Matches.Value $ver = $ver -replace 'Recommended official version \[(\d+\.\d+\.\d+\.\d+)\]', '$1' return $ver } # Check version Spotify offline if ($param2 -eq "offline") { $check_offline = (Get-Item $spotifyExecutable).VersionInfo.FileVersion return $check_offline } # Check version Spotify.bak if ($param2 -eq "Spotify.bak") { $check_offline_bak = (Get-Item $exe_bak).VersionInfo.FileVersion return $check_offline_bak } } function unlockFolder { $ErrorActionPreference = 'SilentlyContinue' $block_File_update = "$env:LOCALAPPDATA\Spotify\Update" $Check_folder = Get-ItemProperty -Path $block_File_update | Select-Object Attributes $folder_update_access = Get-Acl $block_File_update # Check folder Update if it exists if ($Check_folder -match '\bDirectory\b') { # If the rights of the Update folder are blocked, then unblock if ($folder_update_access.AccessToString -match 'Deny') { ($ACL = Get-Acl $block_File_update).access | ForEach-Object { $Users = $_.IdentityReference $ACL.PurgeAccessRules($Users) } $ACL | Set-Acl $block_File_update } } } function downloadScripts($param1) { $webClient = New-Object -TypeName System.Net.WebClient if ($param1 -eq "Desktop") { Import-Module BitsTransfer $ver = Check_verison_clients -param2 "online" $l = "$PWD\links.tsv" $old = [IO.File]::ReadAllText($l) $links = $old -match "https:\/\/upgrade.scdn.co\/upgrade\/client\/win32-x86\/spotify_installer-$ver\.g[0-9a-f]{8}-[0-9]{1,3}\.exe" $links = $Matches.Values } if ($ru -and $param1 -eq "cache-spotify") { $links2 = "https://raw.githubusercontent.com/amd64fox/SpotX/main/scripts/cache/cache_spotify_ru.ps1" } if (!($ru) -and $param1 -eq "cache-spotify" ) { $links2 = "https://raw.githubusercontent.com/amd64fox/SpotX/main/scripts/cache/cache_spotify.ps1" } $web_Url_prev = "https://github.com/mrpond/BlockTheSpot/releases/latest/download/chrome_elf.zip", $links, ` $links2, "https://raw.githubusercontent.com/amd64fox/SpotX/main/scripts/cache/hide_window.vbs", ` "https://raw.githubusercontent.com/amd64fox/SpotX/main/scripts/cache/run_ps.bat", "https://docs.google.com/spreadsheets/d/e/2PACX-1vSFN2hWu4UO-ZWyVe8wlP9c0JsrduA49xBnRmSLOt8SWaOfIpCwjDLKXMTWJQ5aKj3WakQv6-Hnv9rz/pub?gid=0&single=true&output=tsv" $local_Url_prev = "$PWD\chrome_elf.zip", "$PWD\SpotifySetup.exe", "$cache_folder\cache_spotify.ps1", "$cache_folder\hide_window.vbs", "$cache_folder\run_ps.bat", "$PWD\links.tsv" $web_name_file_prev = "chrome_elf.zip", "SpotifySetup.exe", "cache_spotify.ps1", "hide_window.vbs", "run_ps.bat", "links.tsv" switch ( $param1 ) { "BTS" { $web_Url = $web_Url_prev[0]; $local_Url = $local_Url_prev[0]; $web_name_file = $web_name_file_prev[0] } "Desktop" { $web_Url = $web_Url_prev[1]; $local_Url = $local_Url_prev[1]; $web_name_file = $web_name_file_prev[1] } "cache-spotify" { $web_Url = $web_Url_prev[2]; $local_Url = $local_Url_prev[2]; $web_name_file = $web_name_file_prev[2] } "hide_window" { $web_Url = $web_Url_prev[3]; $local_Url = $local_Url_prev[3]; $web_name_file = $web_name_file_prev[3] } "run_ps" { $web_Url = $web_Url_prev[4]; $local_Url = $local_Url_prev[4]; $web_name_file = $web_name_file_prev[4] } "links.tsv" { $web_Url = $web_Url_prev[5]; $local_Url = $local_Url_prev[5]; $web_name_file = $web_name_file_prev[5] } } if ($param1 -eq "Desktop") { try { if (curl.exe -V) { $curl_check = $true } } catch { $curl_check = $false } $vernew = Check_verison_clients -param2 "online" } try { if ($param1 -eq "Desktop" -and $curl_check) { $stcode = curl.exe -I -s $web_Url if (!($stcode -match "200 OK")) { throw ($lang).Download6 } curl.exe $web_Url -o $local_Url --progress-bar --retry 3 --ssl-no-revoke } if ($param1 -eq "Desktop" -and $null -ne (Get-Module -Name BitsTransfer -ListAvailable) -and !($curl_check )) { Start-BitsTransfer -Source $web_Url -Destination $local_Url -DisplayName ($lang).Download5 -Description "$vernew " } if ($param1 -eq "Desktop" -and $null -eq (Get-Module -Name BitsTransfer -ListAvailable) -and !($curl_check )) { $webClient.DownloadFile($web_Url, $local_Url) } if ($param1 -ne "Desktop") { $ProgressPreference = 'SilentlyContinue' # Hiding Progress Bars $webClient.DownloadFile($web_Url, $local_Url) } } catch { Write-Host "" Write-Host ($lang).Download $web_name_file -ForegroundColor RED $Error[0].Exception Write-Host "" Write-Host ($lang).Download2`n Start-Sleep -Milliseconds 5000 try { if ($param1 -eq "Desktop" -and $curl_check) { $stcode = curl.exe -I -s $web_Url if (!($stcode -match "200 OK")) { throw ($lang).Download6 } curl.exe $web_Url -o $local_Url --progress-bar --retry 3 --ssl-no-revoke } if ($param1 -eq "Desktop" -and $null -ne (Get-Module -Name BitsTransfer -ListAvailable) -and !($curl_check )) { Start-BitsTransfer -Source $web_Url -Destination $local_Url -DisplayName ($lang).Download5 -Description "$vernew " } if ($param1 -eq "Desktop" -and $null -eq (Get-Module -Name BitsTransfer -ListAvailable) -and !($curl_check )) { $webClient.DownloadFile($web_Url, $local_Url) } if ($param1 -ne "Desktop") { $ProgressPreference = 'SilentlyContinue' # Hiding Progress Bars $webClient.DownloadFile($web_Url, $local_Url) } } catch { Write-Host ($lang).Download3 -ForegroundColor RED $Error[0].Exception Write-Host "" Write-Host ($lang).Download4`n ($lang).StopScrpit $tempDirectory = $PWD Pop-Location Start-Sleep -Milliseconds 200 Remove-Item -Recurse -LiteralPath $tempDirectory Pause Exit } } } function DesktopFolder { # If the default Dekstop folder does not exist, then try to find it through the registry. $ErrorActionPreference = 'SilentlyContinue' if (Test-Path "$env:USERPROFILE\Desktop") { $desktop_folder = "$env:USERPROFILE\Desktop" } $regedit_desktop_folder = Get-ItemProperty -Path "Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\" $regedit_desktop = $regedit_desktop_folder.'{754AC886-DF64-4CBA-86B5-F7FBF4FBCEF5}' if (!(Test-Path "$env:USERPROFILE\Desktop")) { $desktop_folder = $regedit_desktop } return $desktop_folder } # add Tls12 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Stop-Process -Name Spotify if ($PSVersionTable.PSVersion.major -ge 7) { Import-Module Appx -UseWindowsPowerShell -WarningAction:SilentlyContinue } # Check version Windows $win_os = (get-itemproperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName).ProductName $win11 = $win_os -match "\windows 11\b" $win10 = $win_os -match "\windows 10\b" $win8_1 = $win_os -match "\windows 8.1\b" $win8 = $win_os -match "\windows 8\b" if ($win11 -or $win10 -or $win8_1 -or $win8) { # Remove Spotify Windows Store If Any if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic) { Write-Host ($lang).MsSpoti`n if (!($confirm_uninstall_ms_spoti)) { do { $ch = Read-Host -Prompt ($lang).MsSpoti2 Write-Host "" if (!($ch -eq 'n' -or $ch -eq 'y')) { incorrectValue } } while ($ch -notmatch '^y$|^n$') } if ($confirm_uninstall_ms_spoti) { $ch = 'y' } if ($ch -eq 'y') { $ProgressPreference = 'SilentlyContinue' # Hiding Progress Bars if ($confirm_uninstall_ms_spoti) { Write-Host ($lang).MsSpoti3`n } if (!($confirm_uninstall_ms_spoti)) { Write-Host ($lang).MsSpoti4`n } Get-AppxPackage -Name SpotifyAB.SpotifyMusic | Remove-AppxPackage } if ($ch -eq 'n') { Read-Host ($lang).StopScrpit Pause Exit } } } # Attempt to fix the hosts file $pathHosts = "$Env:windir\System32\Drivers\Etc\hosts" $pathHosts_bak = "$Env:windir\System32\Drivers\Etc\hosts.bak" $ErrorActionPreference = 'SilentlyContinue' $testHosts = Test-Path -Path $pathHosts if ($testHosts) { $hosts = Get-Content -Path $pathHosts if ($hosts -match '^[^\#|].+scdn.+|^[^\#|].+spotify.+') { Write-Host ($lang).HostInfo Write-Host ($lang).HostBak copy-Item $pathHosts $pathHosts_bak Write-Host ($lang).HostDel`n try { $hosts = $hosts -replace '^[^\#|].+scdn.+|^[^\#|].+spotify.+', '' Set-Content -Path $pathHosts -Value $hosts -Force $hosts | Where-Object { $_.trim() -ne "" } | Set-Content -Path $pathHosts -Force } catch { Write-Host ($lang).HostError`n -ForegroundColor Red } } } # Unique directory name based on time Push-Location -LiteralPath $env:TEMP New-Item -Type Directory -Name "SpotX_Temp-$(Get-Date -UFormat '%Y-%m-%d_%H-%M-%S')" | Convert-Path | Set-Location if ($premium) { Write-Host ($lang).Prem`n } if (!($premium)) { Write-Host ($lang).DownBts`n downloadScripts -param1 "BTS" Add-Type -Assembly 'System.IO.Compression.FileSystem' $zip = [System.IO.Compression.ZipFile]::Open("$PWD\chrome_elf.zip", 'read') [System.IO.Compression.ZipFileExtensions]::ExtractToDirectory($zip, $PWD) $zip.Dispose() } downloadScripts -param1 "links.tsv" $online = Check_verison_clients -param2 "online" $spotifyInstalled = (Test-Path -LiteralPath $spotifyExecutable) if ($spotifyInstalled) { $offline = Check_verison_clients -param2 "offline" if ($online -gt $offline) { if ($confirm_spoti_recomended_over -or $confirm_spoti_recomended_unistall) { Write-Host ($lang).OldV`n } if (!($confirm_spoti_recomended_over) -and !($confirm_spoti_recomended_unistall)) { do { Write-Host (($lang).OldV2 -f $offline, $online) $ch = Read-Host -Prompt ($lang).OldV3 Write-Host "" if (!($ch -eq 'n' -or $ch -eq 'y')) { incorrectValue } } while ($ch -notmatch '^y$|^n$') } if ($confirm_spoti_recomended_over -or $confirm_spoti_recomended_unistall) { $ch = 'y' Write-Host ($lang).AutoUpd`n } if ($ch -eq 'y') { $upgrade_client = $true if (!($confirm_spoti_recomended_over) -and !($confirm_spoti_recomended_unistall)) { do { $ch = Read-Host -Prompt (($lang).DelOrOver -f $offline) Write-Host "" if (!($ch -eq 'n' -or $ch -eq 'y')) { incorrectValue } } while ($ch -notmatch '^y$|^n$') } if ($confirm_spoti_recomended_unistall) { $ch = 'y' } if ($confirm_spoti_recomended_over) { $ch = 'n' } if ($ch -eq 'y') { Write-Host ($lang).DelOld`n unlockFolder cmd /c $spotifyExecutable /UNINSTALL /SILENT wait-process -name SpotifyUninstall Start-Sleep -Milliseconds 200 if (Test-Path $spotifyDirectory) { Remove-Item -Recurse -Force -LiteralPath $spotifyDirectory } if (Test-Path $spotifyDirectory2) { Remove-Item -Recurse -Force -LiteralPath $spotifyDirectory2 } if (Test-Path $spotifyUninstall ) { Remove-Item -Recurse -Force -LiteralPath $spotifyUninstall } } if ($ch -eq 'n') { $ch = $null } } if ($ch -eq 'n') { $downgrading = $true } } if ($online -lt $offline) { if ($confirm_spoti_recomended_over -or $confirm_spoti_recomended_unistall) { Write-Host ($lang).NewV`n } if (!($confirm_spoti_recomended_over) -and !($confirm_spoti_recomended_unistall)) { do { Write-Host (($lang).NewV2 -f $offline, $online) $ch = Read-Host -Prompt (($lang).NewV3 -f $offline) Write-Host "" if (!($ch -eq 'n' -or $ch -eq 'y')) { incorrectValue } } while ($ch -notmatch '^y$|^n$') } if ($confirm_spoti_recomended_over -or $confirm_spoti_recomended_unistall) { $ch = 'n' } if ($ch -eq 'y') { $upgrade_client = $false } if ($ch -eq 'n') { if (!($confirm_spoti_recomended_over) -and !($confirm_spoti_recomended_unistall)) { do { $ch = Read-Host -Prompt (($lang).Recom -f $online) Write-Host "" if (!($ch -eq 'n' -or $ch -eq 'y')) { incorrectValue } } while ($ch -notmatch '^y$|^n$') } if ($confirm_spoti_recomended_over -or $confirm_spoti_recomended_unistall) { $ch = 'y' Write-Host ($lang).AutoUpd`n } if ($ch -eq 'y') { $upgrade_client = $true $downgrading = $true if (!($confirm_spoti_recomended_over) -and !($confirm_spoti_recomended_unistall)) { do { $ch = Read-Host -Prompt (($lang).DelOrOver -f $offline) Write-Host "" if (!($ch -eq 'n' -or $ch -eq 'y')) { incorrectValue } } while ($ch -notmatch '^y$|^n$') } if ($confirm_spoti_recomended_unistall) { $ch = 'y' } if ($confirm_spoti_recomended_over) { $ch = 'n' } if ($ch -eq 'y') { Write-Host ($lang).DelNew`n unlockFolder cmd /c $spotifyExecutable /UNINSTALL /SILENT wait-process -name SpotifyUninstall Start-Sleep -Milliseconds 200 if (Test-Path $spotifyDirectory) { Remove-Item -Recurse -Force -LiteralPath $spotifyDirectory } if (Test-Path $spotifyDirectory2) { Remove-Item -Recurse -Force -LiteralPath $spotifyDirectory2 } if (Test-Path $spotifyUninstall ) { Remove-Item -Recurse -Force -LiteralPath $spotifyUninstall } } if ($ch -eq 'n') { $ch = $null } } if ($ch -eq 'n') { Write-Host ($lang).StopScrpit $tempDirectory = $PWD Pop-Location Start-Sleep -Milliseconds 200 Remove-Item -Recurse -LiteralPath $tempDirectory Pause Exit } } } } # If there is no client or it is outdated, then install if (-not $spotifyInstalled -or $upgrade_client) { Write-Host ($lang).DownSpoti"" -NoNewline Write-Host $online -ForegroundColor Green Write-Host ($lang).DownSpoti2`n # Delete old version files of Spotify before installing, leave only profile files $ErrorActionPreference = 'SilentlyContinue' Stop-Process -Name Spotify Start-Sleep -Milliseconds 600 unlockFolder Start-Sleep -Milliseconds 200 Get-ChildItem $spotifyDirectory -Exclude 'Users', 'prefs', 'cache' | Remove-Item -Recurse -Force Start-Sleep -Milliseconds 200 # Client download downloadScripts -param1 "Desktop" Write-Host "" Start-Sleep -Milliseconds 200 # Client installation Start-Process -FilePath explorer.exe -ArgumentList $PWD\SpotifySetup.exe while (-not (get-process | Where-Object { $_.ProcessName -eq 'SpotifySetup' })) {} wait-process -name SpotifySetup wait-process -name SpotifySetup Stop-Process -Name Spotify } # Delete the leveldb folder (Fixes bug with incorrect experimental features for some accounts) $leveldb = (Test-Path -LiteralPath "$spotifyDirectory2\Browser\Local Storage\leveldb") if ($leveldb) { $ErrorActionPreference = 'SilentlyContinue' remove-item "$spotifyDirectory2\Browser\Local Storage\leveldb" -Recurse -Force } # Create backup chrome_elf.dll if (!(Test-Path -LiteralPath $chrome_elf_bak) -and !($premium)) { Move-Item $chrome_elf $chrome_elf_bak } $ch = $null if ($podcasts_off) { Write-Host ($lang).PodcatsOff`n $ch = 'y' } if ($podcasts_on) { Write-Host ($lang).PodcastsOn`n $ch = 'n' } if (!($podcasts_off) -and !($podcasts_on)) { do { $ch = Read-Host -Prompt ($lang).PodcatsSelect Write-Host "" if (!($ch -eq 'n' -or $ch -eq 'y')) { incorrectValue } } while ($ch -notmatch '^y$|^n$') } if ($ch -eq 'y') { $podcast_off = $true } $ch = $null if ($downgrading) { $upd = "`n" + [string]($lang).DowngradeNote } else { $upd = "" } if ($block_update_on) { Write-Host ($lang).UpdBlock`n $ch = 'y' } if ($block_update_off) { Write-Host ($lang).UpdUnblock`n $ch = 'n' } if (!($block_update_on) -and !($block_update_off)) { do { $text_upd = [string]($lang).UpdSelect + $upd $ch = Read-Host -Prompt $text_upd Write-Host "" if (!($ch -eq 'n' -or $ch -eq 'y')) { incorrectValue } } while ($ch -notmatch '^y$|^n$') } if ($ch -eq 'y') { $block_update = $true } if ($ch -eq 'n') { $ErrorActionPreference = 'SilentlyContinue' $exe_onl_fn = Check_verison_clients -param2 "offline" $exe_bak_fn = Check_verison_clients -param2 'Spotify.bak' if ((Test-Path -LiteralPath $exe_bak) -and $exe_onl_fn -eq $exe_bak_fn) { Remove-Item $spotifyExecutable -Recurse -Force Rename-Item $exe_bak $spotifyExecutable } } $ch = $null if ($cache_on) { Write-Host (($lang).CacheOn -f $number_days)`n $cache_install = $true } if ($cache_off) { Write-Host ($lang).CacheOff`n $ErrorActionPreference = 'SilentlyContinue' $desktop_folder = DesktopFolder if (Test-Path -LiteralPath $cache_folder) { remove-item $cache_folder -Recurse -Force remove-item $desktop_folder\Spotify.lnk -Recurse -Force } } if (!($cache_on) -and !($cache_off)) { do { $ch = Read-Host -Prompt ($lang).CacheSelect Write-Host "" if (!($ch -eq 'n' -or $ch -eq 'y')) { incorrectValue } } while ($ch -notmatch '^y$|^n$') if ($ch -eq 'y') { $cache_install = $true do { Write-Host ($lang).CacheDays $ch = Read-Host -Prompt ($lang).CacheDays2 Write-Host "" if (!($ch -match "^[1-9][0-9]?$|^100$")) { incorrectValue } } while ($ch -notmatch '^[1-9][0-9]?$|^100$') if ($ch -match "^[1-9][0-9]?$|^100$") { $number_days = $ch } } if ($ch -eq 'n') { $ErrorActionPreference = 'SilentlyContinue' $desktop_folder = DesktopFolder if (Test-Path -LiteralPath $cache_folder) { remove-item $cache_folder -Recurse -Force remove-item $desktop_folder\Spotify.lnk -Recurse -Force } } } function Helper($paramname) { switch ( $paramname ) { "HtmlLicMin" { # licenses.html minification $html_lic_min = @{ HtmlLicMin1 = '\r?\n(?!\(1|\d)', '' HtmlLicMin2 = '(?m)(^\s*\r?\n)', '' HtmlLicMin3 = ' ', '' HtmlLicMin4 = ' ', '' HtmlLicMin5 = '