private void HandleClickedEvent(object sender, EventArgs args)
        {
            switch (sender)
            {
            case Button bt:
                switch (bt)
                {
                case var b when b.Equals(ButtonEnterPage):
                    WebView1.Source = EntryEndereco.Text;

                    break;

                case var b when b.Equals(ButtonBack):
                    if (WebView1.CanGoBack)
                    {
                        WebView1.GoBack();
                    }
                    break;

                case var b when b.Equals(ButtonNext):
                    if (WebView1.CanGoForward)
                    {
                        WebView1.GoForward();
                    }
                    break;
                }
                break;

            default:
                break;
            }
        }
        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 { }
        }
Ejemplo n.º 3
0
        async Task DeleteTags(string url)
        {
            //Create an HTTP client object
            Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient();

            //Send the GET request asynchronously and retrieve the response as a string.
            Windows.Web.Http.HttpResponseMessage httpResponse = new Windows.Web.Http.HttpResponseMessage();
            string httpResponseBody = "";

            try
            {
                //Send the GET request
                httpResponse = await httpClient.GetAsync(new Uri(url));

                httpResponse.EnsureSuccessStatusCode();
                httpResponseBody = await httpResponse.Content.ReadAsStringAsync();

                //Hidde some tags
                httpResponseBody = Regex.Replace(httpResponseBody, "div id=\"YDC-UH\"", "div id=\"YDC-UH\" hidden");
                httpResponseBody = Regex.Replace(httpResponseBody, "<div id=\"YDC-Side-Stack\"", "<div id=\"YDC-Side-Stack\" hidden");
                httpResponseBody = Regex.Replace(httpResponseBody, "<div class=\"c", "<div hidden class=\"c");
                httpResponseBody = Regex.Replace(httpResponseBody, "<div id=\"YDC-Bottom\" ", "<div id=\"YDC-Bottom\" hidden ");
                //httpResponseBody = Regex.Replace(httpResponseBody, "<button class=\"D.ib.", "<button hidden class=\"D.ib.");
            }
            catch (Exception ex)
            {
                httpResponseBody =
                    "<!DOCTYPE html> <html> <head> <link href=\"https://fonts.googleapis.com/css?family=Roboto\" rel=\"stylesheet\"> </head> <body style=\"background-color:BlueViolet;\"> <div style=\"width: 300px; height: 300px; position: absolute; left: 50%; top: 50%; margin-left: -150px; margin-top: -150px;\"><center><font color=\"white\"><h1 style=\"font-family: 'Roboto', sans-serif;\">" +
                    "</ h1 ></ font ></ center ></ div > </ body > </ html > " + "Error: " + ex.HResult.ToString("X") +
                    " Message: " + ex.Message.TrimEnd() + ".";
            }
            WebView1.NavigateToString(httpResponseBody);
        }
Ejemplo n.º 4
0
        private void WebView1_OnPermissionRequested(object sender, WebViewControlPermissionRequestedEventArgs e)
        {
            if (e.PermissionRequest.State == WebViewControlPermissionState.Allow)
            {
                return;
            }

            var msg = $"Allow {e.PermissionRequest.Uri.Host} to access {e.PermissionRequest.PermissionType}?";

            var response = MessageBox.Show(msg, "Permission Request", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes);

            if (response == MessageBoxResult.Yes)
            {
                if (e.PermissionRequest.State == WebViewControlPermissionState.Defer)
                {
                    WebView1.GetDeferredPermissionRequestById(e.PermissionRequest.Id)?.Allow();
                }
                else
                {
                    e.PermissionRequest.Allow();
                }
            }
            else
            {
                if (e.PermissionRequest.State == WebViewControlPermissionState.Defer)
                {
                    WebView1.GetDeferredPermissionRequestById(e.PermissionRequest.Id)?.Deny();
                }
                else
                {
                    e.PermissionRequest.Deny();
                }
            }
        }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
        public void OpenPaymentStart(string id, string summ)
        {
            WebView1.Hidden = false;
            var url = "http://z98950oc.beget.tech/ETApi/pay.php?id=" + id + "&summ=" + summ; // NOTE: https secure request

            WebView1.LoadRequest(new NSUrlRequest(new NSUrl(url)));
        }
