Пример #1
0
 private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     this.Left = 0;
     this.Top = 0;
     this.Width = this.ParentForm.Width;
     this.Height = this.ParentForm.Height-50;
 }
Пример #2
0
        private async void AuthenticationBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            // Get the currently displayed URL and show it in the textbox
            CurrentUrlTextBox.Text = e.Url.ToString();            

            // Check if the current URL contains the authorization token
            AuthorizationCodeTextBox.Text = OneDriveApi.GetAuthorizationTokenFromUrl(e.Url.ToString());


            // Verify if an authorization token was successfully extracted
            if (!string.IsNullOrEmpty(AuthorizationCodeTextBox.Text))
            {
                // Get an access token based on the authorization token that we now have
                await OneDriveApi.GetAccessToken();
                if (OneDriveApi.AccessToken != null)
                {
                    // Show the access token information in the textboxes
                    AccessTokenTextBox.Text = OneDriveApi.AccessToken.AccessToken;
                    RefreshTokenTextBox.Text = OneDriveApi.AccessToken.RefreshToken;
                    AccessTokenValidTextBox.Text = OneDriveApi.AccessTokenValidUntil.HasValue ? OneDriveApi.AccessTokenValidUntil.Value.ToString("dd-MM-yyyy HH:mm:ss") : "Not valid";
                    
                    // Store the refresh token in the AppSettings so next time you don't have to log in anymore
                    _configuration.AppSettings.Settings["OneDriveApiRefreshToken"].Value = RefreshTokenTextBox.Text;
                    _configuration.Save(ConfigurationSaveMode.Modified);
                    return;
                }
            }

            // If we're on this page, but we didn't get an authorization token, it means that we just signed out, proceed with signing in again
            if (CurrentUrlTextBox.Text.StartsWith("https://login.live.com/oauth20_desktop.srf"))
            {
                var authenticateUri = OneDriveApi.GetAuthenticationUri("wl.offline_access wl.skydrive_update");
                AuthenticationBrowser.Navigate(authenticateUri);
            }
        }
        private async void WebBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            // Check if the current URL contains the authorization token
            var authorizationCode = OneDriveApi.GetAuthorizationTokenFromUrl(e.Url.ToString());

            // Verify if an authorization token was successfully extracted
            if (!string.IsNullOrEmpty(authorizationCode))
            {
                // Get an access token based on the authorization token that we now have
                await OneDriveApi.GetAccessToken();
                if (OneDriveApi.AccessToken != null)
                {
                    DialogResult = DialogResult.OK;
                    Close();
                    return;
                }
            }

            // If we're on this page, but we didn't get an authorization token, it means that we just signed out, proceed with signing in again
            if (e.Url.ToString().StartsWith(OneDriveApi.SignoutUri))
            {
                var authenticateUri = OneDriveApi.GetAuthenticationUri();
                WebBrowser.Navigate(authenticateUri);
            }
        }
        private void webBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            if (e.Url.AbsoluteUri.StartsWith(this.RedirectURL))
            {
                //http://localhost/#access_token=5dlpafwfntadj2cubro3vramcnp4c6&scope=user_read+user_subscriptions
                //{http://localhost/?error=access_denied&error_description=The+user+denied+you+access}
                var startIndex = e.Url.AbsoluteUri.IndexOf("#") + 1;
                var response = e.Url.AbsoluteUri.Substring(startIndex);

                var qs = System.Web.HttpUtility.ParseQueryString(response);

                var access_token = qs["access_token"];

                if (string.IsNullOrWhiteSpace(access_token))
                {
                    Application.Exit();
                    return;
                }

                var twitchAlerts = new Alerts(access_token, this.ClientId);

                this.Hide();
            }
            else if (e.Url.AbsoluteUri.StartsWith("https://api.twitch.tv/"))
            {
                this.Show();
            }
        }
 private void wbFacebookLogin_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     if (e.Url.PathAndQuery.Contains("desktopapp.php"))
     {
         DialogResult = DialogResult.OK;
     }
 }
