private async void WebView1_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args) { if (args.Uri == null) { return; } Uri uri = args.Uri; //"https://accounts.google.com/o/oauth2/approval?as=42e3cc68d2e8ee44&hl=en&pageId=116799181908485949488&xsrfsign=APsBz4gAAAAAVfZ7BqYyX618a7CCGUbeL4zq9ZInja2m" try { string title = await WebView1.InvokeScriptAsync("eval", new string[] { "document.title;" }); string src = await WebView1.InvokeScriptAsync("eval", new string[] { "document.documentElement.outerHTML;" }); if (title.Contains("Success code=")) { string code = title.Replace("Success code=", ""); PrimeTube.YouTube.YoutubeService.ExchangeAuthorizationToken(code); } } catch { } }
private async void 退出_Click(object sender, RoutedEventArgs e) { var exit = string.Format(@"document.querySelectorAll('a[href*=""action=logout""]')[0].href;"); string result = await WebView1.InvokeScriptAsync("eval", new string[] { exit }); WebView1.Source = new Uri(result); BitmapImage bitmapImage = new BitmapImage(new Uri(this.BaseUri, "TopbarICON/默认头像.jpg")); Avatar.ImageSource = bitmapImage; SmallNew.Visibility = (Visibility)1; UserLVL.ClearValue(Image.SourceProperty); UserName.Text = "游客"; LPBtn.Visibility = (Visibility)1; 获取列表1.Visibility = (Visibility)1; TheAPPFrame.Content = null; if (await CheckLoadState(true) == 0) { ShowNotifi("您已成功退出,现在返回主界面"); } await Task.Delay(1000); 退出.Visibility = (Visibility)1; await Task.Delay(1000); LPLogin.Visibility = 0; }
private async void Z返回_Click(object sender, RoutedEventArgs e) { var zh = string.Format(@"document.getElementsByClassName('tipcol')[1].getElementsByTagName('a')[0].onclick();"); await WebView1.InvokeScriptAsync("eval", new string[] { zh }); p1.Visibility = 0; p2.Visibility = (Visibility)1; }
public async Task <string> LoginFun() { await Task.Delay(1000); var checkStatus = string.Format(@"document.querySelectorAll('.alert_right').length.toString();"); string status = await WebView1.InvokeScriptAsync("eval", new string[] { checkStatus }); if (status != "0") { RegLoginPage.Visibility = (Visibility)1; 退出.Visibility = 0; LPLogin.Visibility = (Visibility)1; WebView1.Source = new Uri("http://i.pcbeta.com/home.php?mod=space&do=profile&mobile=no"); if (await CheckLoadState(true) != 0) { LoginBtn.IsEnabled = true; return(""); } await Task.Delay(2000); 获取列表1.Visibility = 0; ShowNotifi("登陆成功!欢迎您!"); LoginEvent(); LPAvatar.Visibility = 0; } else { checkStatus = string.Format(@"document.querySelectorAll('.alert_error').length.toString();"); status = await WebView1.InvokeScriptAsync("eval", new string[] { checkStatus }); if (status != "0") { var xxxx = string.Format(@"document.querySelector('.alert_error').innerText;"); Error3.Text = await WebView1.InvokeScriptAsync("eval", new string[] { xxxx }); } else { checkStatus = string.Format(@"document.querySelectorAll('.alert_info').length.toString();"); status = await WebView1.InvokeScriptAsync("eval", new string[] { checkStatus }); if (status != "0") { var xxxx = string.Format(@"document.querySelector('.alert_info').innerText;"); ShowNotifi(await WebView1.InvokeScriptAsync("eval", new string[] { xxxx })); // } else { await LoginFun(); } } } return(""); }
private async Task <bool> InitiliazeScript() { string xxx = await WebView1.InvokeScriptAsync("EmlakFunc"); if (string.IsNullOrEmpty(xxx)) { return(true); } return(false); }
private async void Z发送_Click(object sender, RoutedEventArgs e) { try { var zh1 = string.Format(@"document.getElementById('lostpw_username').value='{0}';", z用户名.Text); var zh2 = string.Format(@"document.getElementById('lostpw_email').value='{0}';", z邮箱.Text); var zh3 = string.Format(@"document.getElementsByName('lostpwsubmit')[0].click();"); await WebView1.InvokeScriptAsync("eval", new string[] { zh1 + zh2 + zh3 }); await Task.Delay(1000); await FindResult(); } catch (Exception) { ShowNotifi("发送失败,请稍后重试"); } }
private async void LPLogin_Click(object sender, RoutedEventArgs e) { APPLeftPanel.IsPaneOpen = false; try { if (WebView1.Source != new Uri("http://i.pcbeta.com/home.php?mod=space&do=profile&mobile=no")) { WebView1.Source = new Uri("http://i.pcbeta.com/home.php?mod=space&do=profile&mobile=no"); if (await CheckLoadState(true) != 0) { return; } } var send = string.Format(@"document.getElementById('toptb').innerText;"); string ardy = await WebView1.InvokeScriptAsync("eval", new string[] { send }); if (ardy.Contains("退出")) { LoginEvent(); LPLogin.Visibility = (Visibility)1; 退出.Visibility = 0; if (APPLeftPanel.IsPaneOpen) { LPBtn.Visibility = 0; } 获取列表1.Visibility = 0; } else { RegLoginPage.Visibility = 0; LPAvatar.Visibility = (Visibility)1; LPLogin.Visibility = (Visibility)1; } } catch (Exception) { WebView1.Source = new Uri("http://i.pcbeta.com/home.php?mod=space&do=profile&mobile=no"); ShowNotifi("请稍后再试"); } }
public async void LoginEvent() { await Task.Delay(1000); try { var value1 = string.Format(@"document.getElementsByClassName('xw1')[0].innerText;"); UserName.Text = await WebView1.InvokeScriptAsync("eval", new string[] { value1 }); } catch (Exception) { } for (int i = 0; i < 30; i++) { try { var txicon = string.Format(@"document.getElementById('pcd').getElementsByTagName('img')[0].src;"); TempAvatarURL = await WebView1.InvokeScriptAsync("eval", new string[] { txicon }); var gicon = string.Format(@"document.getElementsByClassName('vm')[1].src;"); TempLVLURL = await WebView1.InvokeScriptAsync("eval", new string[] { gicon }); RefreshMessage gx = new RefreshMessage(); gx.CheckNewMessage(); G1(); break; } catch (Exception) { } if (i == 29) { ShowNotifi("头像获取失败,请稍后再试"); } await Task.Delay(1000); } ShowNotifi("登陆成功,欢迎您回来!"); }
public async Task <string> FindResult() { await Task.Delay(1000); var zhc = string.Format(@"document.getElementById('append_parent').innerText;"); string zhStr = await WebView1.InvokeScriptAsync("eval", new string[] { zhc }); if (zhStr.Contains("取回密码的方法")) { ShowNotifi("找回密码的邮件已发送至 " + z邮箱.Text + " 请注意查收. 找回密码"); } else if (zhStr.Contains("您填写的账户资料不匹配")) { ShowNotifi("您填写的账户资料不匹配,请仔细检查后重试. 找回密码"); } else { await FindResult(); } return(""); }
public async void FirstLoad() { await Task.Delay(1000); try { var login = string.Format(@"document.getElementById('toptb').innerText;"); string result = await WebView1.InvokeScriptAsync("eval", new string[] { login }); if (result.Contains("登录")) { TopBtn.Visibility = 0; return; } } catch (Exception) { TopBtn.Visibility = 0; ShowNotifi("网络连接异常!请检查您的网络. 错误"); return; } ShowNotifi("正在登陆...请稍后"); await Task.Delay(1000); LoginEvent(); TopBtn.Visibility = 0; 退出.Visibility = 0; LPLogin.Visibility = (Visibility)1; if (APPLeftPanel.IsPaneOpen) { LPBtn.Visibility = 0; } 获取列表1.Visibility = 0; }
private async void WebView1_LoadCompleted(object sender, NavigationEventArgs e) { await WebView1.InvokeScriptAsync("updateData", new string[] { "2", "2", "2", "2", "2", "2" }); }
private async void Login_Click(object sender, RoutedEventArgs e) { Error3.Text = ""; Error1.Visibility = (Visibility)1; Error2.Visibility = (Visibility)1; if (string.IsNullOrEmpty(Username.Text) | string.IsNullOrWhiteSpace(Username.Text)) { Error1.Visibility = 0; return; } if (string.IsNullOrEmpty(UPassword.Password) | string.IsNullOrWhiteSpace(UPassword.Password)) { Error2.Visibility = 0; return; } LoginBtn.IsEnabled = false; try { var checkLogin = string.Format(@"document.getElementById('ct').innerText;"); string result = await WebView1.InvokeScriptAsync("eval", new string[] { checkLogin }); if (result.Contains("多次输入密码错误")) { ShowNotifi("因为多次输入错误的密码,您的IP已被封禁30分钟,请之后再尝试登陆"); LoginBtn.IsEnabled = true; RegLoginPage.Visibility = (Visibility)1; LPAvatar.Visibility = 0; LPLogin.Visibility = 0; return; } var send1 = string.Format(@"document.getElementsByTagName('input')[2].value='{0}';", Username.Text); var send2 = string.Format(@"document.getElementsByTagName('input')[3].value='{0}';", UPassword.Password); var send3 = ""; if (RememberPass.IsChecked == true) { send3 = string.Format(@"document.getElementsByName('cookietime')[0].checked=1;"); } else { send3 = string.Format(@"document.getElementsByName('cookietime')[0].checked=0;"); } var send4 = ""; if (QuestionCheck.IsChecked == true) { send4 = string.Format(@"document.getElementsByName('questionid')[0].selectedIndex={0};", QuestionBox.SelectedIndex) + string.Format(@"document.getElementsByName('answer')[0].innerText='{0}';", QuestionAnswer.Text); } var send5 = string.Format(@"document.getElementsByName('loginsubmit')[0].click();"); await WebView1.InvokeScriptAsync("eval", new string[] { send1 + send2 + send3 + send4 + send5 }); await LoginFun(); } catch (Exception) { } LoginBtn.IsEnabled = true; }