forked from revinewyd/SpotifyPremium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.ps1
221 lines (197 loc) · 5.82 KB
/
install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# Ignore errors from `Stop-Process`
$PSDefaultParameterValues['Stop-Process:ErrorAction'] = 'SilentlyContinue'
write-host @'
*****************
@revinewyd message:
Follow my socials!
https://myurls.co/revinewyd
*****************
'@
write-host @'
*****************
Author: @revinewyd
*****************
'@
$SpotifyDirectory = "$env:APPDATA\Spotify"
$SpotifyExecutable = "$SpotifyDirectory\Spotify.exe"
$SpotifyApps = "$SpotifyDirectory\Apps"
Write-Host 'Stopping Spotify...'`n
Stop-Process -Name Spotify
Stop-Process -Name SpotifyWebHelper
if ($PSVersionTable.PSVersion.Major -ge 7)
{
Import-Module Appx -UseWindowsPowerShell
}
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{
Write-Host @'
Exiting...
'@`n
Pause
exit
}
}
Push-Location -LiteralPath $env:TEMP
try {
# Unique directory name based on time
New-Item -Type Directory -Name "BlockTheSpot-$(Get-Date -UFormat '%Y-%m-%d_%H-%M-%S')" `
| Convert-Path `
| Set-Location
} catch {
Write-Output $_
Pause
exit
}
Write-Host 'Downloading latest patch (chrome_elf.zip)...'`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 {
Write-Output $_
Sleep
}
<#
try {
$webClient.DownloadFile(
# Remote file URL
'https://github.com/mrpond/BlockTheSpot/files/5969916/zlink.zip',
# Local file path
"$PWD\zlink.zip"
)
} catch {
Write-Output $_
Sleep
}
try {
$webClient.DownloadFile(
# Remote file URL
'https://github.com/mrpond/BlockTheSpot/files/6234124/xpui.zip',
# Local file path
"$PWD\xpui.zip"
)
} catch {
Write-Output $_
Sleep
}
#>
Expand-Archive -Force -LiteralPath "$PWD\chrome_elf.zip" -DestinationPath $PWD
Remove-Item -LiteralPath "$PWD\chrome_elf.zip"
<#
Expand-Archive -Force -LiteralPath "$PWD\zlink.zip" -DestinationPath $PWD
Remove-Item -LiteralPath "$PWD\zlink.zip"
Expand-Archive -Force -LiteralPath "$PWD\xpui.zip" -DestinationPath $PWD
Remove-Item -LiteralPath "$PWD\xpui.zip"
#>
$spotifyInstalled = (Test-Path -LiteralPath $SpotifyExecutable)
if (-not $spotifyInstalled) {
Write-Host @'
Spotify installation was not detected.
Downloading Latest Spotify full setup, please wait...
'@
try {
$webClient.DownloadFile(
# Remote file URL
'https://download.scdn.co/SpotifyFullSetup.exe',
# Local file path
"$PWD\SpotifyFullSetup.exe"
)
} catch {
Write-Output $_
Pause
exit
}
mkdir $SpotifyDirectory >$null 2>&1
Write-Host 'Running installation...'
Start-Process -FilePath "$PWD\SpotifyFullSetup.exe"
Write-Host 'Stopping Spotify...Again'
while ((Get-Process -name Spotify -ErrorAction SilentlyContinue) -eq $null){
#waiting until installation complete
}
Stop-Process -Name Spotify >$null 2>&1
Stop-Process -Name SpotifyWebHelper >$null 2>&1
Stop-Process -Name SpotifyFullSetup >$null 2>&1
}
if (!(test-path $SpotifyDirectory/chrome_elf.dll.bak)){
move $SpotifyDirectory\chrome_elf.dll $SpotifyDirectory\chrome_elf.dll.bak >$null 2>&1
}
Write-Host 'Patching Spotify...'
$patchFiles = "$PWD\chrome_elf.dll", "$PWD\config.ini"
<#
$remup = "$PWD\zlink.spa"
$uipat = "$PWD\xpui.spa"
#>
Copy-Item -LiteralPath $patchFiles -Destination "$SpotifyDirectory"
<#
$ch = Read-Host -Prompt "Optional - Remove Upgrade Button. (Y/N) "
if ($ch -eq 'y'){
move $SpotifyApps\zlink.spa $SpotifyApps\zlink.spa.bak >$null 2>&1
Copy-Item -LiteralPath $remup -Destination "$SpotifyApps"
} else{
Write-Host @'
Won't remove Upgrade Button.
'@`n
}
$ch = Read-Host -Prompt "Change Alpha UI back to Old UI. (BTS only supports Old UI). (Y/N) "
if ($ch -eq 'y'){
move $SpotifyApps\xpui.spa $SpotifyApps\xpui.spa.bak >$null 2>&1
Copy-Item -LiteralPath $uipat -Destination "$SpotifyApps"
} else{
Write-Host @'
UI isn't changed.
'@`n
}
#>
$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
Remove-Item -Recurse -LiteralPath $tempDirectory
Write-Host 'Patching Complete, starting Spotify...'
Start-Process -WorkingDirectory $SpotifyDirectory -FilePath $SpotifyExecutable
Write-Host 'Done.'
write-host @'
*****************
@revinewyd message:
Follow my socials!
https://myurls.co/revinewyd
*****************
'@
exit