$content = Get-Content js\main.js -Raw
$matches = [regex]::Matches($content,'https?://[^"''\)\s]+')
$urls = $matches | ForEach-Object { $_.Value } | Select-Object -Unique
$allOut='scan_all_urls.txt'; $failOut='scan_failing_urls.txt'; $goodOut='scan_good_urls.txt'
'' | Out-File $allOut -Force
'' | Out-File $failOut -Force
'' | Out-File $goodOut -Force
foreach($u in $urls){
    try{
        $r=Invoke-WebRequest -Uri $u -Method Head -TimeoutSec 15 -ErrorAction Stop
        if($r.StatusCode -eq 200){ $u | Out-File $goodOut -Append } else { $u | Out-File $failOut -Append }
    } catch {
        $u | Out-File $failOut -Append
    }
    $u | Out-File $allOut -Append
}
Write-Output "Done. Totals: $((Get-Content $allOut | Measure-Object).Count) all, $((Get-Content $goodOut | Measure-Object).Count) good, $((Get-Content $failOut | Measure-Object).Count) fail"
