Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.48 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Quick Village Notes
  3. // @version 3.1.1
  4. // @author Diogo Rocha
  5. // @include https://*&screen=info_village&id*
  6. // ==/UserScript==
  7.  
  8. //Ainda falta implementar funcionamento para outros mundos
  9.  
  10. var world = window.location.href.substring(8, 12);
  11. var archers = true, religion = true;
  12. var genView = $('#content_value table tbody:eq(2) tr:eq(4) a')
  13. var temp = false;
  14. var event = false;
  15. var listener= false;
  16.  
  17. function injectButton(){
  18. var html = '';
  19. html += '<table class="header-border"><tbody><tr><td><table height="20px" width="20px" class="box menu nowrap"><tbody><tr>'
  20. html += '<td style="white-space:nowrap;" id="state" class="firstcell box-item icon-box nowrap">'
  21. html += '<span></span>'
  22. html += '</td></tr></tbody></table></td></tr><tr class="newStyleOnly"><td class="shadow"><div class="leftshadow"></div><div class="rightshadow"></div></td></tr></tbody></table>'
  23.  
  24. $('#header_info > tbody > tr > td:nth-child(3)').append(html)
  25.  
  26. $('#state').click(function(){toggleListener()})
  27. }
  28.  
  29. if(listener)injectButton();
  30.  
  31. function startListener(){
  32. if(!event){
  33. document.addEventListener ('keydown', reportKeyEvent);
  34. $('#state span').attr("style", "color: green");
  35. $('#state span').text("ON")
  36. event = true;
  37. }
  38. }
  39.  
  40. function stopListener(){
  41. if(event){
  42. document.removeEventListener('keydown', reportKeyEvent);
  43. $('#state span').attr("style", "color: red");
  44. $('#state span').text("OFF")
  45. event = false;
  46. //console.log("off")
  47. }
  48. }
  49.  
  50. function toggleListener(){
  51. if(event) stopListener();
  52. else startListener();
  53. }
  54.  
  55. function reportKeyEvent (zEvent) {
  56. if(zEvent.code === "KeyP" && ($(genView).text().includes("geral da aldeia"))){
  57. var url = String(location.href).split('/')
  58. var link = $(genView).attr("href")
  59. UI.InfoMessage('A abrir aldeia...', 3000);
  60. location.href = url[0] + "//" + url[2] + "/" + link;
  61. }
  62. if(zEvent.code === "F5") location.reload()
  63. if(zEvent.code === "F1") $('#1atq').click();
  64. if(zEvent.code === "F2") $('#ataque').click();
  65. if(zEvent.code === "F10" || zEvent.code === "KeyE") $('#limpa').click();
  66. if(zEvent.code === "F11") $('#editar').click();
  67. if(zEvent.code === "F12" || zEvent.code === "KeyQ") $('#limpar').click();
  68. if(zEvent.code === "KeyC")
  69. {
  70. $('#content_value > table > tbody > tr > td:nth-child(1) > table:nth-child(2) > tbody > tr:nth-child(6) > td > a').click();
  71. setTimeout(function(){$('input[value="220298"]').click();}, 200);
  72. setTimeout(function(){$('input[value="Inserir grupos"]').click();}, 300);
  73. }
  74. zEvent.stopPropagation ();
  75. zEvent.preventDefault ()
  76. }
  77.  
  78. if(world == 'pt59'){
  79. archers = false;
  80. religion = false;
  81. }
  82.  
  83. $('a.float_right').remove();
  84.  
  85. var html = '';
  86. html += '<span class="float_right">'
  87. html += '<button type="button" id="1atq" class="btn">1</button>';
  88. html += '<button type="button" id="2atq" class="btn">2</button>';
  89. html += '<button type="button" id="3atq" class="btn">3</button>';
  90. html += '<button type="button" id="p3atq" class="btn">3+</button>';
  91. html += '<button type="button" id="reservar" class="btn">Reservar</button>';
  92. html += '<button type="button" id="ataque" class="btn">Ataque</button>';
  93. html += '<button type="button" id="defesa" class="btn">Defesa</button>';
  94. if(religion)html += '<button type="button" id="igreja" class="btn">Igreja</button>';
  95. html += '<button type="button" id="torre" class="btn">Torre</button>';
  96. html += '<button type="button" id="limpa" class="btn">Limpa</button>';
  97. html += '<button type="button" id="editar" onclick="VillageInfo.Notes.toggleEdit(); return false" class="btn">Editar</button>';
  98. html += '<button type="button" id="limpar" class="btn">Limpar</button>';
  99. html +- '</span>'
  100. setTimeout(function(){
  101. document.getElementById("1atq").setAttribute("style","background: no-repeat 3px -49px, linear-gradient(to bottom, #ff9631 0%,#ea7404 100%); padding: 3px 3px 3px 3px; font-size: 8px !important")
  102. document.getElementById("2atq").setAttribute("style","background: no-repeat 3px -49px, linear-gradient(to bottom, #ff9631 0%,#ea7404 100%); padding: 3px 3px 3px 3px; font-size: 8px !important")
  103. document.getElementById("3atq").setAttribute("style","background: no-repeat 3px -49px, linear-gradient(to bottom, #ff9631 0%,#ea7404 100%); padding: 3px 3px 3px 3px; font-size: 8px !important")
  104. document.getElementById("p3atq").setAttribute("style","background: no-repeat 3px -49px, linear-gradient(to bottom, #ff9631 0%,#ea7404 100%); padding: 3px 3px 3px 3px; font-size: 8px !important")
  105. document.getElementById("reservar").setAttribute("style","background: no-repeat 3px -49px, linear-gradient(to bottom, #0bac00 0%,#0e7a1e 100%); padding: 3px 3px 3px 3px; font-size: 8px !important")
  106. document.getElementById("ataque").setAttribute("style","background: no-repeat 3px -49px, linear-gradient(to bottom, #0bac00 0%,#0e7a1e 100%); padding: 3px 3px 3px 3px; font-size: 8px !important")
  107. document.getElementById("defesa").setAttribute("style","background: no-repeat 3px -49px, linear-gradient(to bottom, #0bac00 0%,#0e7a1e 100%); padding: 3px 3px 3px 3px; font-size: 8px !important")
  108. document.getElementById("torre").setAttribute("style","background: no-repeat 3px -49px, linear-gradient(to bottom, #0bac00 0%,#0e7a1e 100%); padding: 3px 3px 3px 3px; font-size: 8px !important")
  109. if(religion) document.getElementById("igreja").setAttribute("style","background: no-repeat 3px -49px, linear-gradient(to bottom, #0bac00 0%,#0e7a1e 100%); padding: 3px 3px 3px 3px; font-size: 8px !important")
  110. document.getElementById("limpa").setAttribute("style","background: no-repeat 3px -49px, linear-gradient(to bottom, #0bac00 0%,#0e7a1e 100%); padding: 3px 3px 3px 3px; font-size: 8px !important")
  111. document.getElementById("editar").setAttribute("style","background: no-repeat 3px -49px, linear-gradient(to bottom, #0080ff 0%,#0052a2 100%); padding: 3px 3px 3px 3px; font-size: 8px !important")
  112. document.getElementById("limpar").setAttribute("style","background: no-repeat 3px -49px, linear-gradient(to bottom, #ff0000 0%,#a70000 100%); padding: 3px 3px 3px 3px; font-size: 8px !important")
  113. }, 5);
  114. $('table.vis:eq(2) th:eq(0)').append(html)
  115. if(listener)toggleListener();
  116.  
  117. $('#1atq').click(function(){
  118. $('#editar').click();
  119. $('#message').val($('#message').val() + " 1Full ");
  120. $('#note_submit_button').click();
  121. if(listener)startListener();
  122. })
  123. $('#2atq').click(function(){
  124. $('#editar').click();
  125. $('#message').val($('#message').val() + " 2Full ");
  126. $('#note_submit_button').click();
  127. if(listener)startListener();
  128. })
  129. $('#3atq').click(function(){
  130. $('#editar').click();
  131. $('#message').val($('#message').val() + " 3Full ");
  132. $('#note_submit_button').click();
  133. if(listener)startListener();
  134. })
  135. $('#p3atq').click(function(){
  136. $('#editar').click();
  137. $('#message').val($('#message').val() + " +3Full ");
  138. $('#note_submit_button').click();
  139. if(listener)startListener();
  140. })
  141. $('#reservar').click(function(){
  142. $('#editar').click();
  143. $('#message').val($('#message').val() + " Reservado ");
  144. $('#note_submit_button').click();
  145. if(listener)startListener();
  146. })
  147. $('#ataque').click(function(){
  148. $('#editar').click();
  149. $('#message').val($('#message').val() + " Ataque ");
  150. $('#note_submit_button').click();
  151. if(listener)startListener();
  152. })
  153. $('#defesa').click(function(){
  154. $('#editar').click();
  155. $('#message').val($('#message').val() + " Defesa ");
  156. $('#note_submit_button').click();
  157. if(listener)startListener();
  158. })
  159. $('#torre').click(function(){
  160. $('#editar').click();
  161. $('#message').val($('#message').val() + " Torre ");
  162. $('#note_submit_button').click();
  163. if(listener)startListener();
  164. })
  165. $('#igreja').click(function(){
  166. $('#editar').click();
  167. $('#message').val($('#message').val() + " Igreja ");
  168. $('#note_submit_button').click();
  169. if(listener)startListener();
  170. })
  171. $('#limpa').click(function(){
  172. $('#editar').click();
  173. $('#message').val($('#message').val() + " Limpa ");
  174. $('#note_submit_button').click();
  175. if(listener)startListener();
  176. })
  177. $('#editar').click(function(){
  178. if(listener)stopListener();
  179. })
  180. $('#note_submit_button').click(function(){
  181. if(listener)startListener();
  182. });
  183. $('#limpar').click(function(){
  184. $('#editar').click();
  185. $('#message').val('');
  186. $('#note_submit_button').click();
  187. if(listener)startListener();
  188. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement