Skip to content

Commit

Permalink
Fix crash on sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
Beastwick18 committed Mar 7, 2024
1 parent 8128c82 commit dfd9f9b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 39 deletions.
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,11 @@ Add your real-time notes to your system tray!
<img width=300 src="./assets/login.png" />
</p>

2. Wait for the Battle Chronicle page to load, and copy your UID.
3. Paste your UID into the input box at the bottom.

<p align="center">
<img width=300 src="./assets/uid.png" />
</p>

4. *(optional)* Change the refresh interval to match how often you would like your data to refresh.
5. Click "Done"
2. *(optional)* Change the refresh interval to match how often you would like your data to refresh (in seconds).
3. Click "Done"

# 🏃 Run on startup
- Create a shortcut to either exe.
- Create a shortcut to either executable.
- Press `Win + R` and type in `shell:startup` and hit Enter.
- Copy the shortcut to this location.

Expand Down
Binary file modified assets/login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/uid.png
Binary file not shown.
66 changes: 37 additions & 29 deletions pkg/hoyo/hoyo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,28 @@ func MakeDailyRequest(url string, ltoken string, ltuid string, actID string) (*h
if err != nil {
return nil, err
}
r.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0")
r.Header.Add("Accept", "application/json, text/plain, */*")
r.Header.Add("Accept-Language", "en-US,en;q=0.5")
r.Header.Add("Accept-Encoding", "gzip, deflate, br")
r.Header.Add("Content-Type", "application/json;charset=utf-8")
r.Header.Add("x-rpc-device_id", "7ba783da-1cc5-4c95-87f5-760e064faf37")
r.Header.Add("x-rpc-app_version", "1.5.0")
r.Header.Add("x-rpc-platform", "4")
r.Header.Add("x-rpc-language", "en-us")
r.Header.Add("x-rpc-device_name", "")
r.Header.Add("Origin", "https://act.hoyolab.com")
r.Header.Add("Connection", "keep-alive")
r.Header.Add("Referer", "https://act.hoyolab.com/")
r.Header.Add("Cookie", fmt.Sprintf("ltoken_v2=%s; ltuid_v2=%s", ltoken, ltuid))
r.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0")
r.Header.Set("Accept", "application/json, text/plain, */*")
r.Header.Set("Accept-Language", "en-US,en;q=0.5")
r.Header.Set("Accept-Encoding", "gzip, deflate, br")
r.Header.Set("Content-Type", "application/json;charset=utf-8")
r.Header.Set("x-rpc-device_id", "7ba783da-1cc5-4c95-87f5-760e064faf37")
r.Header.Set("x-rpc-app_version", "1.5.0")
r.Header.Set("x-rpc-platform", "4")
r.Header.Set("x-rpc-language", "en-us")
r.Header.Set("x-rpc-device_name", "")
r.Header.Set("Origin", "https://act.hoyolab.com")
r.Header.Set("Connection", "keep-alive")
r.Header.Set("Referer", "https://act.hoyolab.com/")
r.Header.Set("Cookie", fmt.Sprintf("ltoken_v2=%s; ltuid_v2=%s", ltoken, ltuid))

client := &http.Client{}
client := &http.Client{
Timeout: 5 * time.Second,
}
response, err := client.Do(r)
if err != nil {
return nil, err
}
return response, nil
}

Expand All @@ -46,24 +51,27 @@ func MakeRequest(baseURL string, server string, genshinUID string, ltoken string
if err != nil {
return nil, err
}
r.Header.Add("User-Agent", "Mozilla/5.0 (Linux; Android 11; SAMSUNG SM-G973U) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/14.2 Chrome/87.0.4280.141 Mobile Safari/537.36")
r.Header.Add("Accept", "application/json, text/plain, */*")
r.Header.Add("Accept-Language", "en-US,en;q=0.5")
r.Header.Add("Accept-Encoding", "gzip, deflate, br")
r.Header.Add("x-rpc-client_type", "5")
r.Header.Add("x-rpc-app_version", "1.5.0")
r.Header.Add("x-rpc-language", "en-us")
r.Header.Add("Origin", "https://act.hoyolab.com")
r.Header.Add("Connection", "keep-alive")
r.Header.Add("Referer", "https://act.hoyolab.com/")
r.Header.Add("Cookie", fmt.Sprintf("ltoken_v2=%s; ltuid_v2=%s", ltoken, ltuid))
r.Header.Add("Sec-Fetch-Dest", "empty")
r.Header.Add("Sec-Fetch-Mode", "cors")
r.Header.Add("Sec-Fetch-Site", "same-site")
r.Header.Set("User-Agent", "Mozilla/5.0 (Linux; Android 11; SAMSUNG SM-G973U) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/14.2 Chrome/87.0.4280.141 Mobile Safari/537.36")
r.Header.Set("Accept", "application/json, text/plain, */*")
r.Header.Set("Accept-Language", "en-US,en;q=0.5")
r.Header.Set("Accept-Encoding", "gzip, deflate, br")
r.Header.Set("x-rpc-client_type", "5")
r.Header.Set("x-rpc-app_version", "1.5.0")
r.Header.Set("x-rpc-language", "en-us")
r.Header.Set("Origin", "https://act.hoyolab.com")
r.Header.Set("Connection", "keep-alive")
r.Header.Set("Referer", "https://act.hoyolab.com/")
r.Header.Set("Cookie", fmt.Sprintf("ltoken_v2=%s; ltuid_v2=%s", ltoken, ltuid))
r.Header.Set("Sec-Fetch-Dest", "empty")
r.Header.Set("Sec-Fetch-Mode", "cors")
r.Header.Set("Sec-Fetch-Site", "same-site")

client := &http.Client{}
r.Header.Add("DS", GenerateDS())
response, err := client.Do(r)
if err != nil {
return nil, err
}
return response, nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/logging/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func Warn(fmt string, v ...any) {
}

func SetFile(file string) {
log.SetFlags(log.LstdFlags | log.Llongfile)
var err error
f, err = os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
Expand Down

0 comments on commit dfd9f9b

Please sign in to comment.