[INTERFACE]
DIALOG, "Поиск элементов JS", 765, 296;
STATIC, "Порядковый номер выполнения команды в JavaScript (начинается с 0)", 4, 4, 368, 20;
EDIT, 376, 4, 380, 20, int Num;
STATIC, "Ожидать элемент после начала поиска", 4, 28, 212, 20;
EDIT, 224, 28, 100, 20, int Wai;
STATIC, "Метод поиска", 4, 52, 72, 20;
COMBO, "querySelectorAll""Name""TagName", 80, 52, 156, 132, string M_find;
EDIT, 240, 52, 516, 20, string Find;
COMBO, "Не учитывая текст""Текст элемента (частичное соответствие)""Текст ссылки (частичное соответствие)""Текст элемента (полное соответствие)""Текст ссылки (полное соответствие)", 4, 76, 224, 140, int iT;
EDIT, 232, 76, 524, 20, string Text;
STATIC, "Действие", 4, 100, 56, 20;
COMBO, "Клик по элементу""Записать в элемент""Считать с элемента""Бездействие", 80, 100, 156, 120, string D;
STATIC, "Записать в элемент текст", 240, 100, 140, 20;
EDIT, 384, 100, 140, 20, unknown Z;
STATIC, "Записать в переменную", 528, 100, 128, 20;
EDIT, 660, 100, 96, 20, string VP;
STATIC, "Пауза после действия", 4, 124, 116, 20;
EDIT, 124, 124, 100, 20, int P;
STATIC, "При успехе перейти на порядковый номер команды (при отсутствие параметра перейдет на следующий)", 4, 148, 548, 20;
EDIT, 556, 148, 200, 20, unknown GOTO_Y;
STATIC, "При не удаче перейти на порядковый номер команды (при отсутсвие параметра завершит работу)", 4, 172, 516, 20;
EDIT, 556, 172, 200, 20, unknown GOTO_N;
STATIC, "Массив элементов", 4, 196, 100, 20;
EDIT, 108, 196, 164, 20, string Elements;
STATIC, "Количество найденных элементов", 280, 196, 184, 20;
EDIT, 468, 196, 136, 20, string K_Elements;
STATIC, "Комментарий", 4, 220, 72, 20;
EDIT, 80, 220, 676, 20, unknown Comment;
BUTTON_OK, "Принять", 544, 248, 100, 20;
BUTTON_CANCEL, "Закрыть", 656, 248, 100, 20;
[END]

[APPEARANCE]
COLOR = 50, 10, 250;
SIZE_X = 12;
SIZE_Y =8;
[END]


[INFO]
>>" ">>Num>>[ENDL]>>"При успехе ">>GOTO_Y>>[ENDL]>>[ENDL]>>"При неудаче ">>GOTO_N>>[ENDL]>>D>>[ENDL]>>Comment
[END]


[ASSOC_VAR]
Num=0;
GOTO_Y=;
GOTO_N=;
M_find="querySelectorAll";
Find="selector";
v_Find_v=W#@22@##%~%34~~Find~~%34~A@@&%W;
D="Бездействие";
Z="Текст";
v_Z_v=W#@22@##%~%34~~Z~~%34~A@@&%W;
VP=CopyText_JS;
v_VP_v=~%34~~VP~~%34~;
Text="site.com";
v_Text_v=W#@22@##%~%34~~Text~~%34~A@@&%W;
iT=0;
P=0;
Elements=Elements_JS;
v_Elements_v=~%34~~Elements~~%34~;
K_Elements=K_Elements_JS;
v_K_Elements_v=~%34~~K_Elements~~%34~;
Wai=2000;
V_GOTO_Y=~%34~~GOTO_Y~~%34~;
V_GOTO_N=~%34~~GOTO_N~~%34~;
Comment=;
V_Comment=~%34~~Comment~~%34~;
[END]

[REGEXPLACE_CODE]
A@@&%W=;
W#@22@##%=;
~%34~~%34~A@@&%W=~%94~~%34~~%34~A@@&%W;
W#@22@##%~%34~~%34~=W#@22@##%~%34~~%94~~%34~;
[END]


[GLOBAL_VAR]
string Script_JS="";
string Var_JS="";
string Global_Var_B_JS = "";
string Global_Var_C_JS = "";
string Send_Global_Var_JS="";
string Call_Get_Fun_JS="";
string Get_Global_Var_JS="";
string Send_Back_Global_Var_JS = "";
string Get_Back_Global_Var_JS = "";
string All_Call_Send="";
[END]