Пример #6
0
 private void webBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     //System.Diagnostics.Debug.WriteLine("Navigated to: " + webBrowser1.Url.AbsoluteUri.ToString());
     // 브라우저의 html의 타이틀 값을 가져온다(이 타이틀에 code값이 적혀 있음)
     if(option == LoginOption.GoogleDrive)
     {
         this.Text = webBrowser1.Document.Title;
         if (this.webBrowser1.Document.Title.StartsWith(EndUrl))
         {
             // 타이틀에 적혀 있는 값을 필요한 부분만 잘라서 code에 저장
             this.code = AuthResult(webBrowser1.Document.Title);
             CloseWindow();
         }
     }
     else if(option == LoginOption.OneDrive)
     {
         if (this.webBrowser1.Url.AbsoluteUri.StartsWith(EndUrl))
         {
             string[] querparams = webBrowser1.Url.Query.TrimStart('?').Split('&');
             int index = querparams[0].IndexOf('=');
             querparams[0] = querparams[0].Substring(index+1, (querparams[0].Length - index)-1);
             this.code = querparams[0];
             CloseWindow();
         }
     }
     else if(option == LoginOption.DropBox)
     {
         if(webBrowser1.Document.GetElementById("auth-code") != null)
         {
             webBrowser1.Visible = false;
             this.code = webBrowser1.Document.GetElementById("auth-code").InnerText;
             CloseWindow();
         }
     }
 }
Пример #7
0
        private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            string urlFragment; // фрагмент параметров авторизации

            if (e.Url.AbsolutePath == "/blank.html") // Если абсолютный урл равен, то авторизация прошла
                urlFragment = webBrowser1.Url.Fragment;
            else
                urlFragment = ifLoadLogin();

            if (urlFragment.IndexOf("error") != -1 || urlFragment == "") // Если авторизация прошла с ошибкой
            {
                this.DialogResult = DialogResult.Cancel;
                return;
            }

            if (urlFragment.IndexOf("error") == -1) // Если нет ошибок, берём токен, время жизни и наш айди
            {
                vars.VARS.Token = urlFragment.Substring(14, urlFragment.IndexOf("&") - 14);
                urlFragment = urlFragment.Remove(0, urlFragment.IndexOf("&") + 1);
                vars.VARS.Expire = Convert.ToUInt32(urlFragment.Substring(11, urlFragment.IndexOf("&") - 11));
                urlFragment = urlFragment.Remove(0, urlFragment.IndexOf("&"));
                vars.VARS.Mid = Convert.ToUInt32(urlFragment.Substring(9, urlFragment.Length - 9));
            }

            this.DialogResult = DialogResult.OK; // Возвращаем сообщение об успехе
        }
Пример #8
0
        private void LoginBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            if (e.Url.ToString().Contains("#"))
            {
                string id="", expires="", token="", get=e.Url.ToString();
                try
                {
                    get = get.Split('#')[1]; //erase trash like http:
                    token = get.Split('&')[0].Split('=')[1]; //take string between = and &
                    expires = get.Split('=')[2].Split('&')[0]; //take expires_in=__&
                    id = get.Split('=')[3];//get user id, its 3 '='
                }
                catch { }

                this.si = new SessionInfo();
                this.si.AppId = this.AppId;
                this.si.Permissions = this.Permissions;
                this.si.Token = token;
                this.si.UserId = Convert.ToInt32(id);
                this.si.Expire = Convert.ToInt32(expires);

                this.LoginInfoReceived = true;
                this.Close();
            }
        }
Пример #9
0
 private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     if (Process.HasExited)
       {
     MessageBox.Show("WebServer did not start correctly. Exited with code: " + Process.ExitCode, "Error");
       }
 }
