fork download
  1. table_add = function(a)
  2. {
  3. temp=table;
  4. last=a.length-1;
  5. for(i=0;i<last;i++)
  6. {
  7. if(!temp.has(a[i])) temp.set(a[i], new Map());
  8. temp=temp.get(a[i]);
  9. }
  10. if(!temp.has(a[last])) temp.set(a[last], 0);
  11. newcount=temp.get(a[last])+1;
  12. temp.set(a[last], newcount);
  13. //console.log(a);
  14. return newcount;
  15. }
  16.  
  17. let observer = new MutationObserver(mutationRecords => {
  18. for(let mut of mutationRecords) {
  19. let sl=/table__col _type_btn/;
  20. let sbl=/_state_blocked/;
  21. if (sl.test(mut.target.className)) //если кнопка
  22. {
  23. if(sbl.test(mut.target.className)&&!sbl.test(mut.oldValue)&&!sbl.test(mut.target.parentNode.className))
  24. {
  25. cell_elem=mut.target;
  26. parent_elem=cell_elem.parentElement;
  27. i=0;
  28. a=Array();
  29. a[i++]=cell_elem.cellIndex; //номер ячейки
  30. a[i++]=parent_elem.cells[1].firstElementChild.innerText; //название indent
  31. indent=parseInt(parent_elem.firstElementChild.classList[2].match(/\d/)[0]); //номер indent
  32. temp_elem=parent_elem;
  33. indent_next=indent-1;
  34. while(indent>1)
  35. {
  36. while(indent_next!=indent)
  37. {
  38. temp_elem=temp_elem.previousSibling;
  39. indent=parseInt(temp_elem.firstElementChild.classList[2].match(/\d/)[0]);
  40. }
  41. a[i++]=temp_elem.cells[1].firstElementChild.innerText;
  42. indent_next=indent-1;
  43. }
  44. a[i]=temp_elem.parentElement.firstElementChild.cells[0].innerText;
  45. ret_count=table_add(a.reverse());
  46. if(ret_count>=3)
  47. {
  48. if(mut.target.parentElement.cells.length>12)
  49. {
  50. switch(mut.target.cellIndex)
  51. {
  52. case 2:
  53. case 3:
  54. case 4:
  55. case 5:
  56. case 6:
  57. case 7: str=mut.target.parentElement.parentElement.rows[0].cells[mut.target.cellIndex-1].innerText+" ("+mut.target.innerText+")";
  58. break;
  59. case 9:
  60. case 11:str='Победа команды '+mut.target.parentElement.parentElement.rows[0].cells[mut.target.cellIndex-1].innerText+' с форой '+mut.target.previousElementSibling.innerText+' ('+mut.target.innerText+')';
  61. break;
  62. case 13:str='Тотал больше '+mut.target.previousElementSibling.innerText+' ('+mut.target.innerText+')';
  63. break;
  64. case 14:str='Тотал меньше '+mut.target.previousElementSibling.previousElementSibling.innerText+' ('+mut.target.innerText+')';
  65. break;
  66. }
  67.  
  68. }
  69. else
  70. {
  71. switch(mut.target.cellIndex)
  72. {
  73. case 2:
  74. case 3: str=mut.target.parentElement.parentElement.rows[0].cells[mut.target.cellIndex-1].innerText+" ("+mut.target.innerText+")";
  75. break;
  76. case 5:
  77. case 7:str='Победа команды '+mut.target.parentElement.parentElement.rows[0].cells[mut.target.cellIndex-1].innerText+' с форой '+mut.target.previousElementSibling.innerText+' ('+mut.target.innerText+')';
  78. break;
  79. case 9:str='Тотал больше '+mut.target.previousElementSibling.innerText+' ('+mut.target.innerText+')';
  80. break;
  81. case 10:str='Тотал меньше '+mut.target.previousElementSibling.previousElementSibling.innerText+' ('+mut.target.innerText+')';
  82. break;
  83. }
  84. }
  85.  
  86. let date=new Date();
  87. let time=date.toLocaleTimeString();
  88. str1='';
  89. for(i=0;i<a.length-1;i++)
  90. {
  91. str1+=a[i]+' | ';
  92. }
  93. str1+='потухло в '+ret_count+' раз';
  94. res_str = Array();
  95. res_str[0]=time;
  96. res_str[1]=str1;
  97. res_str[2]=str;
  98. res=document.getElementById('res_tab');
  99. res.firstElementChild.prepend(res.firstElementChild.rows[0].cloneNode(true));
  100. res.firstElementChild.rows[0].setAttribute('class','table__row _type_segment');
  101. //res.firstElementChild.rows[0].className=mut.target.parentElement.parentElement.rows[0].className;
  102. res.firstElementChild.rows[0].setAttribute('style',mut.target.parentElement.parentElement.rows[0].getAttribute('style'));
  103. //res.firstElementChild.rows[0].style=mut.target.parentElement.parentElement.rows[0].style;
  104. if(res.firstElementChild.rows[0].classList.length>3)
  105. (res.firstElementChild.rows[0].classList).remove(res.firstElementChild.rows[0].classList[3]);
  106. for(i=0;i<3;i++)
  107. {
  108. // res.firstElementChild.rows[0].classList[i]=mut.target.parentElement.parentElement.rows[0].classList[i];
  109. res.firstElementChild.rows[0].cells[i].innerText=res_str[i];
  110. }
  111. console.log(time+' '+str1+' '+str);
  112. }
  113.  
  114. }
  115. }
  116.  
  117. }
  118. });
  119.  
  120. //d=document.getElementById('coupons__inner');
  121. d=document.getElementsByClassName("zone__inner")
  122. //d.parentElement.prepend(d.cloneNode(false));
  123. d[0].parentElement.prepend(d[0].cloneNode(false));
  124. //d=document.getElementById('coupons__inner');
  125. d=document.getElementsByClassName("zone__inner")
  126.  
  127. d[0].id='mytable';
  128. tab=document.createElement('table');
  129. d[0].prepend(tab);
  130. d[0].firstElementChild.setAttribute('id', 'res_tab');
  131. res=document.getElementById('res_tab');
  132. r=res.insertRow(0);
  133. r.setAttribute('id','res_tab_row');
  134. //r.setAttribute('class','table__row _tytable__row _type_segment _sport_3088');
  135. r.setAttribute('class','table__row _type_segment');
  136. r.setAttribute('style','background-color: rgb(97, 154, 56)');
  137. r.insertCell(0);
  138. r.insertCell(1);
  139. r.insertCell(2);
  140. r.cells[0].setAttribute('class','table__col _type_head _type_value');
  141. r.cells[1].setAttribute('class','table__col _type_head _type_value');
  142. r.cells[2].setAttribute('class','table__col _type_head _type_value');
  143.  
  144. let d1 =new Date();
  145.  
  146. r.cells[0].innerText=d1.toLocaleTimeString();
  147. r.cells[1].innerText='тут будут указаны вид спорта, соревнование и т.д.';
  148. r.cells[2].innerText='ну а тут результат';
  149.  
  150. table = new Map();
  151.  
  152. observer.observe(document.getElementsByClassName("table")[0], {
  153. subtree: true,
  154. attributes: true,
  155. attributeOldValue: true, attributeFilter: ['class']
  156. });
Runtime error #stdin #stdout #stderr 0.36s 43652KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
js: "prog.js", line 18: missing ; after for-loop initializer
js: for(let mut of mutationRecords) {
js: ..............^
js: "prog.js", line 118: missing ) after argument list
js: });
js: ^
js: "prog.js", line 118: syntax error
js: });
js: .^
js: "prog.js", line 1: Compilation produced 3 syntax errors.