diff --git a/Install.ps1 b/Install.ps1 index 397ba5e..c2e0d51 100644 --- a/Install.ps1 +++ b/Install.ps1 @@ -75,6 +75,9 @@ param [Parameter(HelpMessage = 'New theme activated (new right and left sidebar, some cover change)')] [switch]$new_theme, + [Parameter(HelpMessage = 'Returns old lyrics')] + [switch]$old_lyrics, + [Parameter(HelpMessage = 'Do not create desktop shortcut.')] [switch]$no_shortcut, @@ -450,7 +453,7 @@ function DesktopFolder { } # Recommended version for spotx -$onlineFull = "1.2.4.905.gaf3b1e64-104" +$onlineFull = "1.2.4.907.g126451d5-139" $online = ($onlineFull -split ".g")[0] # Check version Spotify offline @@ -852,8 +855,31 @@ if ($exp_standart) { Write-Host ($lang).ExpStandart`n } if ($exp_spotify) { Write-Host ($lang).ExpSpotify`n } $url = "https://raw.githubusercontent.com/amd64fox/SpotX/main/patches/patches.json" -$webjson = (Invoke-WebRequest -useb -Uri $url).Content | ConvertFrom-Json +$retries = 0 +while ($retries -lt 3) { + try { + $webjson = Invoke-WebRequest -UseBasicParsing -Uri $url | ConvertFrom-Json + break + } + catch { + Write-Warning "Request failed: $_" + $retries++ + Start-Sleep -Seconds 3 + } +} + +if ($retries -eq 3) { + + Write-Host "Failed to get patches.json" -ForegroundColor Red + Write-Host ($lang).StopScrpit + $tempDirectory = $PWD + Pop-Location + Start-Sleep -Milliseconds 200 + Remove-Item -Recurse -LiteralPath $tempDirectory + Pause + Exit +} function Helper($paramname) { switch ( $paramname ) { @@ -983,6 +1009,20 @@ function Helper($paramname) { $contents = $webjsonru.psobject.properties.name $json = $webjsonru } + "PodcastAd" { + # Aodcast ad block + $name = "patches.json.others." + $n = "Spotify.exe" + $contents = "podcast_ad_block" + $json = $webjson.others + } + "BlockUpdate" { + # Block Spotify client updates + $name = "patches.json.others." + $n = "Spotify.exe" + $contents = "block_update" + $json = $webjson.others + } "Collaborators" { # Hide Collaborators icon $name = "patches.json.others." @@ -1016,6 +1056,8 @@ function Helper($paramname) { } if (!($new_theme)) { $rem.remove('newhome'), $rem.remove('newhome2'), $rem.remove('leftsidebar'), $rem.remove('rightsidebar'), $rem.remove('lyricssidebar') } + if ($old_lyrics) { $rem.remove('lyricssidebar') } + $name = "patches.json.exp." $n = "xpui.js" $contents = $webjson.exp.psobject.properties.name @@ -1072,7 +1114,7 @@ function Helper($paramname) { $paramdata } -function extract ($counts, $method, $name, $helper, $add) { +function extract ($counts, $method, $name, $helper, $add, $patch) { switch ( $counts ) { "one" { if ($method -eq "zip") { @@ -1113,6 +1155,12 @@ function extract ($counts, $method, $name, $helper, $add) { } $zip.Dispose() } + "exe" { + $ANSI = [Text.Encoding]::GetEncoding(1251) + $xpui = [IO.File]::ReadAllText($spotifyExecutable, $ANSI) + $xpui = Helper -paramname $helper + [IO.File]::WriteAllText($spotifyExecutable, $xpui, $ANSI) + } } } @@ -1515,38 +1563,27 @@ If (!(Test-Path $start_menu)) { $Shortcut.Save() } -# Block updates -$ErrorActionPreference = 'SilentlyContinue' -$update_test_exe = Test-Path -Path $spotifyExecutable +$ANSI = [Text.Encoding]::GetEncoding(1251) +$old = [IO.File]::ReadAllText($spotifyExecutable, $ANSI) -if ($block_update) { +$rexex1 = $old -notmatch $webjson.others.block_update.add +$rexex2 = $old -notmatch $webjson.others.podcast_ad_block.add - if ($update_test_exe) { - $exe = "$env:APPDATA\Spotify\Spotify.exe" - $ANSI = [Text.Encoding]::GetEncoding(1251) - $old = [IO.File]::ReadAllText($exe, $ANSI) +if ($rexex1 -and $rexex2 ) { - if ($old -match "(?<=wg:\/\/desktop-update\/.)7(\/update)") { - Write-Host ($lang).UpdateBlocked`n - } - elseif ($old -match "(?<=wg:\/\/desktop-update\/.)2(\/update)") { - if (Test-Path -LiteralPath $exe_bak) { - Remove-Item $exe_bak -Recurse -Force - Start-Sleep -Milliseconds 150 - } - copy-Item $exe $exe_bak - $new = $old -replace "(?<=wg:\/\/desktop-update\/.)2(\/update)", '7/update' - [IO.File]::WriteAllText($exe, $new, $ANSI) - } - else { - Write-Host ($lang).UpdateError`n -ForegroundColor Red - } - } - else { - Write-Host ($lang).NoSpotifyExe`n -ForegroundColor Red + if (Test-Path -LiteralPath $exe_bak) { + Remove-Item $exe_bak -Recurse -Force + Start-Sleep -Milliseconds 150 } + copy-Item $spotifyExecutable $exe_bak } +# Podcast ad block +extract -counts 'exe' -helper 'PodcastAd' + +# Block updates +if ($block_update) { extract -counts 'exe' -helper 'BlockUpdate' } + # Automatic cache clearing if ($cache_install) { Start-Sleep -Milliseconds 200 diff --git a/patches/patches.json b/patches/patches.json index 9c3a76f..503dc7a 100644 --- a/patches/patches.json +++ b/patches/patches.json @@ -90,6 +90,24 @@ "match": "((..createElement|children:\\(.{1,7}\\))\\(....,{source:).....get\\(\"about.copyright\",.\\),paragraphClassName:.}\\)", "replace": "$1\"

More about SpotX

Github
FAQ
Telegram channel
Create an issue report

DISCLAIMER

SpotX is a modified version of the official Spotify client, provided as an evaluation version, you use it at your own risk.\"})" }, + "block_update": { + "version": { + "from": "1.1.58", + "do": "" + }, + "add": "(?<=wg:\/\/desktop-update\/.)7(\/update)", + "match": "(?<=wg:\/\/desktop-update\/.)2(\/update)", + "replace": "7/update" + }, + "podcast_ad_block": { + "version": { + "from": "1.1.68", + "do": "" + }, + "add": "(?<=refresh_inventory...)slott", + "match": "(?<=refresh_inventory...)slots", + "replace": "slott" + }, "podcastsoff": { "version": { "from": "1.1.70",