#pragma warning disable private void RunScript(string Name, params object[] Args) { try { Dispatcher.Invoke(() => { try { MainBrowser.InvokeScript(Name, Args); } catch { Clear(); } }); } catch { } }
private void _InstantLogin(object sender, FrameLoadEndEventArgs e) { MainBrowser.ExecuteScriptAsync($@"document.getElementsByClassName(""tv-control-material-input tv-signin-dialog__input tv-control-material-input__control"")[0].setAttribute(""value"", ""{credentials.Read("username")}"");"); MainBrowser.ExecuteScriptAsync($@"document.getElementsByClassName(""tv-control-material-input tv-signin-dialog__input tv-control-material-input__control"")[1].setAttribute(""value"", ""{credentials.Read("password")}"");"); MainBrowser.ExecuteScriptAsync(@"document.getElementsByClassName(""tv-button tv-button--no-border-radius tv-button--size_large tv-button--primary_ghost tv-button--loader"")[0].click();"); MainBrowser.FrameLoadEnd -= _InstantLogin; }
private void urlTextbox_KeyDown(object sender, KeyEventArgs e) { // ReSharper disable once SwitchStatementMissingSomeCases switch (e.Key) { case Key.Return: { MainBrowser.Stop(); var result = ValidHttpUrl(urlTextbox.Text, out var uriResult); if (!result) { MainBrowser.Address = "https://google.com/search?q=" + urlTextbox.Text; } else { MainBrowser.Address = uriResult?.AbsoluteUri; } MainBrowser.Focus(); break; } case Key.Escape: MainBrowser.Focus(); break; } }
private void Shortcut_Ctrl_F() { if (MainBrowser.CanGoForward) { MainBrowser.Forward(); } }
private void Shortcut_Ctrl_B() { if (MainBrowser.CanGoBack) { MainBrowser.Back(); } }
private void GetAuthorizationCode() { _client = new YubiCryptClient(clientId, clientSecret, callbackUrl); messageText.Text = "Please sign in to your YubiCrypt account:"; var url = _client.GetAuthorizationCodeRequestUrl(new string[] { "files", "keys" }); MainBrowser.Navigate(url); }
static async Task StartServerActivatorAsync(string npname) { await Task.Delay(1); while (!ApplicationCTS.IsCancellationRequested) { bool everConnected = false; try { using (var nps = new System.IO.Pipes.NamedPipeServerStream(npname, System.IO.Pipes.PipeDirection.InOut , 1, System.IO.Pipes.PipeTransmissionMode.Byte , System.IO.Pipes.PipeOptions.Asynchronous | System.IO.Pipes.PipeOptions.WriteThrough, 65536, 65536)) { await nps.WaitForConnectionAsync(ApplicationCTS.Token); everConnected = true; byte[] msg = System.Text.Encoding.ASCII.GetBytes(CurrentProcess.Id.ToString()); await nps.WriteAsync(msg); await nps.FlushAsync(); //nps.Disconnect(); //do not disconnect nps.Close(); } } catch (Exception x) { if (ApplicationCTS.IsCancellationRequested) return; WriteDebugLine(x); if (!everConnected) { await Task.Delay(1000); continue; } } PostToAppThread(delegate { WriteDebugLine("ServerActivator"); var mf = MainBrowser?.FindForm(); if (mf?.Visible == true) { ActivateForm(mf); return; } var forms = WF.Application.OpenForms; for (var i = 0; i < forms.Count; i++) { var form = forms[i]; if (!form.Visible) continue; //WindowsInterop.SetForegroundWindow(form.Handle); ActivateForm(form); break; } }); } }
private async Task ClearAds() { if (!blockAdsCheckbox.IsChecked.Value) { return; } MainBrowser.ExecuteScriptAsync(@"document.getElementsByClassName(""closeButton-10VUlhi4- closeButtonAdv-2pjmC0Yh- js-toast__close"")[0].click();"); await Task.Delay(800); MainBrowser.ExecuteScriptAsync(@"document.getElementsByClassName(""js-dialog__action-click js-dialog__no-drag tv-button tv-button--link tv-button--no-padding i-float_left"")[0].click();"); }
private void Forwardbutton_Click(object sender, RoutedEventArgs e) { if (MainBrowser.CanGoForward) { MainBrowser.Forward(); } else { ShowNotification("Cannot go forward"); } }
private void BackButton_Click(object sender, RoutedEventArgs e) { if (MainBrowser.CanGoBack) { MainBrowser.Back(); } else { ShowNotification("Cannot go back"); } }
private void FeedbackPreview_Loaded(object sender, RoutedEventArgs e) { try { MainBrowser.NavigateToString(Html); } catch (Exception ex) { LogWriter.Log(ex, "Displaying the preview"); Dialog.Ok("Feedback Preview", "It was not possible to display the content", ex.Message); } }
private void ErrorComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var item = ErrorComboBox.SelectedItem as FileInfo; if (item == null) { MainBrowser.Navigate("about:blank"); } else { var uri = new System.Uri(item.FullName); MainBrowser.Navigate(uri.AbsoluteUri); } }
public PageDetailMail() { InitializeComponent(); worker.DoWork += worker_DoWork; MailRecu m = NavigateReceptionMailTest.GetNavigationData(this.NavigationService); mail = m; label_Date.Content = m.DateReception; label_Expediteur.Text = m.Expediteur; label_Subject.Text = m.Objet; MainBrowser.NavigateToString(m.Message); worker.RunWorkerAsync(); m.estLu = true; }
public MainWindow() { InitializeComponent(); DataContext = new MainWindowViewModel(); if (!SetBrowserEmulationVersion(BrowserEmulationVersion.Version11Edge)) { _logger.Error("Initialization was failed! NOT SET THE VERSION OF BROWSER!"); } MainBrowser.Navigating += (s, e) => { var fiComWebBrowser = typeof(WebBrowser).GetField("_axIWebBrowser2", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); if (fiComWebBrowser == null) { return; } var objComWebBrowser = fiComWebBrowser.GetValue(MainBrowser); if (objComWebBrowser == null) { return; } objComWebBrowser.GetType().InvokeMember("Silent", System.Reflection.BindingFlags.SetProperty, null, objComWebBrowser, new object[] { true }); }; MainBrowser.Navigated += (sender, args) => { var webBrowserSource = MainBrowser.Source.ToString(); var correctUrlMatchValue = Regex.Match(webBrowserSource, "(?<=https://)www.instagram.com").Value; if (string.IsNullOrEmpty(correctUrlMatchValue)) { MessageBox.Show( "You can navigate only to \"https://www.instagram.com\" page. Please, navigate to correct page. You will redirect to correct page.", "Wrong URL", MessageBoxButton.OK); MainBrowser.Source = new Uri("https://www.instagram.com/"); MainBrowser.Navigate("https://www.instagram.com/"); } }; var curDir = Directory.GetCurrentDirectory(); DocumentationBrowser.Navigate($"file:///{curDir}/Doc/documentation.htm"); }
private void Login() { this.Dispatcher.Invoke(() => { MainBrowser.Address = "https://uk.tradingview.com/#signin"; MainBrowser.FrameLoadEnd += _InstantLogin; try { MainBrowser.ExecuteScriptAsync(@"document.getElementsByClassName(""tv-dialog__error tv-dialog__error--dark"")[0].click();"); } catch (Exception e) { MessageBox.Show(e.Message); } }); }
private void button4_Click_1(object sender, EventArgs e) { Bitmap BottomPanel = Crop(System.IO.Directory.GetCurrentDirectory() + "\\RainbowTemplate.bmp", 1466, 53, 0, 651); Bitmap TopPanel = Crop(System.IO.Directory.GetCurrentDirectory() + "\\RainbowTemplate.bmp", 1466, 29, 0, 0); Bitmap RightSidePanel = Crop(System.IO.Directory.GetCurrentDirectory() + "\\RainbowTemplate.bmp", 220, 624, 0, 313); Bitmap LeftBrowserPanel = Crop(System.IO.Directory.GetCurrentDirectory() + "\\RainbowTemplate.bmp", 520, 625, 0, 29); Bitmap RightBrowserPanel = Crop(System.IO.Directory.GetCurrentDirectory() + "\\RainbowTemplate.bmp", 729, 625, 519, 29); LeftBrowserPanel.Save(@"LBP.bmp"); RightBrowserPanel.Save(@"RBP.bmp"); MainBrowser.EvaluateScript("document.getElementById('booty').style.backgroundImage = 'url(https://i.imgur.com/ZFi2bAs.png)';", TimeSpan.FromMilliseconds(1)); MainBrowser.EvaluateScript("document.getElementById('cons').style.backgroundColor = 'transparent';", TimeSpan.FromMilliseconds(1)); MainBrowser.EvaluateScript("document.getElementById('sb').style.backgroundColor = 'transparent';", TimeSpan.FromMilliseconds(1)); RightBrowser.EvaluateScript("document.getElementById('bootys').style.backgroundImage = 'url(https://i.imgur.com/iaNeUAu.png)';", TimeSpan.FromMilliseconds(1)); b_panel.BackgroundImage = BottomPanel; Bar.BackgroundImage = TopPanel; }
public static void LoadAllFIles() { string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string specificFolder = Path.Combine(folder, "LothosGen"); if (!Directory.Exists(specificFolder)) //Checks OR Makes Directory Folder { try { Directory.CreateDirectory(specificFolder); } catch (Exception e) { MessageBox.Show(e.Message); } } MessageBox.Show("a"); MainBrowser.LoadStartPage(); RightBrowser.LoadUpdatesPage(); }
void RefreshErrorsComboBox() { var asm = new AssemblyInfo(); var dir = new DirectoryInfo(LogHelper.Current.LogsFolder); var errors = dir.GetFiles("*.htm").OrderByDescending(x => x.CreationTime).ToArray(); SubjectTextBox.Text = string.Format("Problem with {0}", asm.Product); ErrorComboBox.ItemsSource = errors; ErrorComboBox.DisplayMemberPath = nameof(FileInfo.Name); if (errors.Length > 0) { ErrorComboBox.SelectedIndex = 0; } else { MainBrowser.Navigate("about:blank"); } }
public async Task Init(Settings setting, MoeSite site) { Site = site; DataContext = setting; Closing += OnClosing; this.SetWindowFluent(setting); try { MainBrowser.CoreWebView2InitializationCompleted += MainBrowserOnCoreWebView2InitializationCompleted; if (MainBrowser == null) { return; } var option = new CoreWebView2EnvironmentOptions(); switch (NetOperator.GetProxyMode(setting, site.SiteSettings)) { case Settings.ProxyModeEnum.None: option.AdditionalBrowserArguments = "--no-proxy-server"; break; case Settings.ProxyModeEnum.Custom: option.AdditionalBrowserArguments = $"--proxy-server=http://{setting.ProxySetting}"; break; case Settings.ProxyModeEnum.Ie: break; } Environment = await CoreWebView2Environment.CreateAsync(null, App.AppDataDir, option); AuthButton.Click += AuthButtonOnClick; GoToLoginPageButton.Click += GoToLoginPageButtonOnClick; var _ = MainBrowser.EnsureCoreWebView2Async(Environment); } catch (Exception ex) { var result = MessageBox.Show(this, "未找到WebView2组件,需要下载吗?(需要Webview2组件才能显示网页登录界面)", App.DisplayName, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { "https://go.microsoft.com/fwlink/p/?LinkId=2124703".GoUrl(); } Ex.Log(ex); Close(); } }
/// <summary> /// Loads only the YouTube player removing all kinds of distractions /// </summary> /// <param name="url"></param> private void LoadYoutubeMode(string url) { // convert url to youtube embed url = url.Replace("watch?v=", "embed/"); MainBrowser.LoadHtml($@" <!DOCTYPE html> <html> <body style=""overflow: hidden;""> <iframe id=""vid"" src=""{url}"" frameborder=""0""></iframe> <script type=""text/javascript""> var el = document.getElementById(""vid""); el.style.width=window.innerWidth-15+'px'; el.style.height=window.innerHeight-15+'px'; </script> </body> </html>"); }
private static void Main(string[] args) { Console.WriteLine("Starting application"); Data = new ProgramData(); if (Data.HasError) { Console.ReadKey(); return; } Socket = new ClientSocket(); WorkerManager = new WorkerManager(); Browser = new MainBrowser(); API = new PropellerAdsApi(Data["username"], Data["password"]); Context = new ClientContext(); Console.WriteLine("Application has started..."); Console.ReadKey(); }
async void HladajButton_Click(object sender, EventArgs e) { dataGridView1.Visible = false; dataGridView1.Columns.Clear(); lines.Clear(); MainBrowser.Navigate("https://cp.hnonline.sk/" + GetTransportMethod() + "/odchody/"); await PageLoad(10); MainBrowser.Focus(); SendKeys.Send("%{o}"); //access key which selects the field SendKeys.Send(ZTextBox.Text); SendKeys.Send("%{k}"); SendKeys.Send(DoTextBox.Text); SendKeys.Send("%{t}"); SendKeys.Send(datumPicker.Value.ToString("d.M.yyyy")); SendKeys.Send("%{a}"); SendKeys.Send("00:00"); SendKeys.SendWait("{ENTER}"); await PageLoad(10); await PageLoad(10); var tr = MainBrowser.Document.GetElementsByTagName("tr"); Regex rL = new Regex(@"javascript:.+?\)"); List <string> pages = rL.Matches(tr[1].InnerHtml).Cast <Match>().Select(match => match.Value).ToList(); await GetLinesFromPage("", tr); foreach (string page in pages) { await GetLinesFromPage(page, tr); } dataGridView1.Visible = true; ShowResults(); }
async Task GetLinesFromPage(string page, HtmlElementCollection tr) { if (page != "") { MainBrowser.Document.InvokeScript(page); } List <string> links = new List <string>(); Regex rS = new Regex("\"/draha/.*?\""); foreach (HtmlElement element in tr) { string test = rS.Match(element.InnerHtml).Value; if (test != "") { test = test.Replace("\"", ""); links.Add(test); } } foreach (string s in links) { MainBrowser.Navigate("https://cp.hnonline.sk" + s); await PageLoad(1); tr = MainBrowser.Document.GetElementsByTagName("tr"); lines.Add(new Line()); for (int i = 1; i < tr.Count - 1; i++) { if (tr[i].Children[0].OuterHtml.Contains("EndDark") || tr[i].Children[0].OuterHtml.Contains("lastRouteDark")) { lines.Last().AddStop(tr[i].Children[0].InnerText, tr[i].Children[1].InnerText == " " ? tr[i].Children[2].InnerText : tr[i].Children[1].InnerText); break; } else if (tr[i].Children[0].OuterHtml.Contains("Dark")) { lines.Last().AddStop(tr[i].Children[0].InnerText, tr[i].Children[2].InnerText); } } } }
public static string get(string ID, string Method) { int c = 0; if (Method == "name") { string _source = ""; _source = MainBrowser.getSource(); List <String> lines = Regex.Split(_source, "\n").ToList(); foreach (string l in lines) { string h = l.ToLower(); if (l.Contains(ID)) { string name = Regex.Split(Regex.Split(h, "name=\"")[1], "\"")[0]; return(name); } } } return("Not Found"); }
private void OnClosing(object sender, CancelEventArgs e) { MainBrowser.Dispose(); }
private void Shortcut_Ctrl_P() { MainBrowser.Print(); }
private void Shortcut_Ctrl_R() { MainBrowser.Reload(); }
private void PrintMenuItem_Click(object sender, RoutedEventArgs e) { MainBrowser.Print(); }
private void ReloadMenuItem_Click(object sender, RoutedEventArgs e) => MainBrowser.Reload();
public void Clear() => MainBrowser.NavigateToString(new PageHTMLBuilder().SetTheme(ThemeListener.GetCurrentTheme() == Themes.Dark).LoadTheme(OptionContainer.SelectedTheme.Path).BuildHTML());