Greasy Fork is available in English.

deepio script

lol

이 스크립트는 직접 설치하는 용도가 아닙니다. 다른 스크립트에서 메타 지시문 // @require https://updategreasyfork.deno.dev/scripts/20128/128677/deepio%20script.js을(를) 사용하여 포함하는 라이브러리입니다.

  1. var colorScheme = {
  2. 'rgb(205,205,205)': 'rgb(30,30,30)', // background
  3. 'rgb(245,245,245)': 'rgb(222,222,222)', // name
  4. 'rgb(255,255,255)': 'rgb(255,255,255)', // all text except name
  5. 'rgb(0,0,0)': 'rgb(0,0,0)', // black overlays usually semi opaque
  6. 'rgb(0,178,225)': 'rgb(22,99,222)', // blue tank
  7. 'rgb(241,78,84)': 'rgb(222,22,22)', // red tank / ffa bullet
  8. 'rgb(153,153,153)': 'rgb(55,55,55)', // tank's nozzle
  9. 'rgb(85,85,85)': 'rgb(10,10,10)', // outline for objects, names and healthbar
  10.  
  11. 'rgb(255,232,105)': 'rgb(255,222,55)', // square
  12. 'rgb(252,118,119)': 'rgb(255,66,33)', // triangle
  13. 'rgb(118,141,252)': 'rgb(111,55,255)', // hexagon
  14. 'rgb(241,119,221)': 'rgb(255,111,255)', // triangle bot
  15. 'rgb(252,195,118)': 'rgb(255,155,55)', // square minion
  16.  
  17. 'rgb(252,173,118)': 'rgb(252,173,118)', // stat - hp regen
  18. 'rgb(249,67,255)': 'rgb(249,67,255)', // stat - max hp
  19. 'rgb(133,67,255)': 'rgb(133,67,255)', // stat - body dmg
  20. 'rgb(67,127,255)': 'rgb(67,127,255)', // stat - bullet speed
  21. 'rgb(255,222,67)': 'rgb(255,222,67)', // stat - bullet penetration
  22. 'rgb(255,67,67)': 'rgb(255,67,67)', // stat - bullet damage
  23. 'rgb(130,255,67)': 'rgb(130,255,67)', // stat - reload
  24. 'rgb(67,255,249)': 'rgb(67,255,249)', // stat - move speed
  25. };
  26.  
  27. function onCanvasFill(fullColor) {
  28. fullColor = fullColor.replace(/ /g, '');
  29. if(colorScheme.hasOwnProperty(fullColor)) return document.getElementById('optnDarkTheme').checked ? colorScheme[fullColor] : fullColor;
  30. else return fullColor;
  31. }
  32. function onCanvasStroke(fullColor) {
  33. fullColor = fullColor.replace(/ /g, '');
  34. if(colorScheme.hasOwnProperty(fullColor)) return document.getElementById('optnDarkTheme').checked ? colorScheme[fullColor] : fullColor;
  35. else return fullColor;
  36. }
  37.  
  38. var canvas = document.getElementById('canvas');
  39. var nick = document.getElementById('textInput');
  40. var optionsDiv, popupsDiv;
  41. var keepOptionOpen = false, playerAlive = -1;
  42. var holdingKey = {};
  43. var tankInfo = {}, statInfo = {}, currentTank = '';
  44.  
  45. function editPanels() {
  46. optionsDiv = document.createElement('div');
  47. optionsDiv.id = 'gameOptions';
  48. optionsDiv.style = 'position: absolute; display: none; top: 60%; left: 50%; transform: translate(-50%, 0%); width: 340px; padding: 6px 12px; border: 2px dashed #333; background-color: #EEE; color: #000; font-family: Tahoma; font-size: 12px;';
  49. optionsDiv.innerHTML = '<div></div><div></div><div></div>';
  50. document.body.insertBefore(optionsDiv, nick.parentElement.nextElementSibling);
  51. optionsDiv.children[0].style = 'margin-bottom: 4px; padding-bottom: 6px; border-bottom: 1px solid #888; font-family: Ubuntu; font-size: 16px; text-align: center';
  52. optionsDiv.children[1].style = 'margin-bottom: 12px;';
  53. optionsDiv.children[2].style = 'font-size: 10px; text-align: right;';
  54. optionsDiv.children[0].innerHTML += 'Game Options<a style="position: absolute; top: 1px; right: 4px; color: #222; text-decoration: none; font-family: serif; font-size: 12px;" href="#">&#x2716;</a>';
  55. optionsDiv.children[1].innerHTML += '<div><strong>(Z)</strong><label><input type="checkbox" id="optnAutoRespawn">Auto respawn</label></div>';
  56. optionsDiv.children[1].innerHTML += '<div><strong>(X)</strong><label><input type="checkbox" id="optnAutoFire">Auto fire</label></div>';
  57. optionsDiv.children[1].innerHTML += '<div><strong>(C)</strong><label><input type="checkbox" id="optn4x3">4:3 aspect</label></div>';
  58. optionsDiv.children[1].innerHTML += '<div><strong>(V)</strong><label><input type="checkbox" id="optnDarkTheme">Dark theme</label></div>';
  59. optionsDiv.children[2].innerHTML += 'Mod by condoriano. <a style="color: blue; text-decoration: none;" target="_blank" href="https://gf.zukizuki.org/en/scripts/19892-diep-io-auto-respawn-mod">Homepage</a> - <a style="color: blue; text-decoration: none;" target="_blank" href="http://pastebin.com/raw/MQGQLuiy">Source</a> <form style="display: inline-block;" id="donate-mod" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"><input name="cmd" value="_donations" type="hidden"><input name="business" value="keyzint@gmail.com" type="hidden"><input name="lc" value="US" type="hidden"><input name="item_name" value="Donation" type="hidden"><input name="no_note" value="0" type="hidden"><input name="currency_code" value="USD" type="hidden"><input name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest" type="hidden"><input style="height: 11px; vertical-align: bottom; margin-left: 5px;" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" alt="PayPal btn" border="0" type="image"><img src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" alt="" height="1" border="0" width="1"></form>';
  60.  
  61. popupsDiv = document.createElement('div');
  62. popupsDiv.id = 'notificationPopups';
  63. popupsDiv.style = 'position: absolute; display: flex; flex-direction: column-reverse; bottom: 10px; left: 210px; width: 260px; max-height: 200px; overflow: hidden; font-family: Ubuntu;';
  64. document.body.insertBefore(popupsDiv, optionsDiv.nextElementSibling);
  65. optionsDiv.children[0].getElementsByTagName('a')[0].onclick = function(e) { toggleOptions(); e.preventDefault(); };
  66.  
  67. var options = optionsDiv.children[1];
  68. for(var i = 0; i < options.children.length; i++) {
  69. options.children[i].style = 'display: inline-block; width: 50%; margin: 2px 0px;';
  70. options.children[i].children[0].style = 'display: inline-block; width: 18px;';
  71. options.children[i].children[1].style = 'position: relative; top: 1px;';
  72. options.children[i].children[1].children[0].style = 'position: relative; top: 2px;';
  73. }
  74. }
  75. editPanels();
  76.  
  77. var inputs = document.getElementsByTagName('input');
  78. for(var i = 0; i < inputs.length; i++) {
  79. if(!inputs[i].id) continue;
  80. if(localStorage.getItem(inputs[i].id) !== null) {
  81. if(inputs[i].type == 'checkbox') inputs[i].checked = JSON.parse(localStorage.getItem(inputs[i].id));
  82. else inputs[i].value = localStorage.getItem(inputs[i].id);
  83. }
  84. inputs[i].addEventListener('change', onInputsChanged);
  85. }
  86. function onInputsChanged() {
  87. if(this.id == 'optnAutoRespawn' && this.checked) respawnPlayer();
  88. else if(this.id == 'optnAutoFire') canvas.dispatchEvent(new MouseEvent(this.checked ? 'mousedown' : 'mouseup'));
  89. else if(this.id == 'optn4x3') toggle4x3(this.checked);
  90. if(this != nick) createPopup(this.parentNode.textContent + ' <span style="color: ' + (this.checked ? '#9D2;">Enabled</span>' : '#F33;">Disabled</span>'));
  91. if(this.type == 'checkbox') localStorage.setItem(this.id, this.checked);
  92. else localStorage.setItem(this.id, this.value);
  93. }
  94. function toggle4x3(enabled) {
  95. if(enabled) {
  96. canvas.setAttribute('width', window.innerHeight * 4 / 3 + 'px');
  97. canvas.style.width = window.innerHeight * 4 / 3 + 'px';
  98. }
  99. else {
  100. canvas.setAttribute('width', window.innerWidth);
  101. canvas.style.width = '';
  102. }
  103. optionsDiv.style.left = canvas.width / 2 + 'px';
  104. }
  105. document.addEventListener('keydown', function(e) {
  106. var key = e.keyCode || e.which;
  107. if(key == 27) toggleOptions();
  108. if(document.activeElement == nick) { if(key == 13) onPlayerSpawn_Pre(); }
  109. else {
  110. if(e.ctrlKey || e.altKey) return;
  111. if(key == 90) document.getElementById('optnAutoRespawn').click();
  112. else if(key == 88) document.getElementById('optnAutoFire').click();
  113. else if(key == 67) document.getElementById('optn4x3').click();
  114. else if(key == 86) document.getElementById('optnDarkTheme').click();
  115. }
  116. });
  117. function toggleOptions() {
  118. optionsDiv.style.display = optionsDiv.style.display == 'none' ? 'block' : 'none';
  119. keepOptionOpen = keepOptionOpen ? false : true;
  120. }
  121. function createPopup(msg, displayTime=2000, bgColor='rgba(0,0,0,0.7)') {
  122. var popup = document.createElement('div');
  123. popup.style = 'display: table; background-color: ' + bgColor + '; color: #DDD; margin: 2px 0px; max-width: 260px; padding: 0px 16px 2px 16px; border-radius: 30px; font-size: 12px;';
  124. popup.innerHTML = msg;
  125. popupsDiv.insertBefore(popup, popupsDiv.firstChild);
  126. setTimeout(function() { popup.remove(); }, displayTime);
  127. }
  128.  
  129. var observer = new MutationObserver(function(changes) {
  130. changes.forEach(function(change) {
  131. if(nick.parentElement.style.display == 'none') {
  132. onPlayerSpawn();
  133. playerAlive = true;
  134. }
  135. else {
  136. if(playerAlive == -1) onGameLoad();
  137. else if(playerAlive === true) onPlayerDeath();
  138. playerAlive = false;
  139. }
  140. });
  141. });
  142. observer.observe(nick.parentElement, { attributes: true, attributeFilter: ['style'] });
  143.  
  144. function onGameLoad() {
  145. nick.value = localStorage.getItem('textInput');
  146. optionsDiv.style.display = 'block';
  147. if(document.getElementById('optnAutoRespawn').checked) setTimeout(function() { respawnPlayer(); }, 1000);
  148. if(document.getElementById('optn4x3').checked) toggle4x3(true);
  149. }
  150. function onPlayerSpawn_Pre() { if(!keepOptionOpen) optionsDiv.style.display = 'none'; }
  151. function onPlayerSpawn() {
  152. currentTank = '';
  153. for(var i = 0; i < statInfo.level.length; i++) statInfo.level[i] = 0;
  154. if(document.getElementById('optnAutoFire').checked) canvas.dispatchEvent(new MouseEvent('mousedown'));
  155. }
  156. function onPlayerDeath() {
  157. if(document.getElementById('optnAutoRespawn').checked) respawnPlayer();
  158. else optionsDiv.style.display = 'block';
  159. }
  160. function respawnPlayer() {
  161. nick.focus();
  162. if(navigator.userAgent.toLowerCase().indexOf('firefox') != -1) {
  163. window.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 13 }));
  164. window.dispatchEvent(new KeyboardEvent('keyup', { keyCode: 13 }));
  165. }
  166. else {
  167. var eventObj;
  168. eventObj = document.createEvent("Events"); eventObj.initEvent("keydown", true, true); eventObj.keyCode = 13; window.dispatchEvent(eventObj);
  169. eventObj = document.createEvent("Events"); eventObj.initEvent("keyup", true, true); eventObj.keyCode = 13; window.dispatchEvent(eventObj);
  170. }
  171.  
  172. if(!keepOptionOpen) optionsDiv.style.display = 'none';
  173. }
  174. ['blur', 'focus'].forEach(function(e) {
  175. window.addEventListener(e, function() {
  176. if(document.getElementById('optnAutoFire').checked) canvas.dispatchEvent(new MouseEvent('mousedown'));
  177. holdingKey = {};
  178. });
  179. });
  180. canvas.addEventListener('click', function() {
  181. if(document.getElementById('optnAutoFire').checked) {
  182. canvas.dispatchEvent(new MouseEvent('mouseup'));
  183. canvas.dispatchEvent(new MouseEvent('mousedown'));
  184. }
  185. });
  186. window.addEventListener('resize', function() { if(document.getElementById('optn4x3').checked) toggle4x3(true); });
  187.  
  188. function modCanvas() {
  189. currentTank = '';
  190. tankInfo = {
  191. 'tankList': {
  192. 'Twin': [ 'Triple Shot', 'Quad Tank', 'Twin Flank' ],
  193. 'Sniper': [ 'Assassin', 'Overseer', 'Hunter' ],
  194. 'Machine Gun': [ 'Destroyer', 'Gunner' ],
  195. 'Flank Guard': [ 'Quad Tank', 'Twin Flank', 'Tri Angle' ],
  196. 'Triple Shot': [ 'Triplet', 'Penta Shot' ],
  197. 'Quad Tank': [ 'Octo Tank' ],
  198. 'Twin Flank': [ 'Octo Tank', 'Triple Twin' ],
  199. 'Overseer': [ 'Overlord', 'Necromancer' ],
  200. 'Assassin': [ 'Stalker' ],
  201. },
  202. 'titlePos': [ 59, 22 ],
  203. 'buttonWidth': 62,
  204. 'buttonHeight': 62,
  205. 'buttonX': 36,
  206. 'buttonY': [ 44, 117, 190, 263 ],
  207. };
  208. statInfo = {
  209. 'name': [ 'Health Regen', 'Max Health', 'Body Damage', 'Bullet Speed', 'Bullet Penetration', 'Bullet Damage', 'Reload', 'Movement Speed' ],
  210. 'color': [ 'FCAD76', 'F943FF', '8543FF', '437FFF', 'FFDE43', 'FF4343', '82FF43', '43FFF9' ],
  211. 'oldcolor': [ 'FFAA55', 'FF55FF', 'AA55FF', '55AAFF', 'FFFF55', 'FF3333', '55FF55', '55FFFF' ],
  212. 'level': [ 0, 0, 0, 0, 0, 0, 0, 0 ],
  213. 'buttonWidth': 26,
  214. 'buttonHeight': 9,
  215. 'buttonX': 138,
  216. 'buttonY': [ 540, 556, 572, 588, 604, 620, 636, 652 ],
  217. };
  218.  
  219. document.addEventListener('keydown', function(e) {
  220. var key = e.keyCode || e.which;
  221. if(e.ctrlKey || e.altKey) return;
  222. if(key >= 49 && key <= 56) {
  223. if(holdingKey[key]) return;
  224. var upgrade = key - 49;
  225. if(e.shiftKey) handleTankUpgrade(upgrade, true);
  226. handleStatUpgrade(upgrade, true);
  227. }
  228. holdingKey[key] = true;
  229. });
  230. document.addEventListener('keyup', function(e) {
  231. var key = e.keyCode || e.which;
  232. holdingKey[key] = false;
  233. });
  234. function populatePoses() {
  235. for(var i = 0; i < tankInfo.buttonY.length; i++) tankInfo.buttonY[i] = 44 + i * 73;
  236. for(i = 0; i < statInfo.name.length; i++) statInfo.buttonY[i] = canvas.height - 143 + i * 16;
  237. }
  238. populatePoses();
  239. window.addEventListener('resize', populatePoses);
  240. canvas.addEventListener('click', function(e) {
  241. if(canvas.style.cursor == 'pointer') {
  242. for(var i = 0; i < statInfo.name.length; i++) {
  243. if(e.clientY >= tankInfo.buttonY[i] && e.clientY <= tankInfo.buttonY[i] + tankInfo.buttonHeight && e.clientX >= tankInfo.buttonX && e.clientX <= tankInfo.buttonX + tankInfo.buttonWidth) handleTankUpgrade(i);
  244. else if(e.clientY >= statInfo.buttonY[i] && e.clientY <= statInfo.buttonY[i] + statInfo.buttonHeight && e.clientX >= statInfo.buttonX && e.clientX <= statInfo.buttonX + statInfo.buttonWidth) handleStatUpgrade(i);
  245. }
  246. }
  247. });
  248. function handleTankUpgrade(upgrade, byKey) {
  249. if(byKey) {
  250. var ctx = canvas.getContext("2d");
  251. var imgData = ctx.getImageData(tankInfo.titlePos[0], tankInfo.titlePos[1], 1, 1);
  252. if(imgData.data[0] >= 220 && imgData.data[1] >= 220 && imgData.data[2] >= 220) simulateClick(tankInfo.buttonX, tankInfo.buttonY[upgrade]);
  253. else return;
  254. }
  255. if(currentTank === '') currentTank = Object.keys(tankInfo.tankList)[upgrade];
  256. else currentTank = tankInfo.tankList[currentTank][upgrade];
  257. if(currentTank) createPopup('Tank upgrade: <span style="color: #FA2;">' + currentTank + '</span>', 4000, '#500');
  258. }
  259. function handleStatUpgrade(upgrade, byKey) {
  260. var ctx = canvas.getContext("2d");
  261. var imgData = ctx.getImageData(statInfo.buttonX, statInfo.buttonY[upgrade] - 1, 1, 2);
  262. if(imgData.data[0] < 90 && imgData.data[1] < 90 && imgData.data[2] < 90) {
  263. if(isStatOpen(imgData)) {
  264. if(statInfo.level[upgrade]) statInfo.level[upgrade]++;
  265. else {
  266. imgData = ctx.getImageData(26, statInfo.buttonY[upgrade], 1, 1);
  267. if(imgData.data[0] < 90 && imgData.data[1] < 90 && imgData.data[2] < 90) statInfo.level[upgrade]++;
  268. }
  269. if(statInfo.level[upgrade] <= 7) createPopup('Upgraded level ' + statInfo.level[upgrade] + ' <span style="color: #' + statInfo.color[upgrade] + '">' + statInfo.name[upgrade] + '</span>');
  270. }
  271. }
  272. }
  273. function isStatOpen(imgData) {
  274. if(document.getElementById('optnDarkTheme').checked) {
  275. var low, high;
  276. for(var i=4; i<=6; i++) {
  277. if(imgData.data[i] > 180 && imgData.data[i] < 200) high = true;
  278. else if(imgData.data[i] > 40 && imgData.data[i] < 100) low = true;
  279. }
  280. if(low && high) return true;
  281. }
  282. else if(document.getElementById('optnDarkTheme').checked === false && (imgData.data[4] > 220 || imgData.data[5] > 220 || imgData.data[6] > 220)) return true;
  283. }
  284. return false;
  285. }
  286. function simulateClick(x,y) {
  287. var ev = new MouseEvent('mousemove', { 'clientX': x, 'clientY': y }); canvas.dispatchEvent(ev);
  288. ev = new MouseEvent('mousedown', { 'clientX': x, 'clientY': y }); canvas.dispatchEvent(ev);
  289. ev = new MouseEvent('mouseup', { 'clientX': x, 'clientY': y }); canvas.dispatchEvent(ev);
  290. }
  291. modCanvas();