SHARE
TWEET

Untitled

a guest Aug 22nd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name Attack&Klin
  3. // @description good work
  4. // @author Konieczek
  5. // @version 0.0.0.1
  6. // @date 09-04-2019
  7. // @include https://*/game.php?village=*&screen=place&try=confirm
  8. // @include https://*/game.php?t=*&village=*&screen=place&try=confirm
  9. // ==/UserScript==
  10.  
  11. // DON'T MESS WITH THIS IF YOU DON'T KNOW WHAT YOU ARE DOING
  12.  
  13. // Add new table row for offset
  14. window.offsetTr = document.createElement("tr");
  15. window.offsetTd = document.createElement("td");
  16. var arrTimeNow = document.getElementById("date_arrival");
  17. window.offsetTr.appendChild(window.offsetTd); // Append td to tr
  18. arrTimeNow.parentNode.parentNode.insertBefore(window.offsetTr, arrTimeNow.parentNode[1]);
  19. window.offsetTd.innerHTML = "Offset: ";
  20. window.offsetTd.setAttribute("colspan", "2");
  21. window.offsetTd.setAttribute("id", "offset");
  22.  
  23. // Set Offset
  24. var pEle = document.getElementById("offset"); // Button comes after this element
  25. var inputOffset = document.createElement("input");
  26. inputOffset.setAttribute("id", "inputOffset");
  27. inputOffset.setAttribute("type", "text");
  28. inputOffset.setAttribute("style", "font-size:15px;")
  29. var callOffset1 = localStorage.getItem("saveOffset");
  30. if (callOffset1 !== null) {
  31.      var offsetInput = localStorage.getItem("saveOffset");
  32. } else {
  33.     var offsetInput = "15";
  34. }
  35. inputOffset.setAttribute("value", offsetInput);
  36. inputOffset.setAttribute("style", "margin-top:10px; width:50px;");
  37. pEle.appendChild(inputOffset, pEle.nextElementSibling);
  38.  
  39. // Create "Set Offset" button
  40. var parentSetOffset = document.getElementById("inputOffset"); // Button comes after this element
  41. var buttonOffset = document.createElement("a"); // Create button called buttonOffset as a link because any button causes the attack to launch
  42. buttonOffset.setAttribute("id", "buttonOffset"); // Set ID of buttonOffset
  43. buttonOffset.setAttribute("class", "btn");
  44. buttonOffset.setAttribute("style", "cursor:pointer;"); // Set cursor to pointer
  45. parentSetOffset.parentNode.insertBefore(buttonOffset, parentSetOffset.nextElementSibling); // Place buttonOffset after parentSetOffset
  46. var text = document.createTextNode("Set Offset"); // buttonOffset has this text
  47. buttonOffset.appendChild(text); // Append text to buttonOffset
  48.  
  49. buttonOffset.onclick = function() {
  50.     "use strict";
  51.     var saveOffset = document.getElementById("inputOffset").value;
  52.     localStorage.setItem("saveOffset", saveOffset);
  53.     var callOffset = localStorage.getItem("saveOffset");
  54.     console.log(callOffset);
  55. };
  56.  
  57. // Add new table row for arrival time
  58. window.showArrTimeTr = document.createElement("tr");
  59. window.showArrTimeTd = document.createElement("td");
  60. var arrTimeNow = document.getElementById("date_arrival");
  61. window.showArrTimeTr.appendChild(window.showArrTimeTd); // Append td to tr
  62. arrTimeNow.parentNode.parentNode.insertBefore(window.showArrTimeTr, arrTimeNow.parentNode[1]);
  63. window.showArrTimeTd.innerHTML = "Please enter the desired arrival time: ";
  64. window.showArrTimeTd.setAttribute("colspan", "2");
  65. window.showArrTimeTd.setAttribute("id", "showArrTime");
  66.  
  67. // Create "Set Arrival Time" button
  68. var pEle = document.getElementById("showArrTime"); // Button comes after this element
  69. var para = document.createElement("p"); // Create new paragraph
  70. para.setAttribute("style", "width:100%");
  71. var btn = document.createElement("a"); // Create button called btn as a link because any button causes the attack to launch
  72. btn.setAttribute("id", "arrTime"); // Set ID of btn
  73. btn.setAttribute("class", "btn");
  74. btn.setAttribute("style", "cursor:pointer;"); // Set cursor to pointer
  75. pEle.parentNode.insertBefore(para, pEle.nextElementSibling); // Place para after pEle
  76. para.parentNode.parentNode.appendChild(btn); // Set the paragraph after the table
  77. var t = document.createTextNode("Set arrival time"); // btn has this text
  78. btn.appendChild(t); // Append text to btn
  79.  
  80. // Create input for time
  81. var defaultTime = document.getElementsByClassName("relative_time")[0].textContent.slice(-8);
  82. var parentInput = document.getElementById("showArrTime"); // Button comes after this element
  83. var inputTime = document.createElement("input");
  84. inputTime.setAttribute("id", "inputTime");
  85. inputTime.setAttribute("type", "text");
  86. inputTime.setAttribute("value", defaultTime);
  87. inputTime.setAttribute("style", "margin-top:10px; width:80px;font-size:15px;");
  88. parentInput.appendChild(inputTime, parentInput.nextElementSibling);
  89.  
  90. // Create input for MS
  91. var parentInputMs = document.getElementById("showArrTime"); // Button comes after this element
  92. var inputTimeMs = document.createElement("input");
  93. inputTimeMs.setAttribute("id", "inputTimeMs");
  94. inputTimeMs.setAttribute("type", "text");
  95. inputTimeMs.setAttribute("value", "000");
  96. inputTimeMs.setAttribute("style", "margin-top:10px; width:30px;font-size:15px;");
  97. parentInputMs.appendChild(inputTimeMs, parentInputMs.nextElementSibling);
  98.  
  99. window.setArrTimeTr = document.createElement("tr");
  100. window.setArrTimeTd = document.createElement("td");
  101.  
  102. btn.onclick = function() {
  103.     "use strict";
  104.     var delayTime = parseInt(localStorage.getItem("saveOffset"));
  105.     var intervalTime = 30; // Set interval in ms
  106.     console.log("delayTime: " + delayTime);
  107.  
  108.     // Add new table row for the set arrival time
  109.     var arrTimeNow = document.getElementById("date_arrival");
  110.     window.setArrTimeTr.appendChild(window.setArrTimeTd); // Append td to tr
  111.     arrTimeNow.parentNode.parentNode.insertBefore(window.setArrTimeTr, arrTimeNow.parentNode[1]);
  112.     window.setArrTimeTd.innerHTML = "You set the arrival time to: " + document.getElementById("inputTime").value + ":" + document.getElementById("inputTimeMs").value + ", offset is " + delayTime;
  113.     window.setArrTimeTd.setAttribute("colspan", "2");
  114.     window.setArrTimeTd.setAttribute("id", "setArrTime");
  115.  
  116.     var arrivalTime = document.getElementById("inputTime").value;
  117.     var arrivalTimeMs = parseInt(document.getElementById("inputTimeMs").value);
  118.     var totalDelay;
  119.     if (arrivalTimeMs - delayTime <= 0) {
  120.         totalDelay = arrivalTimeMs;
  121.     } else {
  122.         totalDelay = arrivalTimeMs - delayTime;
  123.     }
  124.     console.log("totalDelay: " + totalDelay);
  125.  
  126.     setInterval(function retime() {
  127.     //  setInterval(function arrival() {
  128.             window.arrival = document.getElementsByClassName("relative_time")[0].textContent;
  129.     //  }, 100);
  130.         if(window.arrival.slice(-8) === arrivalTime) {
  131.             setTimeout(function() {
  132.                 document.getElementById("troop_confirm_go").click();
  133.             }, totalDelay);
  134.         }
  135.     }, intervalTime);
  136. };
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