Advertisement
Guest User

Beanfun Login Use WebBrowser Control

a guest
Jul 29th, 2013
881
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.96 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Windows.Forms;
  4.  
  5. namespace NewBeanfunLogin
  6. {
  7.     public partial class Form_Main : Form
  8.     {
  9.         Form_Log frmLog = null;
  10.        
  11.  
  12.         public Form_Main()
  13.         {
  14.             InitializeComponent();
  15.             frmLog = new Form_Log();
  16.         }
  17.  
  18.         private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
  19.         {
  20.  
  21.         }
  22.  
  23.         private void wb_Navigating(object sender, WebBrowserNavigatingEventArgs e)
  24.         {
  25.             string url = e.Url.ToString();
  26.  
  27.             Regex[] regAds = new Regex[] {
  28.                 new Regex(@"^https?://tw\.adnew\.beanfun\.com"),
  29.                 new Regex(@"^https?://tw\.beanfun\.com/bfweb/NEW/"),
  30.                 new Regex(@"^https?://tw\.new\.beanfun\.com/\d+_\d+\.html"),
  31.                 new Regex(@"^https?://tw\.new\.beanfun\.com/newHomePage/quicklink\.html"),
  32.                 new Regex(@"^about:"),
  33.                 // new Regex(@"^https?://tw\.beanfun\.com/BFWeb/ADwords\.aspx"),
  34.             };
  35.             foreach (Regex regAd in regAds)
  36.                 if (regAd.IsMatch(url)) { e.Cancel = true; return; }
  37.  
  38.             if (
  39.                     url.Contains("loader_iframe_custom.html") ||
  40.                     url.Contains("ADwords.aspx") ||
  41.                     url.Contains("loading.htm")
  42.                 ) return;
  43.  
  44.             if (url.StartsWith("res:") && url.Contains("beanfun:"))
  45.                 url = url.Substring(url.IndexOf("beanfun:"));
  46.  
  47.             Regex regLogin = new Regex(@"^https?://tw\.newlogin\.beanfun\.com/loginform\.aspx\?skey=(\w+)");
  48.             if (regLogin.IsMatch(url))
  49.             {
  50.                 string skey = regLogin.Match(url).Groups[1].Value;
  51.                 e.Cancel = true;
  52.                 wb.Navigate("https://tw.newlogin.beanfun.com/login/id-pass_form.aspx?skey=" + skey);
  53.  
  54.                 frmLog.lstLog.Items.Add("skey: " + skey);
  55.  
  56.                 return;
  57.             }
  58.  
  59.  
  60.             Regex regLogined = new Regex(@"^https?://tw\.new\.beanfun\.com/beanfun_block/bflogin/handle_writecookie\.aspx\?t=\w+&d=\w+");
  61.             if (regLogined.IsMatch(url))
  62.             {
  63.                 wb.Navigate("http://tw.new.beanfun.com/game_zone/");
  64.  
  65.                 frmLog.lstLog.Items.Add("Logined...");
  66.  
  67.                 return;
  68.             }
  69.  
  70.             if (!url.StartsWith("javascript")) frmLog.lstLog.Items.Add("Navigating: " + url);
  71.         }
  72.  
  73.         private void btnLogin_Click(object sender, EventArgs e)
  74.         {
  75.             if (wb.IsBusy) wb.Stop();
  76.             wb.Navigate("https://tw.new.beanfun.com/beanfun_block/bflogin/default.aspx?service=999999_T0");
  77.         }
  78.  
  79.         private void btnLog_Click(object sender, EventArgs e)
  80.         {
  81.             frmLog.Show();
  82.             frmLog.Focus();
  83.         }
  84.  
  85.         private void btnBotLogin_Click(object sender, EventArgs e)
  86.         {
  87.             new Form_Login().Show();
  88.         }
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement