fix 403 forbidden when user doesnt have chrome #132

This commit is contained in:
zoicware
2026-02-17 18:17:46 -05:00
committed by GitHub
parent bc8ed54511
commit 709bdb0a32

View File

@@ -1261,7 +1261,7 @@ function Download-AppxPackage {
$UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome # needed as sometimes the API will block things when it knows requests are coming from PowerShell $UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome # needed as sometimes the API will block things when it knows requests are coming from PowerShell
} }
catch { catch {
#ignore error $UserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36'
} }
$DownloadedFiles = @() $DownloadedFiles = @()
@@ -1298,6 +1298,15 @@ function Download-AppxPackage {
lang = 'en-US' lang = 'en-US'
} }
$headers = @{
'User-Agent' = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36'
'Accept' = 'application/json, text/javascript, */*; q=0.01'
'Content-Type' = 'application/x-www-form-urlencoded; charset=UTF-8'
'X-Requested-With' = 'XMLHttpRequest'
'Origin' = 'https://store.rg-adguard.net'
'Referer' = 'https://store.rg-adguard.net/'
}
# required due to the api being protected behind Cloudflare now # required due to the api being protected behind Cloudflare now
if (-Not $apiWebSession) { if (-Not $apiWebSession) {
$global:apiWebSession = $null $global:apiWebSession = $null
@@ -1307,7 +1316,7 @@ function Download-AppxPackage {
$raw = $null $raw = $null
try { try {
$raw = Invoke-RestMethod -Method Post -Uri $apiUrl -ContentType 'application/x-www-form-urlencoded' -Body $body -UserAgent $UserAgent -WebSession $apiWebSession $raw = Invoke-RestMethod -Method Post -Uri $apiUrl -Headers $headers -Body $body -WebSession $apiWebSession
} }
catch { catch {
$errorMsg = 'An error occurred: ' + $_ $errorMsg = 'An error occurred: ' + $_