using System; using System.Collections.Generic; using System.Linq; using System.Text; #if WIN32 using MSHTML; #else using mshtml; #endif using sharpknife.Utils; using System.Globalization; using sharpknife.Controls; using System.Drawing; using System.IO; using sharpknife.Data; using sharpknife.Commands; using sharpknife.Engines; namespace sharpknife.Strategies { class MyFreeSharesStrategy : Strategy { public override bool CheckLogin(WebBrowserControl browser, PTCSource source) { //WELCOME TO //MyFreeShares MEMBERS AREA ! string html = browser.Html; if (StringUtils.Contains(html, "Cannot modify header information")) { return true; } // IHTMLElementCollection elements = HtmlUtils.GetElementCollection(browser.Document, "input"); foreach (IHTMLElement element in elements) { IHTMLInputElement input = (IHTMLInputElement)element; if (input.value == "Sign up") { return true; } } return false; } public override void Login(WebBrowserControl browser, PTCSource source) { IHTMLElementCollection inputFields = HtmlUtils.GetElementCollection(browser.Document, "input"); foreach (IHTMLInputElement element in inputFields) { if (element.name == "user") { element.value = source.Username; } else if (element.name == "loza") { element.value = source.Password; } else if (element.name == "Submit2") { element.form.submit(); return; } } } public override decimal GetBalance(WebBrowserControl browser, PTCSource source) { string html = browser.Html; html = StringUtils.RemoveNewLines(html); html = StringUtils.RemoveQuotes(html); string value = StringUtils.GetTokens(html, "CURRENT {}BALANCE : {}
${}")[2]; value = value.Trim(); return decimal.Parse(value, CultureInfo.InvariantCulture.NumberFormat); } public override bool SolveCaptcha(WebBrowserControl browser, PTCSource source) { throw new NotImplementedException(); } public override Ad ParseMail(Mail mail) { throw new NotImplementedException(); } public override bool ParseAds(WebBrowserControl browser, PTCSource source) { IHTMLElementCollection links = HtmlUtils.GetElementCollection(browser.Document, "a"); if (links.length == 0) { browser.Navigate(source.LogInUrl); return false; } foreach (IHTMLAnchorElement link in links) { if (StringUtils.Contains(link.href, "http://www.myfreeshares.com/click.php")) { AdCommand command = new AdCommand(link.href, 15, AdCommand.BonusValue.Share, 0.01m, source.Name); CommandEngine.GetEngine().Commands.Add(command); } } return false; } public override decimal GetReferrals(WebBrowserControl browser, PTCSource source) { throw new NotImplementedException(); } } }