[EVENT]
IF (iT==0)ENABLE(GETID(Text), 0);
IF (iT!=0)ENABLE(GETID(Text), 1);
[END]


[FUNCTION_BODY]
function(string how, string d, string z, string find, string komment, int nom, string goto_y, string goto_n, string text, string vp, int it, int p, int wai, string elements, string k_elements)
{
Script_JS=Script_JS+"if (st=="+format(nom+1)+")/^/"+komment+"^r^n{^r^n";
Script_JS=Script_JS+"var_input.value = ^""+komment+"^";^r^n";
  if (how=="querySelectorAll")
  {
    if (it==0)
    {
    Script_JS=Script_JS+"elements=document.querySelectorAll("+find+");^r^n";
    Script_JS=Script_JS+"Alls=0;^r^n";
    Script_JS=Script_JS+"for (index = 0; index < elements.length; ++index) {^r^n";
    Script_JS=Script_JS+elements+"[Alls]=elements[index];^r^n";
    Script_JS=Script_JS+"Alls=Alls+1;^r^n";
    Script_JS=Script_JS+"}^r^n";
    Script_JS=Script_JS+k_elements+"=Alls;^r^nif (Alls>0) {^r^n";
      if (d=="Клик по элементу")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+elements+"[0].click(); ";
      }
      if (d=="Записать в элемент")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+elements+"[0].value="+z+"; "+elements+"[0].textContent="+z+"; ";
      }
      if (d=="Считать с элемента")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+vp+" = "+elements+"[0].textContent; if ("+vp+"==^"^")"+vp+" = "+elements+"[0].value; ";
      }
      if (d=="Бездействие")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){ ";
      }
    }
    else
    {
    Script_JS=Script_JS+"elements=document.querySelectorAll("+find+");^r^n";
    Script_JS=Script_JS+"Alls=0;^r^n";
    Script_JS=Script_JS+"for (index = 0; index < elements.length; ++index) {^r^n";
    if (it==1)Script_JS=Script_JS+"strE = elements[index].textContent;^r^n";
    if (it==2)Script_JS=Script_JS+"strE = elements[index];^r^n";
      if (it==1 || it==2)
      {
      Script_JS=Script_JS+"nS = strE.toString().search("+text+");^r^n";
      Script_JS=Script_JS+"if (nS!=-1){^r^n";
      }
      if (it==3)
      {
      Script_JS=Script_JS+"if (elements[index].textContent=="+text+"){^r^n";
      }
      if (it==4)
      {
      Script_JS=Script_JS+"if (elements[index]=="+text+"){^r^n";
      }
    Script_JS=Script_JS+elements+"[Alls]=elements[index];^r^n";
    Script_JS=Script_JS+"Alls=Alls+1;^r^n";
    Script_JS=Script_JS+"}}^r^n";
    Script_JS=Script_JS+k_elements+"=Alls;^r^nif (Alls>0) {^r^n";
      if (d=="Клик по элементу")
      {
      Script_JS=Script_JS+"if ("+elements+"[0]){"+elements+"[0].click(); ";
      }
      if (d=="Записать в элемент")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+elements+"[0].value="+z+"; "+elements+"[0].textContent="+z+"; ";
      }
      if (d=="Считать с элемента")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+vp+" = "+elements+"[0].textContent; if ("+vp+"==^"^")"+vp+" = "+elements+"[0].value; ";
      }
      if (d=="Бездействие")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){ ";
      }
    }
  }
  if (how=="TagName")
  {
    if (it==0)
    {
    Script_JS=Script_JS+"elements=document.getElementsByTagName("+find+");^r^n";
    Script_JS=Script_JS+"Alls=0;^r^n";
    Script_JS=Script_JS+"for (index = 0; index < elements.length; ++index) {^r^n";
    Script_JS=Script_JS+elements+"[Alls]=elements[index];^r^n";
    Script_JS=Script_JS+"Alls=Alls+1;^r^n";
    Script_JS=Script_JS+"}^r^n";
    Script_JS=Script_JS+k_elements+"=Alls;^r^nif (Alls>0) {^r^n";
      if (d=="Клик по элементу")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+elements+"[0].click(); ";
      }
      if (d=="Записать в элемент")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+elements+"[0].value="+z+"; "+elements+"[0].textContent="+z+"; ";
      }
      if (d=="Считать с элемента")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+vp+" = "+elements+"[0].textContent; if ("+vp+"==^"^")"+vp+" = "+elements+"[0].value; ";
      }
      if (d=="Бездействие")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){ ";
      }
    }
    else
    {
    Script_JS=Script_JS+"elements=document.getElementsByTagName("+find+");^r^n";
    Script_JS=Script_JS+"Alls=0;^r^n";
    Script_JS=Script_JS+"for (index = 0; index < elements.length; ++index) {^r^n";
    if (it==1)Script_JS=Script_JS+"strE = elements[index].textContent;^r^n";
    if (it==2)Script_JS=Script_JS+"strE = elements[index];^r^n";
    Script_JS=Script_JS+"nS = strE.toString().search("+text+");^r^n";
    Script_JS=Script_JS+"if (nS!=-1){^r^n";
    Script_JS=Script_JS+elements+"[Alls]=elements[index];^r^n";
    Script_JS=Script_JS+"Alls=Alls+1;^r^n";
    Script_JS=Script_JS+"}}^r^n";
    Script_JS=Script_JS+k_elements+"=Alls;^r^nif (Alls>0) {^r^n";
      if (d=="Клик по элементу")
      {
      Script_JS=Script_JS+"if ("+elements+"[0]){"+elements+"[0].click(); ";
      }
      if (d=="Записать в элемент")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+elements+"[0].value="+z+"; "+elements+"[0].textContent="+z+"; ";
      }
      if (d=="Считать с элемента")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+vp+" = "+elements+"[0].textContent; if ("+vp+"==^"^")"+vp+" = "+elements+"[0].value; ";
      }
      if (d=="Бездействие")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){ ";
      }
    }
  }
  if (how=="Name")
  {
    if (it==0)
    {
    Script_JS=Script_JS+"elements=document.getElementsByName("+find+");^r^n";
    Script_JS=Script_JS+"Alls=0;^r^n";
    Script_JS=Script_JS+"for (index = 0; index < elements.length; ++index) {^r^n";
    Script_JS=Script_JS+elements+"[Alls]=elements[index];^r^n";
    Script_JS=Script_JS+"Alls=Alls+1;^r^n";
    Script_JS=Script_JS+"}^r^n";
    Script_JS=Script_JS+k_elements+"=Alls;^r^nif (Alls>0) {^r^n";
      if (d=="Клик по элементу")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+elements+"[0].click(); ";
      }
      if (d=="Записать в элемент")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+elements+"[0].value="+z+"; "+elements+"[0].textContent="+z+"; ";
      }
      if (d=="Считать с элемента")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+vp+" = "+elements+"[0].textContent; if ("+vp+"==^"^")"+vp+" = "+elements+"[0].value; ";
      }
      if (d=="Бездействие")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){ ";
      }
    }
    else
    {
    Script_JS=Script_JS+"elements=document.getElementsByName("+find+");^r^n";
    Script_JS=Script_JS+"Alls=0;^r^n";
    Script_JS=Script_JS+"for (index = 0; index < elements.length; ++index) {^r^n";
    if (it==1)Script_JS=Script_JS+"strE = elements[index].textContent;^r^n";
    if (it==2)Script_JS=Script_JS+"strE = elements[index];^r^n";
    Script_JS=Script_JS+"nS = strE.toString().search("+text+");^r^n";
    Script_JS=Script_JS+"if (nS!=-1){^r^n";
    Script_JS=Script_JS+elements+"[Alls]=elements[index];^r^n";
    Script_JS=Script_JS+"Alls=Alls+1;^r^n";
    Script_JS=Script_JS+"}}^r^n";
    Script_JS=Script_JS+k_elements+"=Alls;^r^nif (Alls>0) {^r^n";
      if (d=="Клик по элементу")
      {
      Script_JS=Script_JS+"if ("+elements+"[0]){"+elements+"[0].click(); ";
      }
      if (d=="Записать в элемент")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+elements+"[0].value="+z+"; "+elements+"[0].textContent="+z+"; ";
      }
      if (d=="Считать с элемента")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){"+vp+" = "+elements+"[0].textContent; if ("+vp+"==^"^")"+vp+" = "+elements+"[0].value; ";
      }
      if (d=="Бездействие")
      {
      Script_JS=Script_JS+"if("+elements+"[0]){ ";
      }
    }
  }
