mirror of
https://github.com/SpotX-Official/SpotX.git
synced 2026-04-22 19:10:19 +10:00
14
run.ps1
14
run.ps1
@@ -592,20 +592,24 @@ $hostsFilePath = Join-Path $Env:windir 'System32\Drivers\Etc\hosts'
|
|||||||
$hostsBackupFilePath = Join-Path $Env:windir 'System32\Drivers\Etc\hosts.bak'
|
$hostsBackupFilePath = Join-Path $Env:windir 'System32\Drivers\Etc\hosts.bak'
|
||||||
|
|
||||||
if (Test-Path -Path $hostsFilePath) {
|
if (Test-Path -Path $hostsFilePath) {
|
||||||
$hosts = Get-Content -Path $hostsFilePath
|
|
||||||
|
|
||||||
if ($hosts -match '^[^\#|].+scdn.+|^[^\#|].+spotify.+') {
|
$hosts = [System.IO.File]::ReadAllLines($hostsFilePath)
|
||||||
|
$regex = "^(?!#|\|)((?:.*?(?:download|upgrade)\.scdn\.co|.*?spotify).*)"
|
||||||
|
|
||||||
|
if ($hosts -match $regex) {
|
||||||
|
|
||||||
Write-Host ($lang).HostInfo
|
Write-Host ($lang).HostInfo
|
||||||
Write-Host ($lang).HostBak
|
Write-Host ($lang).HostBak
|
||||||
|
|
||||||
Copy-Item -Path $hostsFilePath -Destination $hostsBackupFilePath -ErrorAction SilentlyContinue
|
Copy-Item -Path $hostsFilePath -Destination $hostsBackupFilePath -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
if ($?) {
|
if ($?) {
|
||||||
|
|
||||||
Write-Host ($lang).HostDel
|
Write-Host ($lang).HostDel
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$hosts = $hosts -replace '^[^\#|].+scdn.+|^[^\#|].+spotify.+', ''
|
$hosts = $hosts | Where-Object { $_ -notmatch $regex }
|
||||||
$hosts = $hosts | Where-Object { $_.trim() -ne "" }
|
[System.IO.File]::WriteAllLines($hostsFilePath, $hosts)
|
||||||
Set-Content -Path $hostsFilePath -Value $hosts -Force
|
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host ($lang).HostError -ForegroundColor Red
|
Write-Host ($lang).HostError -ForegroundColor Red
|
||||||
|
|||||||
Reference in New Issue
Block a user