What the Honkai: Star Rail import script reads
To import your history you run a short PowerShell script. This page walks through the Honkai: Star Rail script step by step: what it reads, what it leaves alone and what happens to the link it copies. The full script is at the bottom.
What it does, step by step
Reads the game's own log in AppData\LocalLow to find out where the game is installed.
Finds the newest data_2 file in the game's webCaches folder. That file is the cache of the history page you opened in the game.
Copies that file to a temporary file, reads the copy and deletes it straight away. The game keeps the original open, and the script never touches it.
Takes the last link in the text that contains authkey: the address of your pull history page.
Puts the link into the clipboard and prints “Done”. Nothing else happens until you paste the link on our page yourself.
What it never does
- It sends nothing over the internet: there are no download or upload commands in it.
- It doesn't change or delete game files. The only file it writes is its own temporary copy of the cache, deleted right after reading.
- It doesn't ask for administrator rights and installs nothing.
- It doesn't ask for your password, login or cookies.
What is in the link
The link carries a temporary key, authkey, which the game creates for the history page. It only lets someone read your pull history, and it expires on its own.
HoYoverse's history service doesn't let browsers read it directly, so each request goes through our server once and straight on to HoYoverse. We don't log the link and don't store it; the history itself is saved in your browser and, if you're signed in, in your account.
What we keep
The history itself, pull by pull, stays in your browser. If you're signed in, the same records sync to your account so the tracker works on your other devices. The link is never saved anywhere, not even in your browser. To erase the history, press “Delete history” in the tracker: it goes from this browser and from your account.
Check it yourself
- Read the script before you run it. It's shown in full below: plain text made of standard PowerShell commands.
- Look for network commands such as Invoke-WebRequest or Invoke-RestMethod. There are none.
- If you like, paste the link into Notepad first: it starts with an address on hoyoverse.com.
- During the import, the Network tab in your browser's developer tools shows where every request goes: only to our /api/gacha/history address, which passes it on to the publisher.
The full script
The same script as on the import page.
# GachaFans: find the Honkai: Star Rail warp history link (reads local files only)
$dir = Join-Path $env:USERPROFILE 'AppData\LocalLow\Cognosphere\Star Rail'
$line = 'Player.log', 'Player-prev.log' | ForEach-Object { Join-Path $dir $_ } | Where-Object { Test-Path -LiteralPath $_ } |
ForEach-Object { Get-Content -LiteralPath $_ -TotalCount 11 } | Where-Object { $_.StartsWith('Loading player data from ') } | Select-Object -First 1
if (-not $line) { Write-Host 'Game folder not found. Start Honkai: Star Rail on this PC first.'; return }
$data = ($line.Substring(25) -replace 'data\.unity3d$', '').TrimEnd('/')
if (-not (Test-Path -LiteralPath $data)) { Write-Host "The game folder from the log is gone: $data. Start the game, open the pull history, then run this again."; return }
$cache = Get-ChildItem -LiteralPath (Join-Path $data 'webCaches') -Recurse -File -Filter 'data_2' -ErrorAction SilentlyContinue |
Sort-Object LastWriteTime -Descending | Select-Object -First 1
if (-not $cache) { Write-Host 'Cache not found. Open the pull history in the game, then run this again.'; return }
$tmp = Join-Path $env:TEMP ([guid]::NewGuid().ToString())
Copy-Item -LiteralPath $cache.FullName -Destination $tmp
$text = [IO.File]::ReadAllText($tmp)
Remove-Item -LiteralPath $tmp
$url = $text -split '1/0/' | Where-Object { $_ -match 'authkey=' } |
ForEach-Object { [regex]::Match($_, 'https://[A-Za-z0-9\-._~:/?#\[\]@!$&''()*+,;=%]+').Value } |
Where-Object { $_ -match 'authkey=' } | Select-Object -Last 1
if (-not $url) { Write-Host 'Link not found. Open the pull history in the game, then run this again.'; return }
Set-Clipboard -Value $url
Write-Host 'Done: the link is in your clipboard. Paste it on the GachaFans page.'