# Raids Timer BlueStacks opener 1.0.185 # Double-click or right-click → Run with PowerShell. # Installs helper 1.0.185, opens Auto Farm, raidstimer.me, then BlueStacks. $ErrorActionPreference = "Continue" try { Unblock-File -LiteralPath $PSCommandPath -ErrorAction SilentlyContinue } catch {} try { Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force -ErrorAction SilentlyContinue } catch {} try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 } catch {} function Clear-HelperMarkOfWeb([string]$path) { if (-not $path) { return } try { Unblock-File -LiteralPath $path -ErrorAction SilentlyContinue } catch {} try { Remove-Item -LiteralPath $path -Stream Zone.Identifier -Force -ErrorAction SilentlyContinue } catch {} } function Copy-HelperFileClean([string]$from, [string]$to) { if (-not $from -or -not $to -or -not (Test-Path -LiteralPath $from)) { return $false } try { $dir = Split-Path -Parent $to if ($dir -and -not (Test-Path -LiteralPath $dir)) { New-Item -ItemType Directory -Force -Path $dir | Out-Null } [IO.File]::WriteAllBytes($to, [IO.File]::ReadAllBytes($from)) Clear-HelperMarkOfWeb $to return $true } catch { return $false } } try { Clear-HelperMarkOfWeb $PSCommandPath } catch {} $site = "https://raidstimer.me/raids-timer/" $root = Join-Path $env:APPDATA "RaidsTimer" New-Item -ItemType Directory -Force -Path $root | Out-Null $dest = Join-Path $root "pc-banner.ps1" $here = $PSScriptRoot if (-not $here) { $here = Split-Path -Parent $PSCommandPath } function Test-HelperParses([string]$p) { if (-not $p -or -not (Test-Path -LiteralPath $p)) { return $false } $tok = $null $err = $null try { [void][System.Management.Automation.Language.Parser]::ParseFile($p, [ref]$tok, [ref]$err) return (-not $err) -or (@($err).Count -eq 0) } catch { return $false } } function Read-HelperVer([string]$p) { if (-not $p -or -not (Test-Path -LiteralPath $p)) { return [version]"0.0.0" } try { $hit = Select-String -LiteralPath $p -Pattern 'HelperVersion\s*=\s*"([^"]+)"' | Select-Object -First 1 if ($hit) { return [version]$hit.Matches[0].Groups[1].Value } } catch {} return [version]"0.0.0" } function Save-FromSites([string]$rel, [string]$outFile, [int]$minLen) { $probe = Join-Path $root ("fetch-" + [IO.Path]::GetFileName($outFile)) foreach ($base in @( "https://raidstimer.me/raids-timer", "https://www.raidstimer.me/raids-timer", "https://savemypet-backend.onrender.com/raids-timer" )) { try { Invoke-WebRequest -Uri ($base.TrimEnd("/") + "/" + $rel.TrimStart("/")) -OutFile $probe -UseBasicParsing -TimeoutSec 12 if ((Test-Path -LiteralPath $probe) -and ((Get-Item -LiteralPath $probe).Length -ge $minLen)) { Copy-HelperFileClean $probe $outFile return $true } } catch {} } return $false } function Stop-OldPcBanner { $me = [int]$PID try { Get-CimInstance Win32_Process -Filter "Name='powershell.exe' OR Name='pwsh.exe'" -ErrorAction SilentlyContinue | ForEach-Object { $cl = [string]$_.CommandLine if ($cl -notmatch 'pc-banner\.ps1') { return } if ([int]$_.ProcessId -eq $me) { return } try { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue } catch {} } } catch {} } function Get-BlueStacksPlayer { $fromReg = @() foreach ($key in @( "HKLM:\SOFTWARE\BlueStacks_nxt", "HKLM:\SOFTWARE\BlueStacks", "HKLM:\SOFTWARE\WOW6432Node\BlueStacks_nxt", "HKLM:\SOFTWARE\WOW6432Node\BlueStacks", "HKCU:\SOFTWARE\BlueStacks_nxt", "HKCU:\SOFTWARE\BlueStacks" )) { foreach ($name in @("InstallDir", "UserDefinedDir", "DataDir")) { try { $v = [string](Get-ItemProperty -LiteralPath $key -Name $name -ErrorAction Stop).$name if ($v) { $fromReg += $v } } catch {} } } $players = New-Object System.Collections.Generic.List[string] foreach ($dir in $fromReg) { if (-not $dir) { continue } foreach ($name in @("HD-Player.exe", "Bluestacks.exe")) { $p = Join-Path $dir $name if (Test-Path -LiteralPath $p) { [void]$players.Add($p) } $p2 = Join-Path $dir ("Client\" + $name) if (Test-Path -LiteralPath $p2) { [void]$players.Add($p2) } } } foreach ($p in @( "${env:ProgramFiles}\BlueStacks_nxt\HD-Player.exe", "${env:ProgramFiles(x86)}\BlueStacks_nxt\HD-Player.exe", "${env:ProgramFiles}\BlueStacks\HD-Player.exe", "${env:ProgramFiles(x86)}\BlueStacks\HD-Player.exe", "${env:ProgramFiles}\BlueStacks_msi5\HD-Player.exe", "${env:ProgramFiles(x86)}\BlueStacks_msi5\HD-Player.exe", "$env:LOCALAPPDATA\BlueStacks_nxt\HD-Player.exe", "$env:LOCALAPPDATA\BlueStacks\HD-Player.exe", "$env:ProgramData\BlueStacks_nxt\HD-Player.exe" )) { if ($p -and (Test-Path -LiteralPath $p)) { [void]$players.Add($p) } } return @($players | Select-Object -Unique | Where-Object { $_ }) } $tmp = Join-Path $root "pc-banner.fetch.ps1" [void](Save-FromSites "pc-banner.ps1" $tmp 4000) if ((Test-Path -LiteralPath $tmp) -and (Test-HelperParses $tmp) -and ((Get-Item -LiteralPath $tmp).Length -gt 4000)) { Copy-HelperFileClean $tmp $dest } $best = $null $bestV = [version]"0.0.0" $bestLen = 0 foreach ($dir in @( $here, (Join-Path $here ".."), $root, (Join-Path $env:USERPROFILE "Downloads"), [Environment]::GetFolderPath("Desktop") )) { if (-not $dir -or -not (Test-Path -LiteralPath $dir)) { continue } Get-ChildItem -LiteralPath $dir -File -ErrorAction SilentlyContinue | Where-Object { $_.Name -match '(?i)^(pc-banner.*|RaidsTimer-helper.*)\.ps1$' } | ForEach-Object { if (-not (Test-HelperParses $_.FullName)) { return } $v = Read-HelperVer $_.FullName $len = $_.Length if (($v -gt $bestV) -or ($v -eq $bestV -and $len -ge $bestLen)) { $bestV = $v $bestLen = $len $best = $_.FullName } } } if ($best -and $bestV -ge (Read-HelperVer $dest) -and (Test-HelperParses $best)) { Copy-HelperFileClean $best $dest } $wantSha = "" foreach ($manUrl in @( ($site.TrimEnd("/") + "/downloads/versions.json"), "https://savemypet-backend.onrender.com/raids-timer/downloads/versions.json" )) { try { $man = Invoke-RestMethod -Uri $manUrl -TimeoutSec 12 $tool = @($man.tools | Where-Object { [string]$_.id -eq "pc-helper" }) | Select-Object -First 1 if ($tool -and $tool.sha256) { $wantSha = ([string]$tool.sha256).ToLower(); break } } catch {} } if ($wantSha -and (Test-Path -LiteralPath $dest)) { $gotSha = (Get-FileHash -LiteralPath $dest -Algorithm SHA256).Hash.ToLower() if ($gotSha -ne $wantSha) { Write-Host "The helper on this PC did not match the website file. Installing the website helper." if ((Test-Path -LiteralPath $tmp) -and (Test-HelperParses $tmp)) { Copy-HelperFileClean $tmp $dest } else { [void](Save-FromSites "pc-banner.ps1" $dest 4000) } } } $png = Join-Path $root "icon-192.png" foreach ($dir in @($here, (Join-Path $here ".."))) { foreach ($name in @("icon-192.png", "RaidsTimer-icon-192.png")) { $beside = Join-Path $dir $name if (Test-Path -LiteralPath $beside) { Copy-HelperFileClean $beside $png break } } } [void](Save-FromSites "icon-192.png" $png 500) [void](Save-FromSites "pc-banner.cmd" (Join-Path $root "Start-Raids-Timer-Helper.cmd") 200) [void](Save-FromSites "pc-banner-start.ps1" (Join-Path $root "pc-banner-start.ps1") 200) if (-not (Test-Path -LiteralPath $dest)) { Write-Host "Could not get the PC helper. Open $site then Download → Windows PC Chat helper, and run this opener again." Start-Sleep -Seconds 8 exit 1 } $needRestart = $true try { $h = Invoke-RestMethod -Uri "http://127.0.0.1:18765/health" -TimeoutSec 2 $running = [version]"0.0.0" try { if ($h.version) { $running = [version]([string]$h.version) } } catch {} $want = Read-HelperVer $dest if ($h -and $h.ok -eq $true -and $running -ge $want) { $needRestart = $false } } catch {} $exe = Join-Path $env:SystemRoot "System32\WindowsPowerShell\v1.0\powershell.exe" if ($needRestart) { Stop-OldPcBanner Start-Sleep -Milliseconds 400 Start-Process -FilePath $exe -ArgumentList @( "-NoProfile", "-STA", "-ExecutionPolicy", "Bypass", "-WindowStyle", "Hidden", "-File", $dest, "-OpenFarm" ) | Out-Null } else { try { Invoke-RestMethod -Method POST -Uri "http://127.0.0.1:18765/ui/open" -ContentType "application/json" -Body "{}" -TimeoutSec 3 | Out-Null } catch { Start-Process -FilePath $exe -ArgumentList @( "-NoProfile", "-STA", "-ExecutionPolicy", "Bypass", "-WindowStyle", "Hidden", "-File", $dest, "-OpenFarm" ) | Out-Null } } Start-Process $site | Out-Null $alive = Join-Path $root "helper-alive.txt" $ready = Join-Path $root "helper-ready.txt" $okHelper = $false for ($i = 0; $i -lt 18; $i++) { Start-Sleep -Seconds 1 if ((Test-Path -LiteralPath $alive) -or (Test-Path -LiteralPath $ready)) { $okHelper = $true; break } try { $h2 = Invoke-RestMethod -Uri "http://127.0.0.1:18765/health" -TimeoutSec 1 if ($h2 -and $h2.ok -eq $true) { $okHelper = $true; break } } catch {} } $hd = Get-BlueStacksPlayer | Select-Object -First 1 if ($hd) { Start-Process -FilePath $hd | Out-Null Write-Host "BlueStacks is starting. Auto Farm is on the helper. PayPal Chat or Apple Chat (same commander) must be active. The helper shows last payment and until when." } else { Write-Host "BlueStacks was not found. Install BlueStacks, then run this opener again. The helper still opened Auto Farm. PayPal Chat or Apple Chat unlocks it." } if ($okHelper) { Write-Host ("Helper " + (Read-HelperVer $dest).ToString() + " is running. Desktop shortcut: Raids Timer Chat") } else { Write-Host "Helper was not running. Open More then Download on the website, or run Start-Raids-Timer-Helper.cmd in AppData\RaidsTimer." try { Start-Process ($site.TrimEnd("/") + "/#") | Out-Null } catch {} } Write-Host "Website: $site" Start-Sleep -Seconds 5