Пример #10
0
        private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            string responsed = e.Url.ToString();
            if (responsed.StartsWith("http://localhost/inverify"))
            {
                responsed = responsed.Replace("http://localhost/inverify?", "");
                string[] args = responsed.Split('&');
                foreach(string arg in args)
                {
                    string[] values  = arg.Split('=');
                    if(values[0] == "oauth_token")
                        oauth_token = values[1];

                    if(values[0] == "oauth_verifier")
                        oauth_verifier = values[1];
                }
            }

            if (oauth_token != null && oauth_verifier != null)
            {
                if (AuthorizeCompleted != null)
                {
                    AuthorizeCompleted(oauth_token, oauth_verifier);
                    oauth_token = null;
                    oauth_verifier = null;
                }
                tmrCloseCheck.Interval = 2000;
                tmrCloseCheck.Tick += new EventHandler(tmrCloseCheck_Tick);
                tmrCloseCheck.Start();
                ShowOfflienContent("Completed.htm");
            }
        }
Пример #11
0
 private void wbFacebookLogin_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     //if (e.Url.PathAndQuery.Contains("authorize.php") && e.Url.Fragment == "#")
     //{
     //    DialogResult = (_facebookService.HasPermission(_permission)) ? DialogResult.OK : DialogResult.Cancel;
     //}
 }
Пример #12
0
		private void browser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
		{

			//Console.WriteLine(e.Url);

			var pattern = @"code=([\d|a-zA-Z]*)";
			if (Regex.IsMatch(e.Url.Query, pattern))
			{
				panelMask.Visible = true;
				panelMask.BringToFront();
				var code = Regex.Match(e.Url.Query, pattern).Groups[1].Value;

				Task.Factory.StartNew(() =>
				{
					OpenAuth.GetAccessTokenByCode(code);
					UpdateUI(() =>
					{
						if (OpenAuth.IsAuthorized)
						{

							Code = code;
							this.DialogResult = System.Windows.Forms.DialogResult.OK;
							this.Close();

						}
						else
						{

							this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
							this.Close();
						}
					});
				});
			}
		}
Пример #13
0
        private async void OnNavigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            Debug.WriteLine("Navigated " + e.Url);

            // Pre-Authorization performed?
            if (m_isPreAuthorization)
            {
                m_isPreAuthorization = false;
                m_browser.Navigate(m_provider.AuthorizationUrl);
                return;
            }


            // we need to ignore all navigation that isn't to the redirect uri.
            if (!e.Url.ToString().StartsWith(m_provider.RedirectionUrl.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            try
            {
                var isOk = await m_provider.Claim(e.Url, m_browser.DocumentTitle);
                DialogResult = isOk ? DialogResult.OK : DialogResult.Cancel;
            }
            catch
            {
                DialogResult = DialogResult.Cancel;
            }
            finally
            {
                m_browser.Stop();
                Close();
            }
        }
Пример #14
0
 private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     try
     {
         Uri url = e.Url;
         if (url.AbsolutePath == "/blank.html")
         {
             var q = HttpUtility.ParseQueryString(url.Fragment.Substring(1));
             if (q["error"] != null)
             {
                 onError(q["error"], q["error_description"]);
             }
             else
             {
                 onSuccess(q["user_id"], q["access_token"]);
             }
             Hide();
             var timer = new System.Threading.Timer(_ =>
             {
                 Close();
             }, null, 10000, Timeout.Infinite);
         }
     }
     catch (Exception ex)
     {
         onError(ex.Message, "");
     }
 }
 private void browser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     lblLoading.Visible = false;
     txtHtmlView.Text = browser.DocumentText;
     IHTMLDocument2 doc2 = browser.Document.DomDocument as IHTMLDocument2;
     //            doc2.designMode = "On";
 }
Пример #16
0
        private void LoginBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            if (e.Url.ToString().Contains("#"))
            {
                Regex r = new Regex(@"\{(.*)\}");
                string[] json = r.Match(e.Url.ToString()).Value.Replace("{", "").Replace("}", "").Replace("\"", "").Split(',');
                Hashtable h = new Hashtable();
                foreach (string str in json)
                {
                    string[] kv = str.Split(':');
                    h[kv[0]] = kv[1];
                }

                this.si = new SessionInfo();
                this.si.AppId = this.AppId;
                this.si.Permissions = this.Permissions;
                this.si.MemberId = (string)h["mid"];
                this.si.SessionId = (string)h["sid"];
                this.si.Expire = Convert.ToInt32(h["expire"]);
                this.si.Secret = (string)h["secret"];
                this.si.Signature = (string)h["sig"];

                this.LoginInfoReceived = true;
                this.Close();
            }
        }
