[C#] Web Browser Source

  • Hello Guest! Welcome to ConsoleCrunch, to help support our site check out the premium upgrades HERE! to get exclusive access to our hidden content.
  • Unable to load portions of the website...
    If you use an ad blocker addon, you should disable it because it interferes with several elements of the site and blocks more than just adverts.
  • Read Rules Before Posting Post Virus Scans with every program.

Elite_Modz

Active Poster
Retired Staff
Active Member
Console ID Poster
Dec 19, 2014
517
380
133
Crunch
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;

namespace Browser1
{
  public partial class UserControl1 : UserControl
  {
  public UserControl1()
  {
  InitializeComponent();
  }

  private void UserControl1_Load(object sender, EventArgs e)
  {

  }

  #region Design
  public void Design_1()
  {
  //Progressbar for Loading
  progressBar1.Visible = true;
  progressBar2.Visible = true;

  //Side Panels
  panel_1.Visible = true;
  panel_2.Visible = true;
  }

  public void Design_2()
  {

  }
  #endregion

  #region Search
  public void Search_1()
  {
  try
  {
  if (String.IsNullOrEmpty(textBox1.Text))
  {

  }
  else
  {
  if (textBox1.Text.Contains("https://"))
  {
  Load_1();
  webBrowser1.ScriptErrorsSuppressed = true;
  webBrowser1.Navigate(textBox1.Text);
  //BrowserTitle();
  }
  else if (textBox1.Text.Contains("http://"))
  {
  Load_1();
  webBrowser1.ScriptErrorsSuppressed = true;
  webBrowser1.Navigate(textBox1.Text);
  //BrowserTitle();
  }
  else if (!textBox1.Text.Contains("."))
  {
  Load_1();
  webBrowser1.ScriptErrorsSuppressed = true;
  webBrowser1.Navigate("https://www.google.com/search?q=" + textBox1.Text);
  //BrowserTitle();
  }
  else
  {
  Load_1();
  webBrowser1.ScriptErrorsSuppressed = true;
  webBrowser1.Navigate("https://" + textBox1.Text);
  //BrowserTitle();
  }
  }
  }
  catch (Exception ex)
  {
  MessageBox.Show(ex.Message);
  }
  }

  public void Search_2()
  {

  }

  public void Load_1()
  {
  panel1.Enabled = false;
  }

  public static void BrowserTitle()
  {
  UserControl1 userControl1 = new UserControl1();
  //userControl1.BrowserUrl();
  //Form1.TabTitle(BrowserUrl());
  //MessageBox.Show(BrowserUrl());

  Form1 form1 = new Form1();
  form1.tabControl1.TabPages[form1.tabControl1.SelectedIndex].Text = userControl1.webBrowser1.DocumentTitle.ToString();
  form1.tabControl1.SelectedTab.Text = userControl1.webBrowser1.DocumentTitle.ToString();
  form1.tabControl1.Refresh();
  }
  #endregion

  public string BrowserUrl()
  {
  if (!String.IsNullOrEmpty(webBrowser1.Url.ToString()))
  {
  return GetWebPageTitle(webBrowser1.Url.ToString());
  }
  else
  {
  return null;
  }
  }

  public static string GetWebPageTitle(string url)
  {
  // Create a request to the url

  HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;

  // If the request wasn’t an HTTP request (like a file), ignore it

  if (request == null) return null;

  // Use the user’s credentials

  request.UseDefaultCredentials = true;

  // Obtain a response from the server, if there was an error, return nothing

  HttpWebResponse response = null;

  try { response = request.GetResponse() as HttpWebResponse; }

  catch (WebException) { return null; }

  // Regular expression for an HTML title

  string regex = @"(?<=<title.*>)([\s\S]*)(?=</title>)";

  // If the correct HTML header exists for HTML text, continue

  if (new List<string>(response.Headers.AllKeys).Contains("Content-Type"))

  if (response.Headers["Content-Type"].StartsWith("text/html"))
  {
  // Download the page

  WebClient web = new WebClient();

  web.UseDefaultCredentials = true;

  string page = web.DownloadString(url);

  // Extract the title

  Regex ex = new Regex(regex, RegexOptions.IgnoreCase);

  return ex.Match(page).Value.Trim();
  }

  // Not a valid HTML page

  return null;

  }


  private void label2_Click(object sender, EventArgs e)
  {
  progressBar1.Visible = true;
  progressBar2.Visible = true;
  progressBar1.Value = 100;
  progressBar2.Value = 100;
  Search_1();
  }

  private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  {
  if (e.KeyChar == (char)ConsoleKey.Enter)
  {
  Search_1();
  }
  }

  private void webBrowser1_DocumentCompleted_1(object sender, WebBrowserDocumentCompletedEventArgs e)
  {
  panel1.Enabled = true;
  }

  private void label5_Click(object sender, EventArgs e)
  {
  progressBar1.Visible = true;
  progressBar2.Visible = true;
  progressBar1.Value = 0;
  progressBar2.Value = 0;
  //BrowserTitle();
  }

  private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
  {

  }
  }
}
 
General chit-chat
Help Users
  • @ lurch6661:
    says no account by that name on the ps4
  • @ QM|T_JinX:
    did you type it corect
  • @ lurch6661:
    think so
  • @ QM|T_JinX:
    well i made the account on ps5 but you should be able to find it if i go on my app i can find it too
  • @ QM|T_JinX:
    i got picture of ellie from the last of us 2 in profile
  • @ lurch6661:
    strange
  • @ lurch6661:
    dennis_dutch
  • @ lurch6661:
    tright
  • @ QM|T_JinX:
    yea
  • @ lurch6661:
    cant you add me
  • @ lurch6661:
    lurchzapzap
  • @ QM|T_JinX:
    lol im not on that account but can you not find it or can add me
  • @ lurch6661:
    i cannot find it
  • @ lurch6661:
    says 0 players
  • @ QM|T_JinX:
    lol
  • Chat Bot:
    ilybudd is our newest member. Welcome!
  • @ damario:
    Sup
  • @ QM|T_JinX:
    sup\
  • @ Curdawg:
    is there anything i could possibly take inside of my ps4 to change it's cid?
  • Chat Bot:
    peluches is our newest member. Welcome!
  • @ QM|T_JinX:
    from your ps4 for ps3 ?
  • @ QM|T_JinX:
    nah you cant
  • Chat Bot:
    Christo has joined the room.
  • Chat Bot:
    Christo has joined the room.
  • @ lurch6661:
    no more locked doors
    @ lurch6661: no more locked doors