using System; using System.Collections.Generic; using System.Linq; using System.Text; using sharpknife.Controls; using sharpknife.Data; using sharpknife.Utils; #if WIN32 using MSHTML; using System.Globalization; using sharpknife.Commands; using sharpknife.Engines; #else using mshtml; #endif namespace sharpknife.Strategies { public class SamBuxStrategy : Strategy { public override bool CheckLogin(WebBrowserControl browser, PTCSource source) { return (browser.Search("Login") && !browser.Search(source.Username)); } public override void Login(WebBrowserControl browser, PTCSource source) { // // IHTMLInputElement username = (IHTMLInputElement)HtmlUtils.GetElement(browser.Document, "zx-user"); IHTMLInputElement password = (IHTMLInputElement)HtmlUtils.GetElement(browser.Document, "zx-pass-pri"); username.value = source.Username; password.value = source.Password; password.form.submit(); } public override decimal GetBalance(WebBrowserControl browser, PTCSource source) { //Main Balance: $0.0450 USD string html = browser.Html; string value = StringUtils.GetTokens(html, "{}Main Balance:{}${} USD{}")[2]; 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) { //
//
// //
join now - 2dollar payout - AVG over 2
//
//
// //
//
//
// $0.0010 USD //
//
5 seconds
//
//
IHTMLElementCollection elements = HtmlUtils.GetElementCollection(browser.Document, "div"); foreach (IHTMLElement element in elements) { string html = element.outerHTML; //
if (element.className == "item" && !StringUtils.Contains(html, "desc2")) { int duration = 30; decimal value = 0m; try { //$0.0010 USD
5 seconds
string[] tokens = StringUtils.GetTokens(StringUtils.RemoveQuotes(html), "{}${} USD{}{} seconds{}"); duration = int.Parse(tokens[3]); value = 100 * decimal.Parse(tokens[1], CultureInfo.InvariantCulture.NumberFormat); } catch (Exception ex) { LogItem item = new LogItem(ex.ToString()); item.Save(); } string link = StringUtils.GetTokens(StringUtils.RemoveQuotes(html), "{}{}")[1]; link = string.Format("{0}/{1}", source.BaseUrl, link); link = link.Replace("&", "&"); Command command = new AdCommand(link, duration + 5, AdCommand.BonusValue.Cents, value, source.Name); CommandEngine engine = CommandEngine.GetEngine(); engine.Commands.Add(command); } } return false; } public override decimal GetReferrals(WebBrowserControl browser, PTCSource source) { throw new NotImplementedException(); } } }