AutoCraft(EN_VERSION)

Auto craft system. If you only need to craft stews (for example), you can set all other parameters to 0 or 1. They simply won't be crafted if you don't have the resources.

  1. // ==UserScript==
  2. // @name AutoCraft(EN_VERSION)
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.1415
  5. // @description Auto craft system. If you only need to craft stews (for example), you can set all other parameters to 0 or 1. They simply won't be crafted if you don't have the resources.
  6. // @author Drik
  7. // @match https://cavegame.io/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. let menu = document.createElement('div');
  15. menu.style = `
  16. position: fixed;
  17. top: 10px;
  18. left: 10px;
  19. background: rgba(0,0,0,0.8);
  20. color: white;
  21. padding: 10px;
  22. border-radius: 5px;
  23. z-index: 10000;
  24. font-family: Arial, sans-serif;
  25. `;
  26. menu.innerHTML = `
  27. <label for="craftDoorsCount">Craft Doors:</label>
  28. <input type="number" id="craftDoorsCount" min="1" value="1" style="width: 50px; margin-right: 10px;">
  29. <br>
  30. <label for="craftBarriersCount">Craft Barriers:</label>
  31. <input type="number" id="craftBarriersCount" min="1" value="1" style="width: 50px; margin-right: 10px;">
  32. <br>
  33. <label for="craftGeneratorsCount">Craft Gold Generators:</label>
  34. <input type="number" id="craftGeneratorsCount" min="1" value="1" style="width: 50px; margin-right: 10px;">
  35. <br>
  36. <label for="craftArrowsCount">Craft Arrows:</label>
  37. <input type="number" id="craftArrowsCount" min="1" value="1" style="width: 50px; margin-right: 10px;">
  38. <br>
  39. <label for="craftStewsCount">Craft Stews:</label>
  40. <input type="number" id="craftStewsCount" min="1" value="1" style="width: 50px; margin-right: 10px;">
  41. <br>
  42. <button id="startCrafting">Craft</button>
  43. `;
  44. document.body.appendChild(menu);
  45.  
  46.  
  47. menu.querySelectorAll('input[type="number"]').forEach(input => {
  48. input.addEventListener('input', function() {
  49.  
  50. this.value = this.value.replace(/[^0-9]/g, '');
  51. });
  52. });
  53.  
  54. document.getElementById('startCrafting').onclick = () => {
  55. let doorsCount = parseInt(document.getElementById('craftDoorsCount').value);
  56. let barriersCount = parseInt(document.getElementById('craftBarriersCount').value);
  57. let generatorsCount = parseInt(document.getElementById('craftGeneratorsCount').value);
  58. let arrowsCount = parseInt(document.getElementById('craftArrowsCount').value);
  59. let stewsCount = parseInt(document.getElementById('craftStewsCount').value);
  60.  
  61. let craftButtons = {
  62. doors: document.querySelector("div.inventory.overlay-inventory[data-type='vault-door']"),
  63. barriers: document.querySelector("div.inventory.overlay-inventory[data-type='barrier']"),
  64. generators: document.querySelector("div.inventory.overlay-inventory[data-type='gold-generator']"),
  65. arrows: document.querySelector("div.inventory.overlay-inventory[data-type='arrow']"),
  66. stews: document.querySelector("div.inventory.overlay-inventory[data-type='stew']")
  67. };
  68.  
  69. if (doorsCount > 0 && !craftButtons.doors) {
  70. alert('Craft button for doors not found!');
  71. return;
  72. }
  73. if (barriersCount > 0 && !craftButtons.barriers) {
  74. alert('Craft button for barriers not found!');
  75. return;
  76. }
  77. if (generatorsCount > 0 && !craftButtons.generators) {
  78. alert('Craft button for gold generators not found!');
  79. return;
  80. }
  81. if (arrowsCount > 0 && !craftButtons.arrows) {
  82. alert('Craft button for arrows not found!');
  83. return;
  84. }
  85. if (stewsCount > 0 && !craftButtons.stews) {
  86. alert('Craft button for stews not found!');
  87. return;
  88. }
  89.  
  90. for (let i = 0; i < doorsCount; i++) {
  91. craftButtons.doors && craftButtons.doors.click();
  92. }
  93.  
  94. for (let i = 0; i < barriersCount; i++) {
  95. craftButtons.barriers && craftButtons.barriers.click();
  96. }
  97.  
  98. for (let i = 0; i < generatorsCount; i++) {
  99. craftButtons.generators && craftButtons.generators.click();
  100. }
  101.  
  102. for (let i = 0; i < arrowsCount; i++) {
  103. craftButtons.arrows && craftButtons.arrows.click();
  104. }
  105.  
  106. for (let i = 0; i < stewsCount; i++) {
  107. craftButtons.stews && craftButtons.stews.click();
  108. }
  109. };
  110.  
  111. document.addEventListener('keydown', (e) => {
  112. if (e.key === 'F9') {
  113. menu.style.display = (menu.style.display === 'none') ? 'block' : 'none';
  114. }
  115. });
  116. })();