ZennoLab

Automate everything

User Tools

Site Tools


en:addons:capmonster:rc-associations

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
en:addons:capmonster:rc-associations [2016/06/20 14:49]
vladz
en:addons:capmonster:rc-associations [2016/08/19 15:11] (current)
vladz [Using in ZennoPoster]
Line 31: Line 31:
 // show recognizing progress messages // show recognizing progress messages
 var needShowMessages = false; var needShowMessages = false;
-// check if answer ​is correct+// need to check answer's correctness
 var needToCheck = true; var needToCheck = true;
-// number ​of associations ​you should click according ​to task with associations+// count of associations ​need to click in task with associations
 var countAssociations = 4; var countAssociations = 4;
    
Line 59: Line 59:
 // task with associations // task with associations
 var isAssociationsTask = false; var isAssociationsTask = false;
 +var isFirstAttempt = true;
 +var coincidenceReCaptcha2Index = -1;
    
    
Line 161: Line 163:
  {  {
  throw new Exception("​Can'​t open audio form, try to change userAgent"​);​  throw new Exception("​Can'​t open audio form, try to change userAgent"​);​
 + }
 + }
 + }
 +};
 +
 +Action VisibleIndexReCaptchaDefinition= () => {
 + var recaptchaElementsGroup = tab.FindElementsByAttribute("​div",​ "​class",​ "​recaptcha-checkbox-checkmark",​ "​regexp"​);​
 + int length = recaptchaElementsGroup.Elements.Length;​
 + if (length == 1)
 + {
 + coincidenceReCaptcha2Index = 0;
 + return;
 + }
 +
 + for(int i = 0; i < length; i++)
 + {
 + var element = recaptchaElementsGroup.Elements[i];​
 + if (!element.IsVoid)
 + {
 + int x = element.DisplacementInTabWindow.X;​
 + int y = element.DisplacementInTabWindow.Y;​
 +
 + var suspectVisibleElement = tab.GetElementFromPoint(x,​ y).DisplacementInTabWindow;​
 + if (x == suspectVisibleElement.X && y == suspectVisibleElement.Y)
 + {
 + coincidenceReCaptcha2Index = i;
 + break;
  }  }
  }  }
Line 170: Line 199:
  for (int k = 0; k < tryLoadElement;​ k++)  for (int k = 0; k < tryLoadElement;​ k++)
  {  {
 + // searching coincidence index of recaptcha elements
 + VisibleIndexReCaptchaDefinition();​
 + if (coincidenceReCaptcha2Index < 0)
 + continue;​
 +
  // searching "​I'​m not robot" checkbox  // searching "​I'​m not robot" checkbox
- var notRobot = tab.FindElementByAttribute("​div",​ "​class",​ "​recaptcha-checkbox-checkmark",​ "​regexp", ​0);+ var notRobot = tab.FindElementByAttribute("​div",​ "​class",​ "​recaptcha-checkbox-checkmark",​ "​regexp", ​coincidenceReCaptcha2Index);
  // if found  // if found
  if (!notRobot.IsVoid)  if (!notRobot.IsVoid)
Line 200: Line 234:
  }  }
  break;  break;
 +
  }  }
  else  else
  {  {
  // checking if ReCaptcha 1 audio button exists  // checking if ReCaptcha 1 audio button exists
- HtmlElement r1 = tab.GetDocumentByAddress("​0"​).FindElementByTag("​form",​ 0).FindChildById("​recaptcha_switch_audio"​);​+ HtmlElement r1 = tab.FindElementById("​recaptcha_switch_audio"​);​
  if (!r1.IsVoid)  if (!r1.IsVoid)
  {  {
Line 248: Line 283:
  if (isNewView)  if (isNewView)
  {  {
 + if (isFirstAttempt)
 + {
 + isFirstAttempt = false;
 + }
 + else
 + {
 + var reload = tab.FindElementByAttribute("​div",​ "​id",​ "​recaptcha-reload-button",​ "​regexp",​ 0);
 + if (!reload.IsVoid)
 + {
 + reload.Click();​
 + tab.WaitDownloading();​
 + }
 + }
 + 
  var audioChallenge = tab.FindElementByAttribute("​a",​ "​class",​ "​rc-audiochallenge-download-link",​ "​regexp",​ 0);  var audioChallenge = tab.FindElementByAttribute("​a",​ "​class",​ "​rc-audiochallenge-download-link",​ "​regexp",​ 0);
  // if found, getting link to audio file  // if found, getting link to audio file
Line 449: Line 498:
  for (int k = 0; k < tryLoadElement;​ k++)  for (int k = 0; k < tryLoadElement;​ k++)
  {  {
- var checkAnswer = tab.FindElementByAttribute("​div",​ "​class",​ "​recaptcha-checkbox-checkmark",​ "​regexp", ​0);+ var checkAnswer = tab.FindElementByAttribute("​div",​ "​class",​ "​recaptcha-checkbox-checkmark",​ "​regexp", ​coincidenceReCaptcha2Index);
  if (!checkAnswer.IsVoid)  if (!checkAnswer.IsVoid)
  {  {
en/addons/capmonster/rc-associations.txt ยท Last modified: 2016/08/19 15:11 by vladz