Пример #17
0
        void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
          
            if (e.Url.ToString().IndexOf("http://oauth.vk.com/blank.html") != -1)
            {
                var urlParams = HttpUtility.ParseQueryString(e.Url.Fragment.Substring(1));
                ACCESS_TOKEN = urlParams.Get("access_token");
                USER_ID = urlParams.Get("user_id");
                /*string uriString =
                       string.Format("https://api.vk.com/method/{0}.xml?oid={1}&access_token={2}",
                      "audio.get", "6811515", ACCESS_TOKEN);
                       webBrowser1.Navigate(uriString);*/
             request();
            }
         /*   if (e.Url.AbsolutePath.ToString().IndexOf("/method/audio.get.xml") != -1)
            {
                
                XmlDocument xd = new XmlDocument();

                xd.LoadXml(webBrowser1.DocumentText.ToString().Replace(" "," "));
                //XmlNodeList urls = xd.SelectNodes()
                //var document = xd.Load(webBrowser1.DocumentStream);
            }*/


            

        }
Пример #18
0
 private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     textBox2.Text = webBrowser1.DocumentTitle;
     toolStripStatusLabel1.Text = webBrowser1.StatusText;
     textBox3.Text = webBrowser1.Url.ToString();
     //toolStripProgressBar1.Value = webBrowser1.ProgressChanged;
 }
Пример #19
0
 private void Browser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     //tscbUrl.Text = getCurrentBrowser().Url.ToString();
     WebBrowser mybrowser = (WebBrowser)sender;
     XtraTabPage mypage = (XtraTabPage)mybrowser.Parent;
     //设置临时浏览器所在tab标题
     mypage.Text = mybrowser.DocumentTitle;
 }
Пример #20
0
 private void wbMain_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     if (!IsDisposed)
     {
         tstbURL.Text = e.Url.ToString();
         CheckCallback(e.Url.ToString());
     }
 }
Пример #21
0
 private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     if (webBrowser1.Url.ToString() == Url)
     {
         WindowState = FormWindowState.Normal;
     }
     else SaveData();
 }
		private void WebBrowserNavigated(object sender, WebBrowserNavigatedEventArgs e)
		{
			if (IsRedirected(e.Url))
			{
				AuthorizationUri = e.Url;
				Hide();
			}
		}
Пример #23
0
 void HandleNavigated(object sender, SWF.WebBrowserNavigatedEventArgs e)
 {
     UpdateDocumentRef();
     if (enableLoadingEvent)
     {
         ApplicationContext.InvokeUserCode(EventSink.OnLoading);
     }
 }
Пример #24
0
 /// <summary>
 /// This is called when the initial html/body framework is set up, 
 /// or when document.DocumentText is set.  At this point, the 
 /// document is editable.
 /// </summary>
 /// <param name="sender">sender</param>
 /// <param name="e">navigation args</param>
 void webBrowser1Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     setBackgroundColor(BackColor);
     if (Navigated != null)
     {
         Navigated(this, e);
     }
 }
 /// <summary>
 /// Required for support SAML logins
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     IOAuthResponse response;
     if (_authenticationHelper.IsComplete(e.Url, out response))
     {
         HandleOAuthResponse(response);
     }
 }
Пример #26
0
 private void webBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e) {
   exUrl = null;
   try {
     var parts = (webBrowser.Url.Fragment ?? "").Split(new char[] { '#', '@' }, StringSplitOptions.RemoveEmptyEntries);
     if (parts.Length < 5 || parts[4].EndsWith("/")) return;
     exUrl = parts[4]; 
   } finally { OkBtn.Enabled = exUrl!=null; }
 }
Пример #27
0
 /// <summary>
 /// 浏览导航以后触发事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void webBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     tSTBUrl.Text = e.Url.ToString();  
     if (Navigated != null)
     {
         Navigated(sender, e);
     }
 } 