if (goto_y=="") Script_JS=Script_JS+"st=st+1; addNum(); T_Pz=Date.now(); Pz=" + format(p+1) + "; addPz(); wai=Date.now(); addWai(); T=0; All_Call_Send(); return;}}^r^n";
else Script_JS=Script_JS+"st=" + format(formatsn(goto_y)+1) + "; addNum(); T_Pz=Date.now(); Pz=" + format(p+1) + "; addPz(); wai=Date.now(); addWai(); T=0; All_Call_Send(); return;}}^r^n";
Script_JS=Script_JS+"else {^r^nif (Date.now()-wai<"+format(wai)+"){T=0; All_Call_Send(); return;}^r^n";
if (goto_n=="") Script_JS=Script_JS+"else {st=500; addNum(); T_Pz=Date.now(); Pz=1; addPz(); wai=Date.now(); addWai(); T=0; All_Call_Send(); return;}^r^n";
else Script_JS=Script_JS+"else {st=" + format(formatsn(goto_n)+1) + "; addNum(); T_Pz=Date.now(); Pz=1; addPz(); wai=Date.now(); addWai(); T=0; All_Call_Send(); return;}^r^n";
Script_JS=Script_JS+"}}^r^n";
string t1, var;
string t="const "+elements+" ";
if (regexsearch(1, #t1, Var_JS, t)==0)Var_JS=Var_JS+t+"= [];^r^n";
var=vp;
  if (regexsearch(1, #t1, var, "^"")==0)
  {
    if (regexsearch(1, #t1, Global_Var_C_JS, "( "+var+" | "+var+"=| "+var+";)")==0)
    {
    Global_Var_C_JS=Global_Var_C_JS+"var "+var+";^r^n";
    Global_Var_B_JS=Global_Var_B_JS+"var "+var+";^r^n";
    Send_Global_Var_JS=Send_Global_Var_JS+"function Send"+var+"()^r^n{chrome.runtime.sendMessage({T"+var+":"+var+"}, function(response) {var tst=response.farewell;});}^r^n";
    Call_Get_Fun_JS=Call_Get_Fun_JS+"Get"+var+"();^r^n";
    Get_Global_Var_JS=Get_Global_Var_JS+"function Get"+var+"()^r^n{chrome.runtime.sendMessage({greeting:^"GlobalVar_"+var+"^"},function(response){"+var+"=response.farewell;});}^r^n";
    Get_Back_Global_Var_JS=Get_Back_Global_Var_JS+"if (request.greeting==^"GlobalVar_"+var+"^"){sendResponse({farewell:"+var+"});S=1;}^r^n";
    Send_Back_Global_Var_JS=Send_Back_Global_Var_JS+"if (request.T"+var+"){"+var+"=request.T"+var+";}^r^n";
    All_Call_Send=All_Call_Send+"Send"+var+"();^r^n";
    }
  }
var=k_elements;
  if (regexsearch(1, #t1, var, "^"")==0)
  {
    if (regexsearch(1, #t1, Global_Var_C_JS, "( "+var+" | "+var+"=| "+var+";)")==0)
    {
    Global_Var_C_JS=Global_Var_C_JS+"var "+var+"=0;^r^n";
    Global_Var_B_JS=Global_Var_B_JS+"var "+var+"=^"0^";^r^n";
    Send_Global_Var_JS=Send_Global_Var_JS+"function Send"+var+"()^r^n{chrome.runtime.sendMessage({T"+var+":String("+var+")}, function(response) {var tst=response.farewell;});}^r^n";
    Call_Get_Fun_JS=Call_Get_Fun_JS+"Get"+var+"();^r^n";
    Get_Global_Var_JS=Get_Global_Var_JS+"function Get"+var+"()^r^n{chrome.runtime.sendMessage({greeting:^"GlobalVar_"+var+"^"},function(response){"+var+"=Number(response.farewell);});}^r^n";
    Get_Back_Global_Var_JS=Get_Back_Global_Var_JS+"if (request.greeting==^"GlobalVar_"+var+"^"){sendResponse({farewell:"+var+"});S=1;}^r^n";
    Send_Back_Global_Var_JS=Send_Back_Global_Var_JS+"if (request.T"+var+"){"+var+"=request.T"+var+";}^r^n";
    All_Call_Send=All_Call_Send+"Send"+var+"();^r^n";
    }
  }
}
[END]

[CALL]
(M_find, D, v_Z_v, v_Find_v, V_Comment, Num, V_GOTO_Y, V_GOTO_N, v_Text_v, v_VP_v, iT, P, Wai, v_Elements_v, v_K_Elements_v)
[END]

