mirror of
https://github.com/SpotX-Official/SpotX.git
synced 2026-06-20 22:21:09 +10:00
typo
This commit is contained in:
+130
-9
@@ -1,18 +1,26 @@
|
|||||||
# Ignore errors from `Stop-Process`
|
# Ignore errors from `Stop-Process`
|
||||||
$PSDefaultParameterValues['Stop-Process:ErrorAction'] = 'SilentlyContinue'
|
$PSDefaultParameterValues['Stop-Process:ErrorAction'] = 'SilentlyContinue'
|
||||||
|
|
||||||
# Check Tls12
|
# Check Tls12
|
||||||
$tsl_check = [Net.ServicePointManager]::SecurityProtocol
|
$tsl_check = [Net.ServicePointManager]::SecurityProtocol
|
||||||
if (!($tsl_check -match '^tls12$' )) {
|
if (!($tsl_check -match '^tls12$' )) {
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Write-Host "*****************"
|
Write-Host "*****************"
|
||||||
Write-Host "Author: " -NoNewline
|
Write-Host "Author: " -NoNewline
|
||||||
Write-Host "@Amd64fox" -ForegroundColor DarkYellow
|
Write-Host "@Amd64fox" -ForegroundColor DarkYellow
|
||||||
Write-Host "*****************"
|
Write-Host "*****************"
|
||||||
|
|
||||||
|
|
||||||
$SpotifyDirectory = "$env:APPDATA\Spotify"
|
$SpotifyDirectory = "$env:APPDATA\Spotify"
|
||||||
$SpotifyExecutable = "$SpotifyDirectory\Spotify.exe"
|
$SpotifyExecutable = "$SpotifyDirectory\Spotify.exe"
|
||||||
|
|
||||||
|
|
||||||
Stop-Process -Name Spotify
|
Stop-Process -Name Spotify
|
||||||
Stop-Process -Name SpotifyWebHelper
|
Stop-Process -Name SpotifyWebHelper
|
||||||
|
|
||||||
if ($PSVersionTable.PSVersion.Major -ge 7) {
|
if ($PSVersionTable.PSVersion.Major -ge 7) {
|
||||||
Import-Module Appx -UseWindowsPowerShell
|
Import-Module Appx -UseWindowsPowerShell
|
||||||
}
|
}
|
||||||
@@ -22,7 +30,11 @@ $win11 = $win_os -match "\windows 11\b"
|
|||||||
$win10 = $win_os -match "\windows 10\b"
|
$win10 = $win_os -match "\windows 10\b"
|
||||||
$win8_1 = $win_os -match "\windows 8.1\b"
|
$win8_1 = $win_os -match "\windows 8.1\b"
|
||||||
$win8 = $win_os -match "\windows 8\b"
|
$win8 = $win_os -match "\windows 8\b"
|
||||||
|
|
||||||
|
|
||||||
if ($win11 -or $win10 -or $win8_1 -or $win8) {
|
if ($win11 -or $win10 -or $win8_1 -or $win8) {
|
||||||
|
|
||||||
|
|
||||||
# Check and del Windows Store
|
# Check and del Windows Store
|
||||||
if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic) {
|
if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic) {
|
||||||
Write-Host @'
|
Write-Host @'
|
||||||
@@ -44,6 +56,8 @@ Exiting...
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Push-Location -LiteralPath $env:TEMP
|
Push-Location -LiteralPath $env:TEMP
|
||||||
try {
|
try {
|
||||||
# Unique directory name based on time
|
# Unique directory name based on time
|
||||||
@@ -56,9 +70,13 @@ catch {
|
|||||||
Pause
|
Pause
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Write-Host 'Downloading latest patch BTS...'`n
|
Write-Host 'Downloading latest patch BTS...'`n
|
||||||
|
|
||||||
$webClient = New-Object -TypeName System.Net.WebClient
|
$webClient = New-Object -TypeName System.Net.WebClient
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$webClient.DownloadFile(
|
$webClient.DownloadFile(
|
||||||
# Remote file URL
|
# Remote file URL
|
||||||
'https://github.com/mrpond/BlockTheSpot/releases/latest/download/chrome_elf.zip',
|
'https://github.com/mrpond/BlockTheSpot/releases/latest/download/chrome_elf.zip',
|
||||||
@@ -70,8 +88,10 @@ catch {
|
|||||||
Write-Output ''
|
Write-Output ''
|
||||||
Start-Sleep
|
Start-Sleep
|
||||||
}
|
}
|
||||||
|
|
||||||
Expand-Archive -Force -LiteralPath "$PWD\chrome_elf.zip" -DestinationPath $PWD
|
Expand-Archive -Force -LiteralPath "$PWD\chrome_elf.zip" -DestinationPath $PWD
|
||||||
Remove-Item -LiteralPath "$PWD\chrome_elf.zip"
|
Remove-Item -LiteralPath "$PWD\chrome_elf.zip"
|
||||||
|
|
||||||
$spotifyInstalled = (Test-Path -LiteralPath $SpotifyExecutable)
|
$spotifyInstalled = (Test-Path -LiteralPath $SpotifyExecutable)
|
||||||
if (-not $spotifyInstalled) {
|
if (-not $spotifyInstalled) {
|
||||||
|
|
||||||
@@ -89,6 +109,7 @@ if (-not $spotifyInstalled) {
|
|||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
mkdir $SpotifyDirectory >$null 2>&1
|
mkdir $SpotifyDirectory >$null 2>&1
|
||||||
|
|
||||||
# Check version Spotify
|
# Check version Spotify
|
||||||
$version_client_check = (get-item $PWD\SpotifySetup.exe).VersionInfo.ProductVersion
|
$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'
|
$version_client = $version_client_check -split '.\w\w\w\w\w\w\w\w\w'
|
||||||
@@ -96,13 +117,18 @@ if (-not $spotifyInstalled) {
|
|||||||
Write-Host "Downloading and installing Spotify " -NoNewline
|
Write-Host "Downloading and installing Spotify " -NoNewline
|
||||||
Write-Host $version_client -ForegroundColor Green
|
Write-Host $version_client -ForegroundColor Green
|
||||||
Write-Host "Please wait..."
|
Write-Host "Please wait..."
|
||||||
|
|
||||||
Start-Process -FilePath $PWD\SpotifySetup.exe; wait-process -name SpotifySetup
|
Start-Process -FilePath $PWD\SpotifySetup.exe; wait-process -name SpotifySetup
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Stop-Process -Name Spotify >$null 2>&1
|
Stop-Process -Name Spotify >$null 2>&1
|
||||||
Stop-Process -Name SpotifyWebHelper >$null 2>&1
|
Stop-Process -Name SpotifyWebHelper >$null 2>&1
|
||||||
Stop-Process -Name SpotifyFullSetup >$null 2>&1
|
Stop-Process -Name SpotifyFullSetup >$null 2>&1
|
||||||
|
|
||||||
|
|
||||||
$ErrorActionPreference = 'SilentlyContinue' # Команда гасит легкие ошибки
|
$ErrorActionPreference = 'SilentlyContinue' # Команда гасит легкие ошибки
|
||||||
|
|
||||||
# Удалить инсталятор после установки
|
# Удалить инсталятор после установки
|
||||||
if (test-path "$env:LOCALAPPDATA\Microsoft\Windows\Temporary Internet Files\") {
|
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
|
get-childitem -path "$env:LOCALAPPDATA\Microsoft\Windows\Temporary Internet Files\" -Recurse -Force -Filter "SpotifyFullSetup*" | remove-item -Force
|
||||||
@@ -113,37 +139,54 @@ if (-not $spotifyInstalled) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(test-path $SpotifyDirectory/chrome_elf.dll.bak)) {
|
if (!(test-path $SpotifyDirectory/chrome_elf.dll.bak)) {
|
||||||
Move-Item $SpotifyDirectory\chrome_elf.dll $SpotifyDirectory\chrome_elf.dll.bak >$null 2>&1
|
Move-Item $SpotifyDirectory\chrome_elf.dll $SpotifyDirectory\chrome_elf.dll.bak >$null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host 'Patching Spotify...'
|
Write-Host 'Patching Spotify...'
|
||||||
$patchFiles = "$PWD\chrome_elf.dll", "$PWD\config.ini"
|
$patchFiles = "$PWD\chrome_elf.dll", "$PWD\config.ini"
|
||||||
Copy-Item -LiteralPath $patchFiles -Destination "$SpotifyDirectory"
|
Copy-Item -LiteralPath $patchFiles -Destination "$SpotifyDirectory"
|
||||||
|
|
||||||
$tempDirectory = $PWD
|
$tempDirectory = $PWD
|
||||||
Pop-Location
|
Pop-Location
|
||||||
|
|
||||||
|
|
||||||
Start-Sleep -Milliseconds 200
|
Start-Sleep -Milliseconds 200
|
||||||
Remove-Item -Recurse -LiteralPath $tempDirectory
|
Remove-Item -Recurse -LiteralPath $tempDirectory
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Removing an empty block, "Upgrade button", "Upgrade to premium" menu
|
# Removing an empty block, "Upgrade button", "Upgrade to premium" menu
|
||||||
|
|
||||||
$zipFilePath = "$env:APPDATA\Spotify\Apps\xpui.zip"
|
$zipFilePath = "$env:APPDATA\Spotify\Apps\xpui.zip"
|
||||||
$extractPath = "$env:APPDATA\Spotify\Apps\temporary"
|
$extractPath = "$env:APPDATA\Spotify\Apps\temporary"
|
||||||
|
|
||||||
Rename-Item -path $env:APPDATA\Spotify\Apps\xpui.spa -NewName $env:APPDATA\Spotify\Apps\xpui.zip
|
Rename-Item -path $env:APPDATA\Spotify\Apps\xpui.spa -NewName $env:APPDATA\Spotify\Apps\xpui.zip
|
||||||
|
|
||||||
if (Test-Path $env:APPDATA\Spotify\Apps\temporary) {
|
if (Test-Path $env:APPDATA\Spotify\Apps\temporary) {
|
||||||
Remove-item $env:APPDATA\Spotify\Apps\temporary -Recurse
|
Remove-item $env:APPDATA\Spotify\Apps\temporary -Recurse
|
||||||
}
|
}
|
||||||
New-Item -Path $env:APPDATA\Spotify\Apps\temporary -ItemType Directory | Out-Null
|
New-Item -Path $env:APPDATA\Spotify\Apps\temporary -ItemType Directory | Out-Null
|
||||||
|
|
||||||
# Достаем из архива xpui.zip файл xpui.js
|
# Достаем из архива xpui.zip файл xpui.js
|
||||||
Add-Type -Assembly 'System.IO.Compression.FileSystem'
|
Add-Type -Assembly 'System.IO.Compression.FileSystem'
|
||||||
$zip = [System.IO.Compression.ZipFile]::Open($zipFilePath, 'read')
|
$zip = [System.IO.Compression.ZipFile]::Open($zipFilePath, 'read')
|
||||||
$zip.Entries | Where-Object Name -eq xpui.js | ForEach-Object { [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, "$extractPath\$($_.Name)", $true) }
|
$zip.Entries | Where-Object Name -eq xpui.js | ForEach-Object { [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, "$extractPath\$($_.Name)", $true) }
|
||||||
$zip.Dispose()
|
$zip.Dispose()
|
||||||
|
|
||||||
# Делает резервную копию xpui.spa
|
# Делает резервную копию xpui.spa
|
||||||
|
|
||||||
$file_js = Get-Content $env:APPDATA\Spotify\Apps\temporary\xpui.js -Raw
|
$file_js = Get-Content $env:APPDATA\Spotify\Apps\temporary\xpui.js -Raw
|
||||||
|
|
||||||
If (!($file_js -match 'patched by spotx')) {
|
If (!($file_js -match 'patched by spotx')) {
|
||||||
Copy-Item $env:APPDATA\Spotify\Apps\xpui.zip $env:APPDATA\Spotify\Apps\xpui.bak
|
Copy-Item $env:APPDATA\Spotify\Apps\xpui.zip $env:APPDATA\Spotify\Apps\xpui.bak
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Мофифицируем и кладем обратно в архив файл xpui.js
|
# Мофифицируем и кладем обратно в архив файл xpui.js
|
||||||
|
|
||||||
If (!($file_js -match 'patched by spotx')) {
|
If (!($file_js -match 'patched by spotx')) {
|
||||||
$file_js -match 'visible:!e}[)]{1}[,]{1}[A-Za-z]{1}[(]{1}[)]{1}.createElement[(]{1}[A-Za-z]{2}[,]{1}null[)]{1}[,]{1}[A-Za-z]{1}[(]{1}[)]{1}.' | Out-Null
|
$file_js -match 'visible:!e}[)]{1}[,]{1}[A-Za-z]{1}[(]{1}[)]{1}.createElement[(]{1}[A-Za-z]{2}[,]{1}null[)]{1}[,]{1}[A-Za-z]{1}[(]{1}[)]{1}.' | Out-Null
|
||||||
$menu_split_js = $Matches[0] -split 'createElement[(]{1}[A-Za-z]{2}[,]{1}null[)]{1}[,]{1}[A-Za-z]{1}[(]{1}[)]{1}.'
|
$menu_split_js = $Matches[0] -split 'createElement[(]{1}[A-Za-z]{2}[,]{1}null[)]{1}[,]{1}[A-Za-z]{1}[(]{1}[)]{1}.'
|
||||||
@@ -158,6 +201,8 @@ If (!($file_js -match 'patched by spotx')) {
|
|||||||
else {
|
else {
|
||||||
"Xpui.js is already patched"
|
"Xpui.js is already patched"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
<#
|
<#
|
||||||
# Удаление меню через css (РЕЗЕРВНЫЙ)
|
# Удаление меню через css (РЕЗЕРВНЫЙ)
|
||||||
$file_css = Get-Content $env:APPDATA\Spotify\Apps\temporary\xpui.css -Raw
|
$file_css = Get-Content $env:APPDATA\Spotify\Apps\temporary\xpui.css -Raw
|
||||||
@@ -171,14 +216,21 @@ If (!($file_css -match 'patched by spotx')) {
|
|||||||
Compress-Archive -Path $env:APPDATA\Spotify\Apps\temporary\xpui.css -Update -DestinationPath $env:APPDATA\Spotify\Apps\xpui.zip
|
Compress-Archive -Path $env:APPDATA\Spotify\Apps\temporary\xpui.css -Update -DestinationPath $env:APPDATA\Spotify\Apps\xpui.zip
|
||||||
}
|
}
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
|
||||||
Rename-Item -path $env:APPDATA\Spotify\Apps\xpui.zip -NewName $env:APPDATA\Spotify\Apps\xpui.spa
|
Rename-Item -path $env:APPDATA\Spotify\Apps\xpui.zip -NewName $env:APPDATA\Spotify\Apps\xpui.spa
|
||||||
Remove-item $env:APPDATA\Spotify\Apps\temporary -Recurse
|
Remove-item $env:APPDATA\Spotify\Apps\temporary -Recurse
|
||||||
|
|
||||||
|
|
||||||
# Если папки по умолчанию Dekstop не существует, то попытаться найти её через реестр.
|
# Если папки по умолчанию Dekstop не существует, то попытаться найти её через реестр.
|
||||||
$ErrorActionPreference = 'SilentlyContinue'
|
$ErrorActionPreference = 'SilentlyContinue'
|
||||||
|
|
||||||
if (Test-Path "$env:USERPROFILE\Desktop") {
|
if (Test-Path "$env:USERPROFILE\Desktop") {
|
||||||
|
|
||||||
$desktop_folder = "$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_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}'
|
$regedit_desktop = $regedit_desktop_folder.'{754AC886-DF64-4CBA-86B5-F7FBF4FBCEF5}'
|
||||||
|
|
||||||
@@ -186,8 +238,12 @@ if (!(Test-Path "$env:USERPROFILE\Desktop")) {
|
|||||||
$desktop_folder = $regedit_desktop
|
$desktop_folder = $regedit_desktop
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Shortcut bug
|
# Shortcut bug
|
||||||
$ErrorActionPreference = 'SilentlyContinue'
|
$ErrorActionPreference = 'SilentlyContinue'
|
||||||
|
|
||||||
If (!(Test-Path $env:USERPROFILE\Desktop\Spotify.lnk)) {
|
If (!(Test-Path $env:USERPROFILE\Desktop\Spotify.lnk)) {
|
||||||
|
|
||||||
$source = "$env:APPDATA\Spotify\Spotify.exe"
|
$source = "$env:APPDATA\Spotify\Spotify.exe"
|
||||||
@@ -199,14 +255,23 @@ If (!(Test-Path $env:USERPROFILE\Desktop\Spotify.lnk)) {
|
|||||||
$Shortcut.TargetPath = $source
|
$Shortcut.TargetPath = $source
|
||||||
$Shortcut.Save()
|
$Shortcut.Save()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Block updates
|
# Block updates
|
||||||
|
|
||||||
$ErrorActionPreference = 'SilentlyContinue' # Команда гасит легкие ошибки
|
$ErrorActionPreference = 'SilentlyContinue' # Команда гасит легкие ошибки
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$update_directory = Test-Path -Path $env:LOCALAPPDATA\Spotify
|
$update_directory = Test-Path -Path $env:LOCALAPPDATA\Spotify
|
||||||
$update_directory_file = Test-Path -Path $env:LOCALAPPDATA\Spotify\Update
|
$update_directory_file = Test-Path -Path $env:LOCALAPPDATA\Spotify\Update
|
||||||
$migrator_bak = Test-Path -Path $env:APPDATA\Spotify\SpotifyMigrator.bak
|
$migrator_bak = Test-Path -Path $env:APPDATA\Spotify\SpotifyMigrator.bak
|
||||||
$migrator_exe = Test-Path -Path $env:APPDATA\Spotify\SpotifyMigrator.exe
|
$migrator_exe = Test-Path -Path $env:APPDATA\Spotify\SpotifyMigrator.exe
|
||||||
$Check_folder_file = Get-ItemProperty -Path $env:LOCALAPPDATA\Spotify\Update | Select-Object Attributes
|
$Check_folder_file = Get-ItemProperty -Path $env:LOCALAPPDATA\Spotify\Update | Select-Object Attributes
|
||||||
$folder_update_access = Get-Acl $env:LOCALAPPDATA\Spotify\Update
|
$folder_update_access = Get-Acl $env:LOCALAPPDATA\Spotify\Update
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$ch = Read-Host -Prompt "Want to block updates ? (Y/N), Unlock updates (U)"
|
$ch = Read-Host -Prompt "Want to block updates ? (Y/N), Unlock updates (U)"
|
||||||
if (!($ch -eq 'n' -or $ch -eq 'y' -or $ch -eq 'u')) {
|
if (!($ch -eq 'n' -or $ch -eq 'y' -or $ch -eq 'u')) {
|
||||||
@@ -224,11 +289,16 @@ do {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ($ch -notmatch '^y$|^n$|^u$')
|
while ($ch -notmatch '^y$|^n$|^u$')
|
||||||
|
|
||||||
|
|
||||||
if ($ch -eq 'y') {
|
if ($ch -eq 'y') {
|
||||||
|
|
||||||
# Если была установка клиента
|
# Если была установка клиента
|
||||||
if (!($update_directory)) {
|
if (!($update_directory)) {
|
||||||
|
|
||||||
# Создать папку Spotify в Local
|
# Создать папку Spotify в Local
|
||||||
New-Item -Path $env:LOCALAPPDATA -Name "Spotify" -ItemType "directory" | Out-Null
|
New-Item -Path $env:LOCALAPPDATA -Name "Spotify" -ItemType "directory" | Out-Null
|
||||||
|
|
||||||
#Создать файл Update
|
#Создать файл Update
|
||||||
New-Item -Path $env:LOCALAPPDATA\Spotify\ -Name "Update" -ItemType "file" -Value "STOPIT" | Out-Null
|
New-Item -Path $env:LOCALAPPDATA\Spotify\ -Name "Update" -ItemType "file" -Value "STOPIT" | Out-Null
|
||||||
$file = Get-ItemProperty -Path $env:LOCALAPPDATA\Spotify\Update
|
$file = Get-ItemProperty -Path $env:LOCALAPPDATA\Spotify\Update
|
||||||
@@ -239,17 +309,25 @@ if ($ch -eq 'y') {
|
|||||||
Remove-item $env:APPDATA\Spotify\SpotifyMigrator.bak -Recurse -Force
|
Remove-item $env:APPDATA\Spotify\SpotifyMigrator.bak -Recurse -Force
|
||||||
Rename-Item -path $env:APPDATA\Spotify\SpotifyMigrator.exe -NewName $env:APPDATA\Spotify\SpotifyMigrator.bak
|
Rename-Item -path $env:APPDATA\Spotify\SpotifyMigrator.exe -NewName $env:APPDATA\Spotify\SpotifyMigrator.bak
|
||||||
}
|
}
|
||||||
|
|
||||||
# Если есть только мигратор .exe то переименовать его в .bak
|
# Если есть только мигратор .exe то переименовать его в .bak
|
||||||
if ($migrator_exe) {
|
if ($migrator_exe) {
|
||||||
Rename-Item -path $env:APPDATA\Spotify\SpotifyMigrator.exe -NewName $env:APPDATA\Spotify\SpotifyMigrator.bak
|
Rename-Item -path $env:APPDATA\Spotify\SpotifyMigrator.exe -NewName $env:APPDATA\Spotify\SpotifyMigrator.bak
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Если клиент уже был
|
# Если клиент уже был
|
||||||
If ($update_directory) {
|
If ($update_directory) {
|
||||||
|
|
||||||
|
|
||||||
#Удалить папку Update если она есть
|
#Удалить папку Update если она есть
|
||||||
if ($Check_folder_file -match '\bDirectory\b') {
|
if ($Check_folder_file -match '\bDirectory\b') {
|
||||||
|
|
||||||
#Если у папки Update заблокированы права то разблокировать
|
#Если у папки Update заблокированы права то разблокировать
|
||||||
if ($folder_update_access.AccessToString -match 'Deny') {
|
if ($folder_update_access.AccessToString -match 'Deny') {
|
||||||
|
|
||||||
($ACL = Get-Acl $env:LOCALAPPDATA\Spotify\Update).access | ForEach-Object {
|
($ACL = Get-Acl $env:LOCALAPPDATA\Spotify\Update).access | ForEach-Object {
|
||||||
$Users = $_.IdentityReference
|
$Users = $_.IdentityReference
|
||||||
$ACL.PurgeAccessRules($Users) }
|
$ACL.PurgeAccessRules($Users) }
|
||||||
@@ -259,18 +337,10 @@ if ($ch -eq 'y') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#Создать файл Update если его нет
|
#Создать файл Update если его нет
|
||||||
if (!($Check_folder_file -match '\bSystem\b|' -and $Check_folder_file -match '\bReadOnly\b')) {
|
if (!($Check_folder_file -match '\bSystem\b' -and $Check_folder_file -match '\bReadOnly\b')) {
|
||||||
New-Item -Path $env:LOCALAPPDATA\Spotify\ -Name "Update" -ItemType "file" -Value "STOPIT" | Out-Null
|
New-Item -Path $env:LOCALAPPDATA\Spotify\ -Name "Update" -ItemType "file" -Value "STOPIT" | Out-Null
|
||||||
$file = Get-ItemProperty -Path $env:LOCALAPPDATA\Spotify\Update
|
$file = Get-ItemProperty -Path $env:LOCALAPPDATA\Spotify\Update
|
||||||
$file.Attributes = "ReadOnly", "System"
|
$file.Attributes = "ReadOnly", "System"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -279,17 +349,26 @@ if ($ch -eq 'y') {
|
|||||||
Remove-item $env:APPDATA\Spotify\SpotifyMigrator.bak -Recurse -Force
|
Remove-item $env:APPDATA\Spotify\SpotifyMigrator.bak -Recurse -Force
|
||||||
Rename-Item -path $env:APPDATA\Spotify\SpotifyMigrator.exe -NewName $env:APPDATA\Spotify\SpotifyMigrator.bak
|
Rename-Item -path $env:APPDATA\Spotify\SpotifyMigrator.exe -NewName $env:APPDATA\Spotify\SpotifyMigrator.bak
|
||||||
}
|
}
|
||||||
|
|
||||||
# Если есть только мигратор .exe то переименовать его в .bak
|
# Если есть только мигратор .exe то переименовать его в .bak
|
||||||
if ($migrator_exe) {
|
if ($migrator_exe) {
|
||||||
Rename-Item -path $env:APPDATA\Spotify\SpotifyMigrator.exe -NewName $env:APPDATA\Spotify\SpotifyMigrator.bak
|
Rename-Item -path $env:APPDATA\Spotify\SpotifyMigrator.exe -NewName $env:APPDATA\Spotify\SpotifyMigrator.bak
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Write-Host "Updates blocked successfully" -ForegroundColor Green
|
Write-Host "Updates blocked successfully" -ForegroundColor Green
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($ch -eq 'n') {
|
if ($ch -eq 'n') {
|
||||||
Write-Host "Left unchanged"
|
Write-Host "Left unchanged"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($ch -eq 'u') {
|
if ($ch -eq 'u') {
|
||||||
If ($migrator_bak -or $Check_folder_file -match '\bSystem\b|\bReadOnly\b') {
|
If ($migrator_bak -or $Check_folder_file -match '\bSystem\b|\bReadOnly\b') {
|
||||||
|
|
||||||
@@ -305,13 +384,20 @@ if ($ch -eq 'u') {
|
|||||||
}
|
}
|
||||||
Write-Host "Updates unlocked" -ForegroundColor Green
|
Write-Host "Updates unlocked" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
If (!($migrator_bak -or $Check_folder_file -match '\bSystem\b|\bReadOnly\b')) {
|
If (!($migrator_bak -or $Check_folder_file -match '\bSystem\b|\bReadOnly\b')) {
|
||||||
Write-Host "Oops, updates are not blocked"
|
Write-Host "Oops, updates are not blocked"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# automatic cache clearing
|
# automatic cache clearing
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$ch = Read-Host -Prompt "Want to set up automatic cache cleanup? (Y/N) Delete script (U)"
|
$ch = Read-Host -Prompt "Want to set up automatic cache cleanup? (Y/N) Delete script (U)"
|
||||||
|
|
||||||
if (!($ch -eq 'n' -or $ch -eq 'y' -or $ch -eq 'u')) {
|
if (!($ch -eq 'n' -or $ch -eq 'y' -or $ch -eq 'u')) {
|
||||||
Write-Host "Oops, an incorrect value, " -ForegroundColor Red -NoNewline
|
Write-Host "Oops, an incorrect value, " -ForegroundColor Red -NoNewline
|
||||||
Write-Host "enter again through..." -NoNewline
|
Write-Host "enter again through..." -NoNewline
|
||||||
@@ -326,10 +412,18 @@ do {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ($ch -notmatch '^y$|^n$|^u$')
|
while ($ch -notmatch '^y$|^n$|^u$')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($ch -eq 'y') {
|
if ($ch -eq 'y') {
|
||||||
|
|
||||||
|
|
||||||
$test_cache_spotify_ps = Test-Path -Path $env:APPDATA\Spotify\cache-spotify.ps1
|
$test_cache_spotify_ps = Test-Path -Path $env:APPDATA\Spotify\cache-spotify.ps1
|
||||||
$test_spotify_vbs = Test-Path -Path $env:APPDATA\Spotify\Spotify.vbs
|
$test_spotify_vbs = Test-Path -Path $env:APPDATA\Spotify\Spotify.vbs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
If ($test_cache_spotify_ps) {
|
If ($test_cache_spotify_ps) {
|
||||||
Remove-item $env:APPDATA\Spotify\cache-spotify.ps1 -Recurse -Force
|
Remove-item $env:APPDATA\Spotify\cache-spotify.ps1 -Recurse -Force
|
||||||
}
|
}
|
||||||
@@ -337,10 +431,14 @@ if ($ch -eq 'y') {
|
|||||||
Remove-item $env:APPDATA\Spotify\Spotify.vbs -Recurse -Force
|
Remove-item $env:APPDATA\Spotify\Spotify.vbs -Recurse -Force
|
||||||
}
|
}
|
||||||
Start-Sleep -Milliseconds 200
|
Start-Sleep -Milliseconds 200
|
||||||
|
|
||||||
# cache-spotify.ps1
|
# cache-spotify.ps1
|
||||||
$webClient.DownloadFile('https://raw.githubusercontent.com/amd64fox/SpotX/main/cache-spotify.ps1', "$env:APPDATA\Spotify\cache-spotify.ps1")
|
$webClient.DownloadFile('https://raw.githubusercontent.com/amd64fox/SpotX/main/cache-spotify.ps1', "$env:APPDATA\Spotify\cache-spotify.ps1")
|
||||||
|
|
||||||
# Spotify.vbs
|
# Spotify.vbs
|
||||||
$webClient.DownloadFile('https://raw.githubusercontent.com/amd64fox/SpotX/main/Spotify.vbs', "$env:APPDATA\Spotify\Spotify.vbs")
|
$webClient.DownloadFile('https://raw.githubusercontent.com/amd64fox/SpotX/main/Spotify.vbs', "$env:APPDATA\Spotify\Spotify.vbs")
|
||||||
|
|
||||||
|
|
||||||
# Spotify.lnk
|
# Spotify.lnk
|
||||||
$source2 = "$env:APPDATA\Spotify\Spotify.vbs"
|
$source2 = "$env:APPDATA\Spotify\Spotify.vbs"
|
||||||
$target2 = "$desktop_folder\Spotify.lnk"
|
$target2 = "$desktop_folder\Spotify.lnk"
|
||||||
@@ -351,12 +449,19 @@ if ($ch -eq 'y') {
|
|||||||
$Shortcut2.IconLocation = "$env:APPDATA\Spotify\Spotify.exe"
|
$Shortcut2.IconLocation = "$env:APPDATA\Spotify\Spotify.exe"
|
||||||
$Shortcut2.TargetPath = $source2
|
$Shortcut2.TargetPath = $source2
|
||||||
$Shortcut2.Save()
|
$Shortcut2.Save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$ch = Read-Host -Prompt "Cache files that have not been used for more than XX days will be deleted.
|
$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"
|
Enter the number of days from 1 to 100"
|
||||||
|
|
||||||
if (!($ch -match "^[1-9][0-9]?$|^100$")) {
|
if (!($ch -match "^[1-9][0-9]?$|^100$")) {
|
||||||
Write-Host "Oops, an incorrect value, " -ForegroundColor Red -NoNewline
|
Write-Host "Oops, an incorrect value, " -ForegroundColor Red -NoNewline
|
||||||
Write-Host "enter again through..." -NoNewline
|
Write-Host "enter again through..." -NoNewline
|
||||||
|
|
||||||
Start-Sleep -Milliseconds 1000
|
Start-Sleep -Milliseconds 1000
|
||||||
Write-Host "3" -NoNewline
|
Write-Host "3" -NoNewline
|
||||||
Start-Sleep -Milliseconds 1000
|
Start-Sleep -Milliseconds 1000
|
||||||
@@ -368,6 +473,8 @@ if ($ch -eq 'y') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ($ch -notmatch '^[1-9][0-9]?$|^100$')
|
while ($ch -notmatch '^[1-9][0-9]?$|^100$')
|
||||||
|
|
||||||
|
|
||||||
if ($ch -match "^[1-9][0-9]?$|^100$") {
|
if ($ch -match "^[1-9][0-9]?$|^100$") {
|
||||||
$file_cache_spotify_ps1 = Get-Content $env:APPDATA\Spotify\cache-spotify.ps1 -Raw
|
$file_cache_spotify_ps1 = Get-Content $env:APPDATA\Spotify\cache-spotify.ps1 -Raw
|
||||||
$new_file_cache_spotify_ps1 = $file_cache_spotify_ps1 -replace 'seven', $ch -replace '-7', - $ch
|
$new_file_cache_spotify_ps1 = $file_cache_spotify_ps1 -replace 'seven', $ch -replace '-7', - $ch
|
||||||
@@ -381,17 +488,24 @@ if ($ch -eq 'y') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ch -eq 'n') {
|
if ($ch -eq 'n') {
|
||||||
Write-Host "installation completed" -ForegroundColor Green
|
Write-Host "installation completed" -ForegroundColor Green
|
||||||
|
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
if ($ch -eq 'u') {
|
if ($ch -eq 'u') {
|
||||||
|
|
||||||
$test_cache_spotify_ps = Test-Path -Path $env:APPDATA\Spotify\cache-spotify.ps1
|
$test_cache_spotify_ps = Test-Path -Path $env:APPDATA\Spotify\cache-spotify.ps1
|
||||||
$test_spotify_vbs = Test-Path -Path $env:APPDATA\Spotify\Spotify.vbs
|
$test_spotify_vbs = Test-Path -Path $env:APPDATA\Spotify\Spotify.vbs
|
||||||
|
|
||||||
If ($test_cache_spotify_ps -and $test_spotify_vbs) {
|
If ($test_cache_spotify_ps -and $test_spotify_vbs) {
|
||||||
Remove-item $env:APPDATA\Spotify\cache-spotify.ps1 -Recurse -Force
|
Remove-item $env:APPDATA\Spotify\cache-spotify.ps1 -Recurse -Force
|
||||||
Remove-item $env:APPDATA\Spotify\Spotify.vbs -Recurse -Force
|
Remove-item $env:APPDATA\Spotify\Spotify.vbs -Recurse -Force
|
||||||
|
|
||||||
$source3 = "$env:APPDATA\Spotify\Spotify.exe"
|
$source3 = "$env:APPDATA\Spotify\Spotify.exe"
|
||||||
$target3 = "$desktop_folder\Spotify.lnk"
|
$target3 = "$desktop_folder\Spotify.lnk"
|
||||||
$WorkingDir3 = "$env:APPDATA\Spotify"
|
$WorkingDir3 = "$env:APPDATA\Spotify"
|
||||||
@@ -405,10 +519,17 @@ if ($ch -eq 'u') {
|
|||||||
Write-Host "Installation completed" -ForegroundColor Green
|
Write-Host "Installation completed" -ForegroundColor Green
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
If (!($test_cache_spotify_ps -and $test_spotify_vbs)) {
|
If (!($test_cache_spotify_ps -and $test_spotify_vbs)) {
|
||||||
Write-Host "Oops, no cache clearing script found"
|
Write-Host "Oops, no cache clearing script found"
|
||||||
Write-Host "Installation completed" -ForegroundColor Green
|
Write-Host "Installation completed" -ForegroundColor Green
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|||||||
Reference in New Issue
Block a user