SHARE
TWEET

Untitled

a guest May 20th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. //@name GAMOSAS APO KOLO
  3. // @namespace http://your.homepage/
  4. // @version 0.1
  5. // @description enter something useful
  6. // @author You
  7. // @include https://*mode=incomings*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. var atualizarPagina = 1;
  12. if(atualizarPagina == 1) {
  13. setInterval(
  14. function() {
  15. window.location.reload();
  16. }, 120000);
  17. }
  18.  
  19. /* PREDEFINIÇÕES */
  20.  
  21. var todas = true;
  22.  
  23. /* Redirecionamento de páginas -SUSPENSO
  24. if (typeof redirecionar === 'undefined') var redirecionar = false;
  25. testa_variavel(redirecionar, "redirecionar");
  26. if (!(game_data.screen == "info_command"))
  27. {
  28. if (redirecionar) $(location).attr("href", game_data.link_base_pure + "{game}&mode=incomings&subtype=attacks&screen=overview_villages");
  29. else alert("utilize o script na tela de identificação do ataque chegando");
  30. end();
  31. }
  32. */
  33. if (game_data.player.premium == false)
  34. {
  35. alert("Para utilizar esse script é necessária uma Conta Premium.");
  36. end();
  37. }
  38.  
  39. /* FIM DAS PREDEFINIÇÕES */
  40.  
  41. /* FUNÇÕES USUAIS */
  42.  
  43. function testa_variavel(variavel, nome)
  44. {
  45. if (variavel != 0 && variavel != false && variavel != 1 && variavel != true)
  46. {
  47. alert("A variavel " + nome + " precisa ser false (0) ou true (1)");
  48. end();
  49. };
  50. void(0);
  51. };
  52.  
  53. function ler_configuracoes_do_mundo()
  54. {
  55. var sURL = "http://" + window.location.hostname + "/interface.php?func=get_config";
  56. var oRequest = new XMLHttpRequest();
  57. oRequest.open("GET", sURL, false);
  58. oRequest.send(null);
  59. if (oRequest.status != 200) alert("Erro ao ler as configurações!");
  60. var configuracoes_do_mundo = oRequest.responseXML;
  61. theUnitSpeed = configuracoes_do_mundo.getElementsByTagName('unit_speed')[0].childNodes[0].nodeValue;
  62. theWorldSpeed = configuracoes_do_mundo.getElementsByTagName('speed')[0].childNodes[0].nodeValue;
  63. };
  64.  
  65.  
  66. function myErrorSuppressor() { return true;}
  67. window.onerror = myErrorSuppressor;
  68.  
  69.  
  70.  
  71. /* FUNCOES DE COORDENADAS*/
  72.  
  73. function myGetCoords(theString)
  74. {
  75. return /(.*?)\s\(((\d+)\|(\d+))\)\sK(\d+)/i.exec(theString);
  76. }
  77. function fnDistance(a, b)
  78. {
  79. a = a.split('|');
  80. b = b.split('|');
  81. var c = b[0] - a[0];
  82. var d = b[1] - a[1];
  83. return Math.sqrt(c * c + d * d)
  84. }
  85.  
  86.  
  87. /* FIM das FUNCOES DE COORDENADAS*/
  88.  
  89. /* FUNCOES DE DATA*/
  90.  
  91. var strDate = $('#serverDate').text();
  92. var strTime = $('#serverTime').text();
  93. Hservidor = fnDate(strDate+' '+strTime);
  94. // Hservidor = new date(strDate+' '+strTime);
  95.  
  96. var meses = ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'];
  97. var mouth = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Set', 'Oct', 'Nov', 'Dec'];
  98. function meses2mounth(theString)
  99. {
  100. meses.forEach( function (varValue, intIdx){ theString=theString.replace(meses[intIdx], mouth[intIdx]); });
  101. return(theString);
  102. }
  103. function mounth2meses(theString)
  104. {
  105. meses.forEach( function (varValue, intIdx){ theString= theString.replace(mouth[intIdx], meses[intIdx]); });
  106. return(theString);
  107. }
  108.  
  109. function fnDate(txtDate)
  110. {
  111. arrMs = txtDate.match(/:(\d{3})$/i);
  112. if (arrMs) txtDate = txtDate.replace(/:(\d{3})$/i, '');
  113. var dtNew = new Date(txtDate);
  114. if (dtNew == 'Invalid Date')
  115. {
  116. var arrDate = txtDate.match(/\b(\d+)\b/ig);
  117. arrDate = arrDate.map(fnInt);
  118. if (arrDate[2] < 2000) arrDate[2] += 2000;
  119. dtNew = new Date(arrDate[2], arrDate[1] - 1, arrDate[0], arrDate[3], arrDate[4], arrDate[5]);
  120. }
  121. if (arrMs) dtNew.setMilliseconds(arrMs[1]);
  122. return dtNew;
  123. }
  124.  
  125.  
  126.  
  127. function myZeroPad(theString)
  128. {
  129. theInt = parseInt(theString, 10);
  130. return (theInt > 9 ? theInt : '0' + theInt);
  131. }
  132.  
  133. function myTime(theInt)
  134. {
  135. return myZeroPad(theInt / 3600) + ':' + myZeroPad(theInt % (3600) / 60) + ':' + myZeroPad(theInt % 60);
  136. }
  137.  
  138. function fnInt(txtInt)
  139. {
  140. return parseInt(txtInt, 10);
  141. }
  142.  
  143. function fnDateFormat(dtDate)
  144. {
  145. intMs = dtDate.getMilliseconds();
  146. return myZeroPad(dtDate.getHours()) + ':' + myZeroPad(dtDate.getMinutes()) + ':' + myZeroPad(dtDate.getSeconds()) + '.' + (intMs > 99 ? intMs : '0' + myZeroPad(intMs)) + ' ' + myZeroPad(dtDate.getDate()) + '/' + myZeroPad(dtDate.getMonth() + 1);
  147. // return dtDate.toString('HH:mm:ss dd/MM')
  148. }
  149.  
  150.  
  151.  
  152. /* FUNÇOES DE AUXILIO para o HTML*/
  153.  
  154. function myGetElementsByTagName(theObj, theString)
  155. {
  156. return theObj.getElementsByTagName(theString);
  157. }
  158.  
  159. function myGetInner(theObj)
  160. {
  161. return theObj.innerHTML;
  162. }
  163.  
  164. function myGetInnerofFirstLink(theObj)
  165. {
  166. return myGetInner(myGetElementsByTagName(theObj, 'a')[0]);
  167. }
  168.  
  169. function mySetInner(theObj, theString)
  170. {
  171. theObj.innerHTML = theString;
  172. return theObj;
  173. }
  174.  
  175. /* FIM DAS FUNÇOES DE AUXILIO para o HTML*/
  176.  
  177.  
  178. /*SCRIPT*/
  179.  
  180. if (typeof (Formato) == 'undefined') Formato =' %enviado_as% %unidade% %chegada_em%';
  181. if (typeof (FormatoEtiqueta) == 'undefined') FormatoEtiqueta =' %unidade% %enviado_as% %chegada_em%';
  182. var arrUnitNames = ['Explorador ', 'Cavalaria leve ', 'Cavalaria pesada ', 'bárbaro', 'Espadachim ', 'aríete', ' * NOBRE * '];
  183. var arrUnitVel= [9, 10, 11, 18, 22, 30, 35];
  184. var arrReplace = ['unidade', 'aldeia_atacante', 'atacante', 'distancia', 'enviado_as', 'duracao', 'chegada_em', 'coordenada_aldeia_atacante', 'aldeia_defensor', 'coordenada_aldeia_defensor','data de retorno', 'registrado'];
  185. var arrHead = ['Unidade', 'Enviado', 'Dura&ccedil;&atilde;o', 'Renomear'];
  186. var arrValues = arrReplace;
  187. arrReplace = arrReplace.map(function fnReg(txtString){ return new RegExp("\%" + txtString + "\%", "ig");});
  188. Registro=fnDateFormat(Hservidor);
  189. var arrEtiqueta = ['%unit%', '%origin%', '%player%', '%distance%', '%sent%', '%duration%', '%arrival%', '%coords%', '%target%', '%target%','%return%',Registro];
  190. arrEtiqueta.forEach(function (varValue, intIdx){ FormatoEtiqueta=FormatoEtiqueta.replace(arrReplace[intIdx], arrEtiqueta[intIdx]); });
  191.  
  192.  
  193. function labelAttack()
  194. {
  195. // organizando a tabela
  196. theTable = document.getElementById('command_comment').parentNode.parentNode.parentNode.parentNode.parentNode;
  197. ConstWidth = 'width';
  198. theTable.removeAttribute(ConstWidth);
  199. var arrRows = theTable.rows;
  200. var intRows = arrRows.length;
  201. for (intRow = 0; intRow < intRows; intRow++)
  202. {
  203. theRow = arrRows[intRow];
  204. theLength = (arrCells = theRow.cells) ? arrCells.length : 0;
  205. if (theLength) arrCells[theLength - 1].colSpan = 5 - theLength;
  206. }
  207.  
  208. // extraindo informacoes do comando
  209. ler_configuracoes_do_mundo();
  210. arrArrivalIn = myGetInner(arrRows[6].cells[1]).match(/\d+/ig);
  211. msecsArrivalIn = (arrArrivalIn[0] * 3600 + arrArrivalIn[1] * 60 + arrArrivalIn[2] * 1) * 1000;
  212. Alvo = (arrRows[4].cells[1].textContent).match(/\d+\|\d+/ig);
  213. Alvo = Alvo[Alvo.length - 1];
  214. NomeAlvo = arrRows[4].cells[1].textContent;
  215. CordAtacante = (arrRows[2].cells[1].textContent).match(/\d+\|\d+/ig);
  216. CordAtacante = CordAtacante[CordAtacante.length - 1];
  217. Distancia = fnDistance(CordAtacante, Alvo);
  218. chegada = typeof (arrRows[5].cells[1].innerText) == 'undefined' ? arrRows[5].cells[1].textContent : arrRows[5].cells[1].innerText; //MMM DD,yyyy HH:mm:ss:FFF
  219. dtArrival = new Date(meses2mounth(chegada));
  220.  
  221. arrValues[1] = arrRows[2].cells[1].textContent; //aldeia_atacante (nome)
  222. arrValues[2] = myGetInnerofFirstLink(arrRows[1].cells[2]); //atacante(nome)
  223. arrValues[3] = Distancia.toFixed(2);//distancia
  224. arrValues[6] = fnDateFormat(dtArrival);
  225. arrValues[7] = CordAtacante;
  226. arrValues[8] = Alvo;
  227. arrValues[9] = NomeAlvo;
  228.  
  229.  
  230. var intRow = intRows - 2;
  231. newRow = theTable.insertRow(intRow++);;
  232. mySetInner(newRow.insertCell(0), 'Dist&acircncia:').colSpan = 2;
  233. mySetInner(newRow.insertCell(1), arrValues[3] + ' Campos').colSpan = 2;
  234. newRow = theTable.insertRow(intRow++);;
  235.  
  236. function myInsTH(theString)
  237. {
  238. newCell = newRow.appendChild(document.createElement('th'));
  239. return mySetInner(newCell, theString);
  240. }
  241. arrHead.forEach(myInsTH);
  242.  
  243. for (theIndex in arrUnitNames)
  244. {
  245. msecsDuration = Math.round(arrUnitVel[theIndex] * 60 * 1000 * Distancia / theWorldSpeed / theUnitSpeed);
  246. secsDiff = (msecsDuration - msecsArrivalIn) / 1000;
  247. if (secsDiff > 0)
  248. {
  249. arrValues[0] = arrUnitNames[theIndex]; //unidade
  250. arrValues[4] = fnDateFormat(new Date(dtArrival - msecsDuration));//enviado as
  251. arrValues[5] = myTime(msecsDuration / 1000);//duracao
  252. arrValues[10] = fnDateFormat(new Date(dtArrival + msecsDuration));//retorno as
  253. arrValues[11] = Registro;
  254.  
  255. newRow = theTable.insertRow(intRow++);;
  256. mySetInner(newRow.insertCell(0), arrUnitNames[theIndex]);
  257. mySetInner(newRow.insertCell(1), secsDiff < 60 && 'just now' || secsDiff < 3600 && Math.floor(secsDiff / 60) + ' min atr&aacute;s' || myTime(secsDiff) + ' atr&aacute;s');
  258. mySetInner(newRow.insertCell(2), arrValues[5]);
  259. newCell = newRow.insertCell(3);
  260.  
  261. var element = document.createElement("input");
  262. element.setAttribute("type", "button");
  263. element.setAttribute("value", "OK");
  264. element.setAttribute("name", theIndex);
  265. element.onclick = function ()
  266. {
  267. javascript: $('.rename-icon').click();
  268. quickedit = document.getElementsByClassName('quickedit-edit')[0];
  269. editlabel = quickedit.getElementsByTagName('input');
  270. editlabel[0].value = document.getElementsByName("label" + this.name)[0].value;
  271. editlabel[1].click();
  272. };
  273. newButton = newCell.appendChild(element);
  274.  
  275. var element = document.createElement("input");
  276. element.setAttribute("type", "text");
  277. element.setAttribute("name", "label" + theIndex);
  278. element.size = 20;
  279. element.value = Formato;
  280.  
  281. function fnPreg(varValue, intIdx){element.value= element.value.replace(arrReplace[intIdx], varValue); }
  282. arrValues.forEach(fnPreg);
  283. newInput = newCell.appendChild(element);
  284.  
  285. }
  286. }
  287. }
  288.  
  289. if (game_data.screen == "info_command") labelAttack();
  290.  
  291.  
  292. if (game_data.mode=='incomings')
  293. {
  294. if(todas) {$(':checkbox').each(function(i,e){e.checked=true});};
  295. $('input[name=label_format]').val(FormatoEtiqueta).parents('form').find('input[name=label]').click();
  296. }
  297.  
  298. void(0);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top