string extPath = @"C:\zen\CapMonster Cloud — automated captcha solver 1.11.12.0.crx";
string apiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
int attempCnt = 3;
instance.InstallCrxExtension(extPath);
_ = instance.GetExtensionById("pabjfbciaedomjjfelfafejkppknjleh").Activate();
_ = !instance.IsExtensionWorking ? throw new Exception("Не удается активировать расширение CapMonsterCloud !") : true;
Tab ext = instance.ActiveExtension;
ext.FindElementByXPath("//input[@type='text']", 0).SetValue(apiKey.Trim(), "Full");
while (true)
{
HtmlElement saveIcon = ext.FindElementByXPath("//span[@class='anticon']/*[@fill='#46B982']", 0);
if(!saveIcon.IsNull && !saveIcon.IsVoid)
{
saveIcon.Click();
break;
}
}
string balance = "";
var timer = System.Diagnostics.Stopwatch.StartNew();
while (true)
{
try
{
if (timer.ElapsedMilliseconds > 10000) throw new Exception("Не удалось соединиться с сервером CapMonsterCloud в течении 10 секунд !");
balance = ext.FindElementByXPath("//span[starts-with(@class, 'ant-typography')]", 3).InnerText;
if (balance.Contains("$")) break;
else if (balance.Contains("Неверный ключ")) throw new Exception("Неверный Api ключ CapMonsterCloud !");
}
finally { timer.Stop(); }
}
double buy = double.Parse(new string(balance.Where(x => char.IsDigit(x) || x == '.').ToArray()), System.Globalization.CultureInfo.InvariantCulture);
if (buy < 0.05) throw new Exception($"Слишком маленький баланс CapMonsterCloud: {buy}$ !");
if (0 < attempCnt && attempCnt < 10)
{
ext.FindElementByXPath("//span[@class='ant-select-selection-item']", 0).Click();
ext.FindElementByXPath("//*[@class='ant-select-item-option-content']", attempCnt).Click();
}
HtmlElement he = instance.ActiveExtension.FindElementByAttribute("span", "innertext", "Token", "regexp", 1);
if (he.IsVoid) return -1;
instance.WaitFieldEmulationDelay();
he.RiseEvent("click", instance.EmulationLevel);
HtmlElement helem = instance.ActiveExtension.GetDocumentByAddress("0").FindElementByAttribute("button", "class", "ant-btn\\ ant-btn-text\\ sc-1om12l0\\ lnoqzy", "regexp", 0);
if (helem.IsVoid) return -1;
instance.WaitFieldEmulationDelay();
helem.RiseEvent("click", instance.EmulationLevel);
instance.ActiveTab.FindElementByXPath("/html", 0).Click();