Exemplo n.º 1
0
        private async void WebView_DOMContentLoaded(WebView sender, WebViewDOMContentLoadedEventArgs args)
        {
            if (_mPageArgs != null)
            {
                string url = _mWebView.Source.ToString();
                if (url.StartsWith("https://www.twitch.tv/"))
                {
                    if (url.StartsWith("https://www.twitch.tv/login"))
                    {
                    }
                    else
                    {
                        //invoke callback and close window
                        if (_mPageArgs.OnComplete != null)
                        {
                            string html = await _mWebView.InvokeScriptAsync("eval", new string[] { "document.documentElement.outerHTML;" });

                            await _mPageArgs.OnComplete(html);
                        }
                        _mPageArgs = null;
                        Window.Current.Close();
                    }
                }
                else
                {
                    if (url.StartsWith(_mPageArgs.EndUrl))
                    {
                        if (_mPageArgs.OnComplete != null)
                        {
                            string html = await _mWebView.InvokeScriptAsync("eval", new string[] { "document.documentElement.outerHTML;" });

                            await _mPageArgs.OnComplete(html);

                            _mPageArgs = null;
                            Window.Current.Close();
                        }
                    }
                }
            }
        }