# Ignore errors from `Stop-Process` $PSDefaultParameterValues['Stop-Process:ErrorAction'] = [System.Management.Automation.ActionPreference]::SilentlyContinue Write-Host "*****************" Write-Host "Author: " -NoNewline Write-Host "@Amd64fox" -ForegroundColor DarkYellow Write-Host "*****************"`n $spotifyDirectory = "$env:APPDATA\Spotify" $spotifyExecutable = "$spotifyDirectory\Spotify.exe" $chrome_elf = "$spotifyDirectory\chrome_elf.dll" $chrome_elf_bak = "$spotifyDirectory\chrome_elf_bak.dll" $upgrade_client = $false $podcasts_off = $false $spotx_new = $false $run_as_admin = $false $block_update = $false $cache_install = $false # Check Tls12 $tsl_check = [Net.ServicePointManager]::SecurityProtocol if (!($tsl_check -match '^tls12$' )) { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 } # Checking startup rights [System.Security.Principal.WindowsPrincipal] $principal = [System.Security.Principal.WindowsIdentity]::GetCurrent() $isUserAdmin = $principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator) if ($isUserAdmin) { Write-Host 'Startup detected with administrator rights'`n $run_as_admin = $true } Stop-Process -Name Spotify Stop-Process -Name SpotifyWebHelper if ($PSVersionTable.PSVersion.Major -ge 7) { Import-Module Appx -UseWindowsPowerShell } # 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 'The Microsoft Store version of Spotify has been detected which is not supported.'`n $ch = Read-Host -Prompt "Uninstall Spotify Windows Store edition (Y/N) " if ($ch -eq 'y') { Write-Host 'Uninstalling Spotify.'`n Get-AppxPackage -Name SpotifyAB.SpotifyMusic | Remove-AppxPackage } else { Read-Host "Exiting...`nPress any key to exit..." exit } } } # Unique directory name based on time Push-Location -LiteralPath $env:TEMP New-Item -Type Directory -Name "BlockTheSpot-$(Get-Date -UFormat '%Y-%m-%d_%H-%M-%S')" | Convert-Path | Set-Location Write-Host 'Downloading latest patch BTS...'`n $webClient = New-Object -TypeName System.Net.WebClient try { $webClient.DownloadFile( # Remote file URL "https://github.com/mrpond/BlockTheSpot/releases/latest/download/chrome_elf.zip", # Local file path "$PWD\chrome_elf.zip" ) } catch [System.Management.Automation.MethodInvocationException] { Write-Host "Error downloading chrome_elf.zip" -ForegroundColor RED $Error[0].Exception Write-Host "" Write-Host "Will re-request in 5 seconds..."`n Start-Sleep -Milliseconds 5000 try { $webClient.DownloadFile( # Remote file URL "https://github.com/mrpond/BlockTheSpot/releases/latest/download/chrome_elf.zip", # Local file path "$PWD\chrome_elf.zip" ) } catch [System.Management.Automation.MethodInvocationException] { Write-Host "Error again, script stopped" -ForegroundColor RED $Error[0].Exception Write-Host "" Write-Host "Try to check your internet connection and run the installation again."`n $tempDirectory = $PWD Pop-Location Start-Sleep -Milliseconds 200 Remove-Item -Recurse -LiteralPath $tempDirectory exit } } Expand-Archive -Force -LiteralPath "$PWD\chrome_elf.zip" -DestinationPath $PWD Remove-Item -LiteralPath "$PWD\chrome_elf.zip" try { $webClient.DownloadFile( # Remote file URL 'https://download.scdn.co/SpotifySetup.exe', # Local file path "$PWD\SpotifySetup.exe" ) } catch [System.Management.Automation.MethodInvocationException] { Write-Host "Error downloading SpotifySetup.exe" -ForegroundColor RED $Error[0].Exception Write-Host "" Write-Host "Will re-request in 5 seconds..."`n Start-Sleep -Milliseconds 5000 try { $webClient.DownloadFile( # Remote file URL 'https://download.scdn.co/SpotifySetup.exe', # Local file path "$PWD\SpotifySetup.exe" ) } catch [System.Management.Automation.MethodInvocationException] { Write-Host "Error again, script stopped" -ForegroundColor RED $Error[0].Exception Write-Host "" Write-Host "Try to check your internet connection and run the installation again."`n $tempDirectory = $PWD Pop-Location Start-Sleep -Milliseconds 200 Remove-Item -Recurse -LiteralPath $tempDirectory exit } } $spotifyInstalled = (Test-Path -LiteralPath $spotifyExecutable) if ($spotifyInstalled) { # Check last version Spotify online $version_client_check = (get-item $PWD\SpotifySetup.exe).VersionInfo.ProductVersion $online_version = $version_client_check -split '.\w\w\w\w\w\w\w\w\w' # Check last version Spotify ofline $ofline_version = (Get-Item $spotifyExecutable).VersionInfo.FileVersion if ($online_version -gt $ofline_version) { do { $ch = Read-Host -Prompt "Your Spotify $ofline_version version is outdated, it is recommended to upgrade to $online_version `nWant to update ? (Y/N)" Write-Host "" if (!($ch -eq 'n' -or $ch -eq 'y')) { Write-Host "Oops, an incorrect value, " -ForegroundColor Red -NoNewline Write-Host "enter again through..." -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 } } while ($ch -notmatch '^y$|^n$') if ($ch -eq 'y') { $upgrade_client = $true } } } # If there is no client or it is outdated, then install if (-not $spotifyInstalled -or $upgrade_client) { $version_client_check = (get-item $PWD\SpotifySetup.exe).VersionInfo.ProductVersion $version_client = $version_client_check -split '.\w\w\w\w\w\w\w\w\w' Write-Host "Downloading and installing Spotify " -NoNewline Write-Host $version_client -ForegroundColor Green Write-Host "Please wait..."`n # Try deleting chrome_elf files if Spotify folder exists if (Test-Path -LiteralPath $spotifyDirectory) { $ErrorActionPreference = 'SilentlyContinue' # extinguishes light mistakes Stop-Process -Name Spotify Start-Sleep -Seconds 1 Remove-Item $spotifyDirectory -Include *chrome_elf* -Recurse -Force } # Correcting the error if the spotify installer was launched from the administrator if ($run_as_admin) { $apppath = 'powershell.exe' $taskname = 'Spotify install' $action = New-ScheduledTaskAction -Execute $apppath -Argument "-NoLogo -NoProfile -Command & `'$PWD\SpotifySetup.exe`'" $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -WakeToRun Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $taskname -Settings $settings -Force | Write-Verbose Start-ScheduledTask -TaskName $taskname Start-Sleep -Seconds 2 Unregister-ScheduledTask -TaskName $taskname -Confirm:$false Start-Sleep -Seconds 2 wait-process -name SpotifySetup } else { Start-Process -FilePath $PWD\SpotifySetup.exe; wait-process -name SpotifySetup } Stop-Process -Name Spotify Stop-Process -Name SpotifyWebHelper Stop-Process -Name SpotifyFullSetup $ErrorActionPreference = 'SilentlyContinue' # extinguishes light mistakes # Remove Spotify installer if (test-path "$env:LOCALAPPDATA\Microsoft\Windows\Temporary Internet Files\") { get-childitem -path "$env:LOCALAPPDATA\Microsoft\Windows\Temporary Internet Files\" -Recurse -Force -Filter "SpotifyFullSetup*" | remove-item -Force } if (test-path $env:LOCALAPPDATA\Microsoft\Windows\INetCache\) { get-childitem -path "$env:LOCALAPPDATA\Microsoft\Windows\INetCache\" -Recurse -Force -Filter "SpotifyFullSetup*" | remove-item -Force } } # Create backup chrome_elf.dll if (!(Test-Path -LiteralPath $chrome_elf_bak)) { Move-Item $chrome_elf $chrome_elf_bak } do { $ch = Read-Host -Prompt "Want to turn off podcasts ? (Y/N)" Write-Host "" if (!($ch -eq 'n' -or $ch -eq 'y')) { Write-Host "Oops, an incorrect value, " -ForegroundColor Red -NoNewline Write-Host "enter again through..." -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 } } while ($ch -notmatch '^y$|^n$') if ($ch -eq 'y') { $podcasts_off = $true } do { $ch = Read-Host -Prompt "Want to block updates ? (Y/N)" Write-Host "" if (!($ch -eq 'n' -or $ch -eq 'y')) { Write-Host "Oops, an incorrect value, " -ForegroundColor Red -NoNewline Write-Host "enter again through..." -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 } } while ($ch -notmatch '^y$|^n$') if ($ch -eq 'y') { $block_update = $true } do { $ch = Read-Host -Prompt "Want to set up automatic cache cleanup? (Y/N)" Write-Host "" if (!($ch -eq 'n' -or $ch -eq 'y')) { Write-Host "Oops, an incorrect value, " -ForegroundColor Red -NoNewline Write-Host "enter again through..." -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 } } while ($ch -notmatch '^y$|^n$') if ($ch -eq 'y') { $cache_install = $true do { $ch = Read-Host -Prompt "Cache files that have not been used for more than XX days will be deleted. Enter the number of days from 1 to 100" Write-Host "" if (!($ch -match "^[1-9][0-9]?$|^100$")) { Write-Host "Oops, an incorrect value, " -ForegroundColor Red -NoNewline Write-Host "enter again through..." -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 } } while ($ch -notmatch '^[1-9][0-9]?$|^100$') if ($ch -match "^[1-9][0-9]?$|^100$") { $number_days = $ch } } function OffUpdStatus { # Remove the label about the new version $upgrade_status = "sp://desktop/v1/upgrade/status" if ($xpui_js -match $upgrade_status) { $xpui_js = $xpui_js -replace $upgrade_status, "" } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$upgrade_status in xpui.js" } $xpui_js } function OffPodcasts { # Turn off podcasts $podcasts_off1 = '"album,playlist,artist,show,station,episode"', '"album,playlist,artist,station"' $podcasts_off2 = ',this[.]enableShows=[a-z]' if ($xpui_js -match $podcasts_off1[0]) { $xpui_js = $xpui_js -replace $podcasts_off1[0], $podcasts_off1[1] } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$podcasts_off1[0] in xpui.js" } if ($xpui_js -match $podcasts_off2) { $xpui_js = $xpui_js -replace $podcasts_off2, "" } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$podcasts_off2 in xpui.js" } $xpui_js } function OffAdsOnFullscreen { # Removing an empty block $empty_block_ad = 'adsEnabled:!0', 'adsEnabled:!1' # Full screen mode activation and removing "Upgrade to premium" menu, upgrade button $full_screen_1 = '(session[,]{1}[a-z]{1}[=]{1}[a-z]{1}[=]{1}[>]{1}[{]{1}var [a-z]{1}[,]{1}[a-z]{1}[,]{1}[a-z]{1}[;]{1}[a-z]{6})(["]{1}free["]{1})', '$1"premium"' $full_screen_2 = '([a-z]{1}[.]{1}toLowerCase[(]{1}[)]{2}[}]{1}[,]{1}[a-z]{1}[=]{1}[a-z]{1}[=]{1}[>]{1}[{]{1}var [a-z]{1}[,]{1}[a-z]{1}[,]{1}[a-z]{1}[;]{1}return)(["]{1}premium["]{1})', '$1"free"' # Disabling a playlist sponsor $playlist_ad_off = "allSponsorships" if ($xpui_js -match $empty_block_ad[0]) { $xpui_js = $xpui_js -replace $empty_block_ad[0], $empty_block_ad[1] } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$empty_block_ad[0] in xpui.js" } if ($xpui_js -match $full_screen_1[0]) { $xpui_js = $xpui_js -replace $full_screen_1[0], $full_screen_1[1] } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$full_screen_1[0] in xpui.js" } if ($xpui_js -match $full_screen_2[0]) { $xpui_js = $xpui_js -replace $full_screen_2[0], $full_screen_2[1] } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$full_screen_2[0] in xpui.js" } if ($xpui_js -match $playlist_ad_off) { $xpui_js = $xpui_js -replace $playlist_ad_off, "" } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$playlist_ad_off in xpui.js" } $xpui_js } function ExpFeature { # Experimental Feature $exp_features1 = '(Show "Made For You" entry point in the left sidebar.,default:)(!1)', '$1!0' $exp_features2 = '(Enables the 2021 icons redraw which loads a different font asset for rendering icon glyphs.",default:)(!1)', '$1!0' $exp_features3 = '(Enable Liked Songs section on Artist page",default:)(!1)', '$1!0' $exp_features4 = '(Enable block users feature in clientX",default:)(!1)', '$1!0' $exp_features5 = '(Enables quicksilver in-app messaging modal",default:)(!0)', '$1!1' $exp_features6 = '(With this enabled, clients will check whether tracks have lyrics available",default:)(!1)', '$1!0' $exp_features7 = '(Enables new playlist creation flow in Web Player and DesktopX",default:)(!1)', '$1!0' $exp_features8 = '(Enable Enhance Playlist UI and functionality",default:)(!1)', '$1!0' if ($xpui_js -match $exp_features1[0]) { $xpui_js = $xpui_js -replace $exp_features1[0], $exp_features1[1] } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$exp_features1[0] in xpui.js" } if ($xpui_js -match $exp_features2[0]) { $xpui_js = $xpui_js -replace $exp_features2[0], $exp_features2[1] } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$exp_features2[0] in xpui.js" } if ($xpui_js -match $exp_features3[0]) { $xpui_js = $xpui_js -replace $exp_features3[0], $exp_features3[1] } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$exp_features3[0] in xpui.js" } if ($xpui_js -match $exp_features4[0]) { $xpui_js = $xpui_js -replace $exp_features4[0], $exp_features4[1] } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$exp_features4[0] in xpui.js" } if ($xpui_js -match $exp_features5[0]) { $xpui_js = $xpui_js -replace $exp_features5[0], $exp_features5[1] } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$exp_features5[0] in xpui.js" } if ($xpui_js -match $exp_features6[0]) { $xpui_js = $xpui_js -replace $exp_features6[0], $exp_features6[1] } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$exp_features6[0] in xpui.js" } if ($xpui_js -match $exp_features7[0]) { $xpui_js = $xpui_js -replace $exp_features7[0], $exp_features7[1] } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$exp_features7[0] in xpui.js" } if ($xpui_js -match $exp_features8[0]) { $xpui_js = $xpui_js -replace $exp_features8[0], $exp_features8[1] } else { Write-Host "Didn't find variable " -ForegroundColor red -NoNewline; Write-Host "`$exp_features8[0] in xpui.js" } $xpui_js } function ContentsHtml { # licenses.html minification $html_lic_min1 = '