Пример #28
0
 private void browser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     if (e.Url.AbsoluteUri.StartsWith(ApiAccepted))
     {
         // Lets get access token
         AuthService.AccessToken(new HyvesServicesCallback<AccessToken>(AccessTokenCallback));
     }
 }
Пример #29
0
 void HandleNavigated(object sender, SWF.WebBrowserNavigatedEventArgs e)
 {
     if (enableLoadingEvent)
     {
         ApplicationContext.InvokeUserCode(delegate {
             EventSink.OnLoading();
         });
     }
 }
Пример #30
0
        private void WebBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            if (!WebBrowser.DocumentTitle.Contains("Success code")) return;

            var authToken = _vns.ExtractAuthToken(WebBrowser.DocumentTitle);
            var oauthResponse = _vns.GetRequestTokens(authToken);
            _vns.SaveOauthResponse(oauthResponse);
            Close();
        }
Пример #31
0
 private void webBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     if (_isInitialized)
     {
         Program.Code = Regex.Match(webBrowser.Url.AbsoluteUri, "(?<=code=)[\\da-z]+").ToString();
         Close();
     }
     _isInitialized = true;
 }
 private void wbFacebookLogin_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     if(e.Url.PathAndQuery.StartsWith("/connect/login_success.html"))
     {
         DialogResult = DialogResult.OK;
         var sessionString = HttpUtility.ParseQueryString(e.Url.Query).Get("session");
         SessionProperties = JSONHelper.ConvertFromJSONAssoicativeArray(sessionString);
     }
 }
Пример #33
0
 void webBrowser1_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
 {
     //this.Text = "Navigated:" + e.Url.ToString();
     if (m_ExitURL != "")
     {
         if (e.Url.ToString().Contains(m_ExitURL))
         {
             this.Close();
         }
     }
 }
Пример #34
0
 /// <summary>
 /// 释放内存和显示url 更新的URL textboxaddress在导航。
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void wfBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
 {
     try
     {
         tbInput.Text = wfBrowser.Url.ToString();
         //LbTitle.Content = wfBrowser.Document.Title;
         IntPtr pHandle = GetCurrentProcess();
         SetProcessWorkingSetSize(pHandle, -1, -1);
     }
     finally
     {
         GC.Collect();
         GC.WaitForPendingFinalizers();
     }
 }
Пример #35
0
        private void WebBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            WebBrowser2 browser = sender as WebBrowser2;

            browser.ObjectForScripting = new WebPageCloseHandler(browser.Parent as TabPageWithWebBrowser);
            HtmlDocument doc = FindDocument(browser.Document, e.Url);

            if (doc != null)
            {
                WebBrowser2.AttachScript(doc.DomDocument as IHTMLDocument, AttachScript, HtmlElementInsertionOrientation.AfterBegin);
                if (opener != null)
                {
                    browser.Document.Cookie = opener.document.cookie;
                    browser.Document.InvokeScript("setOpener", new object[] { opener });
                }
            }
            this.Text = string.IsNullOrEmpty(browser.Document.Title) ? "未命名" : browser.Document.Title;
        }
 private void WebBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
 {
     WriteVerbose($"Navigated: {e.Url}");
 }
Пример #37
0
		protected virtual void OnNavigated(WebBrowserNavigatedEventArgs e)
		{
			throw null;
		}
Пример #38
0
 private void Browser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
 {
     Log($"Navigated: {e.Url}");
 }
