Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Failed captcha challenge hint
Browse files Browse the repository at this point in the history
  • Loading branch information
Azure99 committed Jul 3, 2023
1 parent 982479a commit 1f5b750
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/View/CaptchaWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GenshinPlayerQuery.View"
mc:Ignorable="d"
Title="CaptchaWindow" Height="600" Width="400" Closed="Window_Closed">
Title="验证码" Height="500" Width="350" Closed="Window_Closed" Closing="Window_Closing">
<Grid>
<Wpf:WebView2 Name="WebViewCaptcha" CoreWebView2InitializationCompleted="WebViewCaptcha_CoreWebView2InitializationCompleted" NavigationStarting="WebViewCaptcha_NavigationStarting" />
</Grid>
Expand Down
30 changes: 20 additions & 10 deletions src/View/CaptchaWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,46 @@ namespace GenshinPlayerQuery.View
/// </summary>
public partial class CaptchaWindow : Window
{
private string challenge;
private string gt;
private string _challenge;
private string _gt;
private bool _verifySuccessful;

public CaptchaWindow(string challenge, string gt)
{
InitializeComponent();
MessageBus.CaptchaWindow = this;
WebViewCaptcha.EnsureCoreWebView2Async();
this.challenge = challenge;
this.gt = gt;
}

private void Window_Closed(object sender, EventArgs e)
{
WebViewCaptcha.Dispose();
_challenge = challenge;
_gt = gt;
}

private void WebViewCaptcha_CoreWebView2InitializationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e)
{
WebViewCaptcha.CoreWebView2.Navigate($"https://www.rainng.com/ser/soft/genshin-player-query/static/geetest/v1/?challenge={challenge}&gt={gt}");
WebViewCaptcha.CoreWebView2.Navigate($"https://www.rainng.com/ser/soft/genshin-player-query/static/geetest/v1/?challenge={_challenge}&gt={_gt}");
}

private void WebViewCaptcha_NavigationStarting(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs e)
{
Uri uri = new Uri(e.Uri);
if (uri.Host == "rainng")
{
_verifySuccessful = true;
NameValueCollection result = HttpUtility.ParseQueryString(uri.Query);
MessageBus.AfterCaptchaChallengeSuccessful(result["geetest_challenge"], result["geetest_validate"], result["geetest_seccode"]);
}
}

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (!_verifySuccessful)
{
MessageBus.AfterCaptchaChallengeFailed();
}
}

private void Window_Closed(object sender, EventArgs e)
{
WebViewCaptcha.Dispose();
}
}
}

0 comments on commit 1f5b750

Please sign in to comment.