|
Add-Type -AssemblyName System.Web |
|
|
|
$logLocation = "%userprofile%\AppData\LocalLow\miHoYo\Genshin Impact\output_log.txt"; |
|
$logLocationChina = "%userprofile%\AppData\LocalLow\miHoYo\$([char]0x539f)$([char]0x795e)\output_log.txt"; |
|
|
|
$reg = $args[0] |
|
$apiHost = "public-operation-hk4e-sg.hoyoverse.com" |
|
if ($reg -eq "china") { |
|
Write-Host "Using China cache location" |
|
$logLocation = $logLocationChina |
|
$apiHost = "public-operation-hk4e.mihoyo.com" |
|
} |
|
|
|
$tmps = $env:TEMP + '\pm.ps1'; |
|
if ([System.IO.File]::Exists($tmps)) { |
|
ri $tmps |
|
} |
|
|
|
$path = [System.Environment]::ExpandEnvironmentVariables($logLocation); |
|
if (-Not [System.IO.File]::Exists($path)) { |
|
Write-Host "Cannot find the log file! Make sure to open the wish history first!" -ForegroundColor Red |
|
|
|
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { |
|
Write-Host "Do you want to try to run the script as Administrator? Press [ENTER] to continue, or any key to cancel." |
|
$keyInput = [Console]::ReadKey($true).Key |
|
if ($keyInput -ne "13") { |
|
return |
|
} |
|
|
|
$myinvocation.mycommand.definition > $tmps |
|
|
|
Start-Process powershell -Verb runAs -ArgumentList "-noexit", $tmps, $reg |
|
break |
|
} |
|
|
|
return |
|
} |
|
|
|
$logs = Get-Content -Path $path |
|
$m = $logs -match "(?m).:/.+(GenshinImpact_Data|YuanShen_Data)" |
|
$m[0] -match "(.:/.+(GenshinImpact_Data|YuanShen_Data))" >$null |
|
|
|
if ($matches.Length -eq 0) { |
|
Write-Host "Cannot find the wish history url! Make sure to open the wish history first!" -ForegroundColor Red |
|
return |
|
} |
|
|
|
$gamedir = $matches[1] |
|
# Thanks to @jogerj for getting the latest webchache dir |
|
$webcachePath = Resolve-Path "$gamedir/webCaches" |
|
$cacheVerPath = Get-Item (Get-ChildItem -Path $webcachePath | Sort-Object LastWriteTime -Descending | Select-Object -First 1).FullName |
|
$cachefile = Resolve-Path "$cacheVerPath/Cache/Cache_Data/data_2" |
|
$tmpfile = "$env:TEMP/ch_data_2" |
|
|
|
Copy-Item $cachefile -Destination $tmpfile |
|
|
|
function testUrl($url) { |
|
$ProgressPreference = 'SilentlyContinue' |
|
$uri = [System.UriBuilder]::New($url) |
|
$uri.Path = "gacha_info/api/getGachaLog" |
|
$uri.Host = $apiHost |
|
$uri.Fragment = "" |
|
$params = [System.Web.HttpUtility]::ParseQueryString($uri.Query) |
|
$params.Set("lang", "en"); |
|
$params.Set("gacha_type", 301); |
|
$params.Set("size", "5"); |
|
$params.Add("lang", "en-us"); |
|
$uri.Query = $params.ToString() |
|
$apiUrl = $uri.Uri.AbsoluteUri |
|
|
|
$response = Invoke-WebRequest -Uri $apiUrl -ContentType "application/json" -UseBasicParsing -TimeoutSec 10 | ConvertFrom-Json |
|
$testResult = $response.retcode -eq 0 |
|
return $testResult |
|
} |
|
|
|
$content = Get-Content -Encoding UTF8 -Raw $tmpfile |
|
$splitted = $content -split "1/0/" |
|
$found = $splitted -match "webview_gacha" |
|
$link = $false |
|
$linkFound = $false |
|
for ($i = $found.Length - 1; $i -ge 0; $i -= 1) { |
|
$t = $found[$i] -match "(https.+?game_biz=)" |
|
$link = $matches[0] |
|
Write-Host "`rChecking Link $i" -NoNewline |
|
$testResult = testUrl $link |
|
if ($testResult -eq $true) { |
|
$linkFound = $true |
|
break |
|
} |
|
Sleep 1 |
|
} |
|
|
|
Remove-Item $tmpfile |
|
|
|
Write-Host "" |
|
|
|
if (-Not $linkFound) { |
|
Write-Host "Cannot find the wish history url! Make sure to open the wish history first!" -ForegroundColor Red |
|
return |
|
} |
|
|
|
$wishHistoryUrl = $link |
|
|
|
Write-Host $wishHistoryUrl |
|
Set-Clipboard -Value $wishHistoryUrl |
|
Write-Host "Link copied to clipboard, paste it back to paimon.moe" -ForegroundColor Green |
https://webstatic-sea.hoyoverse.com/genshin/event/e20190909gacha-v2/index.html?win_mode=fullscreen&authkey_ver=1&sign_type=2&auth_appid=webview_gacha&init_type=301&gacha_id=666e99c499de824cf10211511d3c2ad3b48cf38d×tamp=1673997965&lang=ja&device_type=pc&game_version=OSRELWin3.4.0_R12875869_S12901190_D13021296&plat_type=pc®ion=os_asia&authkey=lTW%2fFdSYCJPo85m%2bPESmZ4xCjwsfJBWHpI%2fXOAHYKaE8iv%2fgsHR%2bJJam%2bUHaKBIG7B0nVNkWcTnJer7c1j53B%2fJ2L8hXgA0LhNxj0VzuZpW%2faEAl8pOI3e%2bCn%2bCUgs0AxSvA4BJaxCNDBIJ9S8b8UTue5igLGzGR9GOf78Te7HhwZ%2fkhJWAB4A9S0fTfYDjjKchwYfSt%2ba8haNIAfXK%2f0OhnbBye3%2b4SiOOl%2fHb%2fpZl7zxWMvmokQEkY1PYqxwIPnqYdbh80Knh%2fAG%2bKuy%2fQn2JjD8v14l7r3LSVK%2fs02uchlh%2fDede6Oor0Mscf5rykkdotgVAbDotJeYg2Nrarn4MP4HIIaF8a08UW8KTZND3m1a%2fK%2fed32elkTNgqhWjAi1ZDlGW3J099%2buLjEUb0Bqm7IMEf7RNdkXwIK5mHUupcQHrygKW8rwmEV2utN0zV7sQbOg50jeVy5JMswPVC%2fMpHfyZS3igG%2fd5jaecBrZ67m3anvfb4T%2fu9aHs0X4vqmiQmYlcoLoLjJ0ewTbLranAxUQdrpmJ%2fIILK99PKMAAwv%2byMhmhglPhdPxqKcfvWCqDGIIvM5nrFO99nAaVVg1m7IOjwdnXQGDFKEKr434htgGv0QeF6MZYnNlQ0T%2fWEBj6m%2bm0UMoC2eD91TCD%2fGVl%2bCMiIOHrlWvE7kljNOBnZ%2fb80qkdBiBIVqDXfNjvT76Yh21eBn8BlwfF2nlSi5NGN5hFXybdoBCq45tWQd28XI3ifBG1rSZf%2fEryjwQxqUklRPGtPJozNSPw2YuZLTtzNjWfBS%2bQZeJqYO7DxMFwiSzlAU0v8q%2bqSt8m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