Ejemplo n.º 7
0
 private void backButton_Tapped(object sender, BackRequestedEventArgs e)
 {
     if (WebView1.CanGoBack)
     {
         WebView1.GoBack();
     }
 }
Ejemplo n.º 8
0
 private void FrameBackBtn_Click(object sender, RoutedEventArgs e)
 {
     if (TheAPPFrame.CanGoBack)
     {
         TheAPPFrame.GoBack();
         WebView1.GoBack();
     }
 }
Ejemplo n.º 9
0
 private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (ListView.SelectedItem != null)
     {
         FeedItem item = (FeedItem)ListView.SelectedItem;
         WebView1.Navigate(new Uri(item.Link));
     }
 }
Ejemplo n.º 10
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;
        }
Ejemplo n.º 11
0
        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("");
        }
Ejemplo n.º 12
0
        private async Task <bool> InitiliazeScript()
        {
            string xxx = await WebView1.InvokeScriptAsync("EmlakFunc");

            if (string.IsNullOrEmpty(xxx))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 13
0
        private void btnShowTweet_Click(object sender, RoutedEventArgs e)
        {
            Button el        = (Button)sender;
            string link      = ((Button)sender).CommandParameter.ToString();
            Uri    targetUri = new Uri(link);

            WebView1.Navigate(targetUri);
            Uri targetUri2 = new Uri(link);

            WebView2.Navigate(targetUri2);
        }
Ejemplo n.º 14
0
        private async void TextBox_KeyUp(object sender, KeyRoutedEventArgs e)
        {
            if (e.Key == Windows.System.VirtualKey.Enter)
            {
                string   order        = textBox.Text;
                string[] Parsed_Order = order.Split(' ');
                int      cnt          = 0;
                string   returnValue  = "";


                textBox.Text = "";
                if (order.Contains("노래"))
                {
                    foreach (var music in MusicLoader.MusicDB)
                    {
                        if (cnt <= 10)
                        {
                            if (music.Emotion.Contains(Parsed_Order[0]))
                            {
                                cnt++;
                                returnValue += $" {music.Title} - {music.Singer}, {music.Emotion} \r\n";
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else if (order.Contains("유튜브"))
                {
                    WebView1.Navigate(new Uri("https://www.youtube.com/watch?v=" + Parsed_Order[0]));
                    WebView1.Visibility = Visibility.Visible;
                }
                try
                {
                    SpeechSynthesisStream synthesisStream = await synthesizer.SynthesizeTextToStreamAsync(returnValue);

                    // Set the source and start playing the synthesized audio stream.
                    media.AutoPlay = true;
                    media.SetSource(synthesisStream, synthesisStream.ContentType);
                    media.Play();
                }
                catch (Exception)
                {
                }
                ContentDialog c = new ContentDialog()
                {
                    Content = returnValue
                };
                await c.ShowAsync();
            }
        }
Ejemplo n.º 15
0
 private void NavigateToUrl(string urlStr)
 {
     try
     {
         var uri = new Uri(urlStr);
         WebView1.Navigate(uri);
     }
     catch (FormatException e)
     {
         Debug.WriteLine(String.Format("URL is invalid, try again.  Details --> {0}", e.Message));
     }
 }
Ejemplo n.º 16
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            //yt vid
            NSUrl videoURL = new NSUrl(@"https://www.youtube.com/embed/WL2l_Q1AR_Q");

            string htmlString = "<html>" +
                                "<body>" +
                                "<iframe width=\"100\"  height=\"100\" src=\"https://www.youtube.com/embed/WL2l_Q1AR_Q\" allowfullscreen</iframe>" +
                                "</body>" +
                                "</html>";

            WebView1.LoadHtmlString(htmlString, videoURL);

            //Images not interactable
            Image1.UserInteractionEnabled = false;
            Image2.UserInteractionEnabled = false;

            Button1.TouchDown += (object sender, EventArgs e) =>
            {
                //ALERT
                UIAlertView alert = new UIAlertView()
                {
                    Title   = "Button1 Alert",
                    Message = "You clicked button 1."
                };

                alert.AddButton("OK");
                alert.Show();
            };

            Button2.TouchDown += (object sender, EventArgs e) =>
            {
                //ALERT
                UIAlertView alert = new UIAlertView()
                {
                    Title   = "Button2 Alert",
                    Message = "You clicked button 2."
                };

                alert.AddButton("OK");
                alert.Show();

                //PLAY ABC SONG
                //url = NSUrl.FromFilename("Sounds/mysound.mp3");
                //mySound = new SystemSound(url);
                //mySound.PlaySystemSound();
            };
        }
Ejemplo n.º 17
0
        public MainPage()
        {
            this.InitializeComponent();



            //            [0,-0,0,0,0,3 ],
            //[1,-1,1,2,1,6 ],
            //[2,-2,4,4,0.5,2],
            //[3,-3,9,6,0.33,4],
            //[4, -4, 16, 8, 0.25, 9],
            //["hello", "a", "b", "c", "d", "e", "a"]
            //JavaScriptSerializer ser = new JavaScriptSerializer();

            WebView1.Navigate(new Uri("ms-appx-web:///Assets/ParallelCoordinates2.html"));
            WebView1.LoadCompleted += WebView1_LoadCompleted;
        }
Ejemplo n.º 18
0
        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("发送失败,请稍后重试");
            }
        }
Ejemplo n.º 19
0
        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("请稍后再试");
            }
        }
