From 173b687db018143b3dfa6a93c96292ddd95b9929 Mon Sep 17 00:00:00 2001 From: hina Date: Sat, 17 Aug 2024 07:38:07 +0900 Subject: [PATCH 1/5] [zzz] Update game records URL --- src/Starward/Controls/BBSWebBridge.xaml.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Starward/Controls/BBSWebBridge.xaml.cs b/src/Starward/Controls/BBSWebBridge.xaml.cs index 1dc14800f..7c6cd1aa8 100644 --- a/src/Starward/Controls/BBSWebBridge.xaml.cs +++ b/src/Starward/Controls/BBSWebBridge.xaml.cs @@ -168,10 +168,10 @@ public async Task LoadPageAsync(bool force = false) { (true, GameBiz.GenshinImpact) => "https://act.hoyolab.com/app/community-game-records-sea/m.html?gid=2", (true, GameBiz.StarRail) => "https://act.hoyolab.com/app/community-game-records-sea/m.html?gid=6", - (true, GameBiz.ZZZ) => "https://act.hoyolab.com/app/community-game-records-sea/m.html?gid=8", + (true, GameBiz.ZZZ) => "https://act.hoyolab.com/app/mihoyo-zzz-game-record/index.html", (false, GameBiz.GenshinImpact) => "https://webstatic.mihoyo.com/app/community-game-records/?game_id=2", (false, GameBiz.StarRail) => "https://webstatic.mihoyo.com/app/community-game-records/?game_id=6", - (false, GameBiz.ZZZ) => "https://webstatic.mihoyo.com/app/community-game-records/?game_id=8", + (false, GameBiz.ZZZ) => "https://act.mihoyo.com/app/mihoyo-zzz-game-record/index.html", _ => null, }; if (url is not null) @@ -645,19 +645,19 @@ private static string GetRandomString(int timestamp) private class JsParam { /// - /// 方法名称 + /// 锟斤拷锟斤拷锟斤拷锟斤拷 /// [JsonPropertyName("method")] public string Method { get; set; } /// - /// 数据 可以为空 + /// 锟斤拷锟斤拷 锟斤拷锟斤拷为锟斤拷 /// [JsonPropertyName("payload")] public JsonNode? Payload { get; set; } /// - /// 回调的名称,调用 JavaScript:mhyWebBridge 时作为首个参数传入 + /// 锟截碉拷锟斤拷锟斤拷锟狡o拷锟斤拷锟斤拷 JavaScript:mhyWebBridge 时锟斤拷为锟阶革拷锟斤拷锟斤拷锟斤拷锟斤拷 /// [JsonPropertyName("callback")] public string? Callback { get; set; } @@ -668,19 +668,19 @@ private class JsParam private class JsResult { /// - /// 代码 + /// 锟斤拷锟斤拷 /// [JsonPropertyName("retcode")] public int Code { get; set; } /// - /// 消息 + /// 锟斤拷息 /// [JsonPropertyName("message")] public string Message { get; set; } = string.Empty; /// - /// 数据 + /// 锟斤拷锟斤拷 /// [JsonPropertyName("data")] public Dictionary Data { get; set; } = default!; From 2a7e9a383ea1e0b8e4f7a1ba9953ae7146fcf39f Mon Sep 17 00:00:00 2001 From: hina Date: Sat, 17 Aug 2024 07:40:02 +0900 Subject: [PATCH 2/5] Retrieve ZZZ Account data --- .../GameRecord/GameRecordClient.cs | 14 ++++++++ src/Starward.Core/GameRecord/HoyolabClient.cs | 31 +++++++++++++++++- .../GameRecord/HyperionClient.cs | 32 ++++++++++++++++++- 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/src/Starward.Core/GameRecord/GameRecordClient.cs b/src/Starward.Core/GameRecord/GameRecordClient.cs index 30bd931f1..a9a8c1e5b 100644 --- a/src/Starward.Core/GameRecord/GameRecordClient.cs +++ b/src/Starward.Core/GameRecord/GameRecordClient.cs @@ -369,6 +369,20 @@ protected virtual async Task CommonSendAsync(HttpRequestMessage request, Cancell #endregion + #region ZZZ + + /// + /// Get ZZZ Role + /// + /// + /// + /// + /// 杈撳叆鐨 cookie 涓虹┖ + public abstract Task> GetZZZGameRolesAsync(string cookie, CancellationToken cancellationToken = default); + + #endregion + + // 瀵板畤铦楃伨 // https://api-takumi-record.mihoyo.com/game_record/app/hkrpg/api/rogue_locust?server=prod_gf_cn&role_id={uid}&need_detail=true diff --git a/src/Starward.Core/GameRecord/HoyolabClient.cs b/src/Starward.Core/GameRecord/HoyolabClient.cs index 83c6fdd66..228098182 100644 --- a/src/Starward.Core/GameRecord/HoyolabClient.cs +++ b/src/Starward.Core/GameRecord/HoyolabClient.cs @@ -14,7 +14,7 @@ public class HoyolabClient : GameRecordClient public override string UAContent => $"Mozilla/5.0 (Linux; Android 13; Pixel 5 Build/TQ3A.230901.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/118.0.0.0 Mobile Safari/537.36 miHoYoBBSOversea/{AppVersion}"; - public override string AppVersion => "2.54.0"; + public override string AppVersion => "2.59.0"; protected override string ApiSalt => "okr4obncj8bw5a65hbnn5oo6ixjc3l9w"; @@ -83,6 +83,7 @@ public override async Task> GetAllGameRolesAsync(string coo var list = new List(); list.AddRange(await GetGenshinGameRolesAsync(cookie, cancellationToken)); list.AddRange(await GetStarRailGameRolesAsync(cookie, cancellationToken)); + list.AddRange(await GetZZZGameRolesAsync(cookie, cancellationToken)); return list; } @@ -459,4 +460,32 @@ public override async Task GetTrailblazeCalendarDetail #endregion + #region ZZZ + + /// + /// Get ZZZ Role + /// + /// + /// + /// + /// 杈撳叆鐨 cookie 涓虹┖ + public override async Task> GetZZZGameRolesAsync(string cookie, CancellationToken cancellationToken = default) + { + if (string.IsNullOrWhiteSpace(cookie)) + { + throw new ArgumentNullException(nameof(cookie)); + } + + const string url = "https://api-account-os.hoyolab.com/binding/api/getUserGameRolesByCookieToken?game_biz=nap_global"; + var request = new HttpRequestMessage(HttpMethod.Get, url); + request.Headers.Add(Cookie, cookie); + request.Headers.Add(X_Request_With, com_mihoyo_hoyolab); + request.Headers.Add(Referer, "https://act.hoyolab.com"); + var data = await CommonSendAsync(request, cancellationToken); + data.List?.ForEach(x => x.Cookie = cookie); + return data.List ?? new List(); + } + + #endregion + } diff --git a/src/Starward.Core/GameRecord/HyperionClient.cs b/src/Starward.Core/GameRecord/HyperionClient.cs index 0e4af788f..3836edad4 100644 --- a/src/Starward.Core/GameRecord/HyperionClient.cs +++ b/src/Starward.Core/GameRecord/HyperionClient.cs @@ -15,7 +15,7 @@ public class HyperionClient : GameRecordClient public override string UAContent => $"Mozilla/5.0 (Linux; Android 13; Pixel 5 Build/TQ3A.230901.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/118.0.0.0 Mobile Safari/537.36 miHoYoBBS/{AppVersion}"; - public override string AppVersion => "2.71.1"; + public override string AppVersion => "2.74.2"; protected override string ApiSalt => "t0qEgfub6cvueAPgR5m9aQWWVciEer7v"; @@ -80,6 +80,7 @@ public override async Task> GetAllGameRolesAsync(string coo var list = new List(); list.AddRange(await GetGenshinGameRolesAsync(cookie, cancellationToken)); list.AddRange(await GetStarRailGameRolesAsync(cookie, cancellationToken)); + list.AddRange(await GetZZZGameRolesAsync(cookie, cancellationToken)); return list; } @@ -517,6 +518,35 @@ public override async Task GetTrailblazeCalendarDetail #endregion + #region ZZZ + + /// + /// Get ZZZ Role + /// + /// + /// + /// + /// 杈撳叆鐨 cookie 涓虹┖ + public override async Task> GetZZZGameRolesAsync(string cookie, CancellationToken cancellationToken = default) + { + if (string.IsNullOrWhiteSpace(cookie)) + { + throw new ArgumentNullException(nameof(cookie)); + } + const string url = "https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=nap_cn"; + var request = new HttpRequestMessage(HttpMethod.Get, url); + request.Headers.Add(Cookie, cookie); + request.Headers.Add(DS, CreateSecret2(url)); + request.Headers.Add(X_Request_With, com_mihoyo_hyperion); + request.Headers.Add(x_rpc_app_version, AppVersion); + request.Headers.Add(x_rpc_client_type, "5"); + request.Headers.Add(Referer, "https://webstatic.mihoyo.com/"); + var data = await CommonSendAsync(request, cancellationToken); + data.List?.ForEach(x => x.Cookie = cookie); + return data.List ?? new List(); + } + + #endregion } From f2056a6fdf5e4792a66c9a2eddb8cb26564f0f8d Mon Sep 17 00:00:00 2001 From: hina Date: Sat, 17 Aug 2024 07:40:44 +0900 Subject: [PATCH 3/5] Show ZZZ BattleChronicle menu --- src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml.cs | 5 +++++ src/Starward/Pages/MainPage.xaml.cs | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml.cs b/src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml.cs index ebb20d977..b10fa59b1 100644 --- a/src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml.cs +++ b/src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml.cs @@ -225,6 +225,11 @@ private void InitializeNavigationViewItemVisibility() // 閾侀亾鎴樼哗鍥剧墖 Image_BattleChronicle.Source = new BitmapImage(new("ms-appx:///Assets/Image/ade9545750299456a3fcbc8c3b63521d_2941971308029698042.png")); } + + if (CurrentGameBiz.ToGame() is GameBiz.ZZZ) + { + NavigationViewItem_BattleChronicle.Visibility = Visibility.Visible; + } } diff --git a/src/Starward/Pages/MainPage.xaml.cs b/src/Starward/Pages/MainPage.xaml.cs index 477da65ab..d031d0fcf 100644 --- a/src/Starward/Pages/MainPage.xaml.cs +++ b/src/Starward/Pages/MainPage.xaml.cs @@ -534,7 +534,7 @@ private void UpdateNavigationViewItemsText() NavigationViewItem_GameSetting.Visibility = Visibility.Visible; NavigationViewItem_Screenshot.Visibility = Visibility.Visible; NavigationViewItem_GachaLog.Visibility = Visibility.Visible; - NavigationViewItem_HoyolabToolbox.Visibility = Visibility.Collapsed; + NavigationViewItem_HoyolabToolbox.Visibility = Visibility.Visible; NavigationViewItem_SelfQuery.Visibility = Visibility.Visible; } else @@ -624,8 +624,7 @@ public void NavigateTo(Type? page, object? param = null, NavigationTransitionInf { string? destPage = page?.Name; if (destPage is null or nameof(BlankPage) - || (CurrentGameBiz.ToGame() is GameBiz.Honkai3rd && destPage is not nameof(GameLauncherPage) and not nameof(GameSettingPage) and not nameof(ScreenshotPage)) - || CurrentGameBiz.ToGame() is GameBiz.ZZZ && destPage is not nameof(GameLauncherPage) and not nameof(GameSettingPage) and not nameof(GachaLogPage) and not nameof(ScreenshotPage) and not nameof(SelfQueryPage)) + || (CurrentGameBiz.ToGame() is GameBiz.Honkai3rd && destPage is not nameof(GameLauncherPage) and not nameof(GameSettingPage) and not nameof(ScreenshotPage))) { page = typeof(GameLauncherPage); destPage = nameof(GameLauncherPage); From 6cde37615a9416a2186af27b5c24733209ed98b4 Mon Sep 17 00:00:00 2001 From: hina Date: Sat, 17 Aug 2024 20:39:25 +0900 Subject: [PATCH 4/5] Use mobile URL --- src/Starward/Controls/BBSWebBridge.xaml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Starward/Controls/BBSWebBridge.xaml.cs b/src/Starward/Controls/BBSWebBridge.xaml.cs index 7c6cd1aa8..f61f25ae1 100644 --- a/src/Starward/Controls/BBSWebBridge.xaml.cs +++ b/src/Starward/Controls/BBSWebBridge.xaml.cs @@ -168,10 +168,10 @@ public async Task LoadPageAsync(bool force = false) { (true, GameBiz.GenshinImpact) => "https://act.hoyolab.com/app/community-game-records-sea/m.html?gid=2", (true, GameBiz.StarRail) => "https://act.hoyolab.com/app/community-game-records-sea/m.html?gid=6", - (true, GameBiz.ZZZ) => "https://act.hoyolab.com/app/mihoyo-zzz-game-record/index.html", + (true, GameBiz.ZZZ) => "https://act.hoyolab.com/app/mihoyo-zzz-game-record/m.html", (false, GameBiz.GenshinImpact) => "https://webstatic.mihoyo.com/app/community-game-records/?game_id=2", (false, GameBiz.StarRail) => "https://webstatic.mihoyo.com/app/community-game-records/?game_id=6", - (false, GameBiz.ZZZ) => "https://act.mihoyo.com/app/mihoyo-zzz-game-record/index.html", + (false, GameBiz.ZZZ) => "https://act.mihoyo.com/app/mihoyo-zzz-game-record/m.html", _ => null, }; if (url is not null) From efe518829704f80e95a81a036ba5ea5802956f27 Mon Sep 17 00:00:00 2001 From: hina Date: Fri, 13 Sep 2024 00:05:30 +0900 Subject: [PATCH 5/5] fix: revert Garbled thanks https://github.com/Scighost/Starward/pull/1038#discussion_r1756667700 --- src/Starward/Controls/BBSWebBridge.xaml.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Starward/Controls/BBSWebBridge.xaml.cs b/src/Starward/Controls/BBSWebBridge.xaml.cs index f61f25ae1..5f45bbc14 100644 --- a/src/Starward/Controls/BBSWebBridge.xaml.cs +++ b/src/Starward/Controls/BBSWebBridge.xaml.cs @@ -645,19 +645,19 @@ private static string GetRandomString(int timestamp) private class JsParam { /// - /// 锟斤拷锟斤拷锟斤拷锟斤拷 + /// 鏂规硶鍚嶇О /// [JsonPropertyName("method")] public string Method { get; set; } /// - /// 锟斤拷锟斤拷 锟斤拷锟斤拷为锟斤拷 + /// 鏁版嵁 鍙互涓虹┖ /// [JsonPropertyName("payload")] public JsonNode? Payload { get; set; } /// - /// 锟截碉拷锟斤拷锟斤拷锟狡o拷锟斤拷锟斤拷 JavaScript:mhyWebBridge 时锟斤拷为锟阶革拷锟斤拷锟斤拷锟斤拷锟斤拷 + /// 鍥炶皟鐨勫悕绉帮紝璋冪敤 JavaScript:mhyWebBridge 鏃朵綔涓洪涓弬鏁颁紶鍏 /// [JsonPropertyName("callback")] public string? Callback { get; set; } @@ -668,19 +668,19 @@ private class JsParam private class JsResult { /// - /// 锟斤拷锟斤拷 + /// 浠g爜 /// [JsonPropertyName("retcode")] public int Code { get; set; } /// - /// 锟斤拷息 + /// 娑堟伅 /// [JsonPropertyName("message")] public string Message { get; set; } = string.Empty; /// - /// 锟斤拷锟斤拷 + /// 鏁版嵁 /// [JsonPropertyName("data")] public Dictionary Data { get; set; } = default!;