Skip to content

Commit

Permalink
ty Mega#5619 jyse#5128 Microwave at 3AM#7792 aLB3RT3X#3274 for help m…
Browse files Browse the repository at this point in the history
…e testing it
  • Loading branch information
mrpond committed Oct 2, 2021
2 parents 36f7b88 + ae7116a commit 3a3bf4b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ or
* Reinstall Spotify

### Known Issues:
* You may face issue [#150](https://github.com/mrpond/BlockTheSpot/issues/150).
* You may face issue [#150](https://github.com/mrpond/BlockTheSpot/issues/150). Can be fixed by enabling the experimental feature when using `BlockTheSpot.bat`.
* We support last 2 version of Spotify (latest + previous) only. Please check it before opening an issue.

### Additional Notes:
* Remove "Upgrade" Button [#83](https://github.com/mrpond/BlockTheSpot/issues/83) and Remove "Ad Placeholder" [#150](https://github.com/mrpond/BlockTheSpot/issues/150) only works when you use any of the auto installation methods and press `y` when prompted.
* "chrome_elf.dll" gets replaced by the Spotify installer each time it updates, hence why you'll probably need to apply the patch again when it happens
* [Spicetify](https://github.com/khanhas/spicetify-cli) users will need to reapply BlockTheSpot after applying a Spicetify patches.
* If the automatic install/uninstall scripts do not work, please contact [Nuzair46](https://github.com/Nuzair46)
Expand Down
34 changes: 34 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,40 @@ UI isn't changed.
}
#>

$ch = Read-Host -Prompt "Optional - Remove ad placeholder and upgrade button. (Experimental) (Y/N) "
if ($ch -eq 'y') {
Add-Type -Assembly 'System.IO.Compression.FileSystem'

Copy-Item -Path "$SpotifyApps\xpui.spa" -Destination "$SpotifyApps\xpui.spa.bak"

$zip = [System.IO.Compression.ZipFile]::Open("$SpotifyApps\xpui.spa", 'update')
$entry = $zip.GetEntry('xpui.js')

# Extract xpui.js from zip to memory
$reader = New-Object System.IO.StreamReader($entry.Open())
$xpuiContents = $reader.ReadToEnd()
$reader.Close()

# Replace ".ads.leaderboard.isEnabled" + separator - '}' or ')'
# With ".ads.leaderboard.isEnabled&&false" + separator
$xpuiContents = $xpuiContents -replace '(\.ads\.leaderboard\.isEnabled)(}|\))', '$1&&false$2'

# Delete ".createElement(XX,{onClick:X,className:XX.X.UpgradeButton}),X()"
$xpuiContents = $xpuiContents -replace '\.createElement\([^.,{]+,{onClick:[^.,]+,className:[^.]+\.[^.]+\.UpgradeButton}\),[^.(]+\(\)', ''

# Rewrite it to the zip
$writer = New-Object System.IO.StreamWriter($entry.Open())
$writer.BaseStream.SetLength(0)
$writer.Write($xpuiContents)
$writer.Close()

$zip.Dispose()
} else {
Write-Host @'
Won't remove ad placeholder and upgrade button.
'@`n
}

$tempDirectory = $PWD
Pop-Location

Expand Down

0 comments on commit 3a3bf4b

Please sign in to comment.