Ejemplo n.º 20
0
        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("登陆成功,欢迎您回来!");
        }
Ejemplo n.º 21
0
        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("");
        }
Ejemplo n.º 22
0
        /// <summary>
        /// This is the click handler for the 'Navigation' button.  You would replace this with your own handler
        /// if you have a button or buttons on this page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NavigateButton_Click(object sender, RoutedEventArgs e)
        {
            ProgressRing1.IsActive = true;

            // Provide an indication as to where we are trying to navigate to
            rootPage.NotifyUser(String.Format("Navigating to: {0}", Address.Text), NotifyType.StatusMessage);

            // Hook the LoadCompleted event for the WebView to know when the URL is fully loaded
            WebView1.LoadCompleted += new Windows.UI.Xaml.Navigation.LoadCompletedEventHandler(WebView1_LoadCompleted);

            // Attempt to navigate to the specified URL.  Notice that a malformed URL will raise a FormatException
            // which we catch and let the user know that the URL is bad and to enter a new well-formed one.
            try
            {
                Uri targetUri = new Uri(Address.Text);
                WebView1.Navigate(targetUri);
            }
            catch (FormatException myE)
            {
                // Bad address
                rootPage.NotifyUser(String.Format("Address is invalid, try again.  Details --> {0}", myE.Message), NotifyType.ErrorMessage);
            }
        }
Ejemplo n.º 23
0
        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;
        }
Ejemplo n.º 24
0
        private void btnShowTweet_Click(object sender, RoutedEventArgs e)
        {
            Button el        = (Button)sender;
            string link      = ((Button)sender).CommandParameter.ToString();
            Uri    targetUri = new Uri(link);

            WebView1.Navigate(targetUri);
            WebView2.Navigate(targetUri);

            string ee;

            ItemListView_SelectionChanged(null, null);

            int i = 0;

            foreach (var rectangle in FindVisualChildren <Button>(itemListView))
            {
                i++;
                if (rectangle.CommandParameter.ToString() == link)
                {
                    itemListView.SelectedIndex = i;
                }
            }
        }
Ejemplo n.º 25
0
        private void InitiliazeScriptNonAsync()
        {
            string result = WebView1.InvokeScript("EmlakFunc");

            MessageBox.Show(result);
        }
Ejemplo n.º 26
0
 private async void WebView1_LoadCompleted(object sender, NavigationEventArgs e)
 {
     await WebView1.InvokeScriptAsync("updateData", new string[] { "2", "2", "2", "2", "2", "2" });
 }
Ejemplo n.º 27
0
 private void BrowseForward_OnExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     WebView1?.GoForward();
 }
Ejemplo n.º 28
0
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     WebView1.Navigate(new Uri("http://" + textBox1.Text));
 }
 private void ButtonNavigate_Click(object sender, RoutedEventArgs e)
 {
     WebView1.Navigate(new Uri(TextBoxWithURL.Text));
 }
Ejemplo n.º 30
0
        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;
        }