Пример #39
0
        public static void SongRequestPlayer_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            Window.SongRequestPlayer.Navigated -= SongRequestPlayer_Navigated;
            if (CurrentSong == null && File.Exists(extension.GetDataPath() + "Songs.txt"))
            {
                foreach (string sSong in File.ReadAllLines(extension.GetDataPath() + "Songs.txt"))
                {
                    if (sSong != "" && (CurrentSong = GetSong(sSong.Split('|')[0])) != null)
                    {
                        CurrentSong.requester = sSong.Substring(sSong.LastIndexOf('|') + 1);
                        break;
                    }
                }
            }
            if (CurrentSong != null)
            {
                Console.WriteLine("test");
                //Window.SongRequestPlayer.Document.Write("<iframe id=\"musicPlayer\" type=\"text/html\" src=\"https://www.youtube.com/apiplayer?video_id=oOxPvmXNVtA&version=3&autoplay=1&enablejsapi=1&feature=player_embedded&controls=0&modestbranding=1&rel=0&showinfo=0&autohide=1&color=white&playerapiid=musicPlayer&iv_load_policy=3\" frameborder=\"0\" allowfullscreen>");
                //Window.SongRequestPlayer.Document.Write("<html><head><script type=\"text/javascript\">function TestScript() { outputID.innerHTML = \"Test\" } function Pause() { document.getElementById(\"popupVid\").getElementsByTagName(\"iframe\")[0].contentWindow;.postMessage(\"{\\\"event\\\":\\\"command\\\",\\\"func\\\":\\\"\"pauseVideo\"\\\",\\\"args\\\":\\\"\\\"}\", \"*\"); }</script></head><body><div id=\"outputID\" style=\"color:Red; font-size:16\">Hello from HTML document with script!</div><iframe id=\"musicPlayer\" type=\"text/html\" src=\"https://www.youtube.com/apiplayer?video_id=oOxPvmXNVtA&version=3&autoplay=1&enablejsapi=1&feature=player_embedded&controls=0&modestbranding=1&rel=0&showinfo=0&autohide=1&color=white&playerapiid=musicPlayer&iv_load_policy=3\" frameborder=\"0\" allowfullscreen></iframe></body></html>");
                // Window.SongRequestPlayer.Document.Write("<html><head><script type=\"text/javascript\">function TestScript() { outputID.innerHTML = \"Test\"; } function Pause() { outputID.innerHTML = \"Blah\"; func = 'pauseVideo'; document.getElementById(\"popupVid\").getElementsByTagName(\"iframe\")[0].contentWindow.postMessage('{\"event\":\"command\",\"func\":\"' + func + '\",\"args\":\"\"}','*'); }</script></head><body><div id=\"outputID\" style=\"color:Red; font-size:16\">Hello from HTML document with script!</div><div id=\"popupVid\" style=\"position:absolute;left:0px;top:87px;width:auto;background-color:#D05F27;height:auto;display:;z-index:200;\"><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/M7lc1UVf-VE?autoplay=1&controls=0&disablekb=1&enablejsapi=1&modestbranding=1&showinfo=0&autohide=1&color=white&iv_load_policy=3\" frameborder=\"0\" allowfullscreen></iframe><br><a href=\"javascript:void(0);\" onclick=\"Pause();\">Pause</a></div></body></html>");
                //Window.SongRequestPlayer.DocumentText = Properties.Resources.SongRequest.Replace("{VIDEOID}", CurrentSong.id);
                //Console.WriteLine(Properties.Resources.SongRequest);
                //Window.SongRequestPlayer.Document.Write(Properties.Resources.SongRequest.Replace("{VIDEOID}", CurrentSong.id));
                //Window.SongRequestPlayer.Document.Write("<html><head><script type=\"text/javascript\">function TestScript() { outputID.innerHTML = \"Test\" } function onYouTubePlayerReady(player) { outputID.innerHTML = \"Test\" } function Pause() { document.getElementById('ytplayer').pauseVideo(); }</script></head><body><div id=\"outputID\" style=\"color:Red; font-size:16\">Hello from HTML document with script!</div><iframe id=\"ytplayer\" type=\"text/html\" width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/M7lc1UVf-VE?autoplay=1&controls=0&disablekb=1&enablejsapi=1&modestbranding=1&showinfo=0&autohide=1&color=white&iv_load_policy=3\" frameborder=\"0\" allowfullscreen></iframe><a href=\"javascript:void(0);\" onclick=\"pause();\">Pause</a></body></html>");
                //Window.SongRequestPlayer.Document.Write("<object type=\"application/x-shockwave-flash\" data=\"https://www.youtube.com/apiplayer?video_id=lsE_J6yskQE&amp;version=3&amp;feature=player_embedded&amp;autoplay=1&amp;controls=0&amp;enablejsapi=1&amp;modestbranding=1&amp;rel=0&amp;showinfo=0&amp;autohide=1&amp;color=white&amp;playerapiid=musicPlayer&amp;iv_load_policy=3\" width=\"100%\" height=\"100%\" id=\"musicPlayer\" style=\"visibility: visible;\"><param name=\"allowScriptAccess\" value=\"always\"><param name=\"wmode\" value=\"transparent\"></object>");
                //Window.SongRequestPlayer.Refresh();
            }
            bool loaded = false;

            Window.SongRequestPlayer.DocumentCompleted += ((object s, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs eargs) =>
            {
                if (loaded)
                {
                    return;
                }
                loaded = true;
                Console.WriteLine("test2");
                Window.SongRequestPlayer.DocumentText = Properties.Resources.SongRequest.Replace("{VIDEOID}", CurrentSong.id);
                //Window.SongRequestPlayer.Document.Write(Properties.Resources.SongRequest.Replace("{VIDEOID}", CurrentSong.id));
                //Window.SongRequestPlayer.Refresh();
                new Thread(() =>
                {
                    Thread.Sleep(5000);
                    Window.BeginInvoke((MethodInvoker) delegate
                    {
                        //Window.SongRequestPlayer.Document.InvokeScript("TestScript");
                        Window.SongRequestPlayer.Document.InvokeScript("Pause");
                    });
                }).Start();
            });
            //EstimatedEnding = (TimeStarted = GetUnixTimeNow()) + (int)CurrentSong.duration.TotalSeconds + 1;
            //NextSongTimer.Change((int)CurrentSong.duration.TotalSeconds * 1000 + 1000, Timeout.Infinite);

            /*NextSongTimer.Change(5000, Timeout.Infinite);
             * bool found = false;
             * foreach (System.Windows.Forms.HtmlElement elem in Window.SongRequestPlayer.Document.All)
             * {
             *  Console.WriteLine(C:elem.Id);
             *  if (elem.Id == "musicPlayer")
             *  {
             *      found = true;
             *      Console.WriteLine("JACKPOT");
             *      elem.InvokeMember("javascript:pauseVideo()");
             *      elem.InvokeMember("javascript:pauseVideo();");
             *      elem.InvokeMember("javascript:player.pauseVideo()");
             *      elem.InvokeMember("javascript:player.pauseVideo();");
             *      elem.InvokeMember("javascript:musicPlayer.pauseVideo()");
             *      elem.InvokeMember("javascript:musicPlayer.pauseVideo();");
             *      Window.SongRequestPlayer.Navigate("javascript:pauseVideo()");
             *      Window.SongRequestPlayer.Navigate("javascript:pauseVideo();");
             *      Window.SongRequestPlayer.Navigate("javascript:player.pauseVideo()");
             *      Window.SongRequestPlayer.Navigate("javascript:player.pauseVideo();");
             *      Window.SongRequestPlayer.Navigate("javascript:musicPlayer.pauseVideo()");
             *      Window.SongRequestPlayer.Navigate("javascript:musicPlayer.pauseVideo();");
             *  }
             * }
             * if (!found)
             * {
             *  Window.SongRequestPlayer.Document.Write("<iframe id=\"musicPlayer\" type=\"text/html\" width=\"640\" height=\"360\" src=\"https://www.youtube.com/apiplayer?video_id=" + CurrentSong.id + "&version=3&autoplay=1&enablejsapi=1&feature=player_embedded&controls=0&modestbranding=1&rel=0&showinfo=0&autohide=1&color=white&playerapiid=musicPlayer&iv_load_policy=3\" frameborder=\"0\" allowfullscreen>");
             *  Window.SongRequestPlayer.Refresh();
             * }*/

            //Irc.sendMessage("[Song Request]: Now playing - " + CurrentSong.title + (CurrentSong.requester != "" ? ", requested by " + CurrentSong.requester : ""));
        }