Bloble.io Zoom The Patch

Zoom Hack.

  1. // ==UserScript==
  2. // @name Bloble.io Zoom The Patch
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Zoom Hack.
  6. // @author IMPERATOR
  7. // @match http://bloble.io/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. window.UIList = window.UIList || [];
  12. window.initFuncs = window.initFuncs || [];
  13. window.statusItems = window.statusItems || [];
  14.  
  15. window.sendIndex = 0;
  16. window.loops = 0;
  17. window.hasSentTarget = false;
  18. window.usePatch = true;
  19. window.cache = [];
  20. window.cacheHeight = 0;
  21. window.cacheIndexes = 0;
  22. window.shift = false;
  23. window.sendFrequency = 1E3 / 15
  24. window.UIList.push({
  25. level: 3,
  26. x: 0,
  27. description: 'Zoom Patch',
  28. html: '<div id="patch" onclick=patch()>Disable ZP</div>'
  29. });
  30.  
  31. window.statusItems.push({
  32. name: 'Zoom Patch',
  33. order: 2,
  34. value: function () {
  35. return usePatch ? 'On' : 'Off';
  36. }
  37. });
  38.  
  39. window.patch = function () {
  40. var el = document.getElementById('patch');
  41. if (usePatch) {
  42. usePatch = false
  43. socket.emit("2", Math.round(camX), Math.round(camY))
  44. el.textContent = 'Enable ZP'
  45. } else {
  46. usePatch = true;
  47. el.textContent = 'Disable ZP';
  48. populate();
  49. }
  50. window.statusBar();
  51. return usePatch;
  52. }
  53.  
  54.  
  55. function populate() {
  56. if (!usePatch) return;
  57. cacheHeight = Math.round(maxScreenHeight / 1080);
  58. cacheIndexes = cacheHeight * cacheHeight - 1;
  59. for (var i = cache.length; i < cacheIndexes; i++) {
  60. cache[i] = spiral(i);
  61. }
  62. }
  63. populate();
  64.  
  65.  
  66. window.addEventListener('keyup', function (a) {
  67. a = a.keyCode ? a.keyCode : a.which;
  68. if (a == 70) { // F to out
  69. (maxScreenHeight = 30000, maxScreenWidth = 53333, resize(true));
  70. cameraSpd = (shift ? 1.8 : .85) * (Math.log(maxScreenHeight / 1080) + 1)
  71. populate()
  72. }
  73. if (a == 67) { // C to zoom in
  74. (maxScreenHeight = 1080, maxScreenWidth = 1920, resize(true))
  75. cameraSpd = shift ? 1.8 : .85;
  76. populate()
  77. }
  78. if (a === 16) {
  79. shift = false;
  80. cameraSpd = .85 * (Math.log(maxScreenHeight / 1080) + 1);
  81. }
  82.  
  83. })
  84. window.addEventListener('keydown', function (a) {
  85. a = a.keyCode ? a.keyCode : a.which;
  86. if (a === 16) {
  87. shift = true;
  88. cameraSpd = 1.8 * (Math.log(maxScreenHeight / 1080) + 1);
  89. }
  90. })
  91.  
  92. function zoom(a) {
  93. a = window.event || a;
  94. a.preventDefault();
  95. a.stopPropagation();
  96. scroll = Math.max(-1, Math.min(1, a.wheelDelta || -a.detail))
  97. if (scroll == -1) { //zoom out
  98. if (maxScreenHeight < 30000) {
  99. (maxScreenHeight += 250, maxScreenWidth += 250, resize(true));
  100. cameraSpd = (shift ? 1.8 : .85) * (Math.log(maxScreenHeight / 1080) + 1)
  101. scroll = 0
  102. populate()
  103. }
  104. }
  105.  
  106. if (scroll == 1) { //zoom in
  107. if (maxScreenHeight > 1080) {
  108. (maxScreenHeight -= 250, maxScreenWidth -= 250, resize(true))
  109. cameraSpd = (shift ? 1.8 : .85) * (Math.log(maxScreenHeight / 1080) + 1)
  110. scroll = 0
  111. populate()
  112. }
  113. }
  114. }
  115. mainCanvas.addEventListener ? (window.addEventListener("mousewheel", zoom, !1),
  116. mainCanvas.addEventListener("DOMMouseScroll", zoom, !1)) : window.attachEvent("onmousewheel", zoom);
  117.  
  118. function spiral(n) {
  119. var r = Math.floor((Math.sqrt(n + 1) - 1) / 2) + 1;
  120. var p = (8 * r * (r - 1)) / 2;
  121. var en = r * 2;
  122. var a = (1 + n - p) % (r * 8);
  123. var pos = [0, 0, r];
  124. switch (Math.floor(a / (r * 2))) {
  125. case 0:
  126. pos[0] = a - r;
  127. pos[1] = -r;
  128. break;
  129. case 1:
  130. pos[0] = r;
  131. pos[1] = (a % en) - r;
  132. break;
  133. case 2:
  134. pos[0] = r - (a % en);
  135. pos[1] = r;
  136. break;
  137. case 3:
  138. pos[0] = -r;
  139. pos[1] = r - (a % en);
  140. break;
  141. }
  142. return pos;
  143. }
  144.  
  145. window.initFuncs.push(function () {
  146. var js = window.updateGameLoop.toString();
  147.  
  148. var ind = js.indexOf('if (gameState && mapBounds) {');
  149. if (ind === -1) ind = js.indexOf('if (gameState&&mapBounds) {');
  150. if (ind === -1) ind = js.indexOf('if(gameState&&mapBounds){');
  151.  
  152. var ind2 = js.indexOf('}', ind);
  153.  
  154. var n = js.substring(0, ind) + 'if(gameState&&mapBounds){if(camXS||camYS)camX+=camXS*cameraSpd*a,camY+=camYS*cameraSpd*a;player.x+camX<mapBounds[0]?camX=mapBounds[0]-player.x:player.x+camX>mapBounds[0]+mapBounds[2]&&(camX=mapBounds[0]+mapBounds[2]-player.x);player.y+camY<mapBounds[1]?camY=mapBounds[1]-player.y:player.y+camY>mapBounds[1]+mapBounds[3]&&(camY=mapBounds[1]+mapBounds[3]-player.y);if(currentTime-lastCamSend>=sendFrequency)if(lastCamSend=currentTime,usePatch&&cacheIndexes)if(lastCamX!=camX||lastCamY!=camY)lastCamX=camX,lastCamY=camY,loop=sendIndex=0;else{if(4>=loop){if(sendIndex%2)(sendIndex-1)%6?socket.emit("2",Math.round(camX),Math.round(camY)):socket.emit("2",0,0);else{var index=sendIndex/2;index>=cacheIndexes?(sendIndex=0,loop++):socket.emit("2",Math.round(camX+1920*cache[index][0]),Math.round(camY+1080*cache[index][1]))}hasSentTarget=!1;sendIndex++}}else lastCamX==camX&&lastCamY==camY&&hasSentTarget||(lastCamX=camX,hasSentTarget=!0,lastCamY=camY,loop=0,socket.emit("2",Math.round(camX),Math.round(camY)))}' +
  155. js.substr(ind2 + 1);
  156. n = n.substring(n.indexOf('{') + 1, n.lastIndexOf('}'));
  157. window.updateGameLoop = new Function('a', n)
  158.  
  159. });
  160.  
  161. window.makeUI = function () {
  162. if (window.hasMadeUI) return;
  163. window.hasMadeUI = true;
  164. window.statusItems.sort(function (a, b) {
  165. return a.order - b.order;
  166. })
  167. var levels = [];
  168. window.UIList.forEach((item) => {
  169. if (!levels[item.level]) levels[item.level] = [];
  170. levels[item.level].push(item)
  171. })
  172.  
  173. levels = levels.filter((a) => {
  174. if (a) {
  175. a.sort(function (a, b) {
  176. return a.x - b.x;
  177. })
  178. return true;
  179. } else {
  180. return false;
  181. }
  182. })
  183.  
  184. var headAppend = document.getElementsByTagName("head")[0],
  185. style = document.createElement("div");
  186.  
  187. var toast = document.createElement('div');
  188. toast.id = "snackbar";
  189. var css = document.createElement('div');
  190.  
  191. css.innerHTML = '<style>\n\
  192. #snackbar {\n\
  193. visibility: hidden;\n\
  194. min-width: 250px;\n\
  195. margin-left: -125px;\n\
  196. background-color: rgba(40, 40, 40, 0.5);\n\
  197. color: #fff;\n\
  198. text-align: center;\n\
  199. border-radius: 4px;\n\
  200. padding: 10px;\n\
  201. font-family: "regularF";\n\
  202. font-size: 20px;\n\
  203. position: fixed;\n\
  204. z-index: 100;\n\
  205. left: 50%;\n\
  206. top: 30px;\n\
  207. }\n\
  208. #snackbar.show {\n\
  209. visibility: visible;\n\
  210. -webkit-animation: fadein 0.5s;\n\
  211. animation: fadein 0.5s;\n\
  212. }\n\
  213. #snackbar.hide {\n\
  214. visibility: visible;\n\
  215. -webkit-animation: fadeout 0.5s;\n\
  216. animation: fadeout 0.5s;\n\
  217. }\n\
  218. @-webkit-keyframes fadein {\n\
  219. from {top: 0; opacity: 0;}\n\
  220. to {top: 30px; opacity: 1;}\n\
  221. }\n\
  222. @keyframes fadein {\n\
  223. from {top: 0; opacity: 0;}\n\
  224. to {top: 30px; opacity: 1;}\n\
  225. }\n\
  226. @-webkit-keyframes fadeout {\n\
  227. from {top: 30px; opacity: 1;}\n\
  228. to {top: 0; opacity: 0;}\n\
  229. }\n\
  230. @keyframes fadeout {\n\
  231. from {top: 30px; opacity: 1;}\n\
  232. to {top: 0; opacity: 0;}\n\
  233. }\n\
  234. </style>'
  235. var height = levels.length * (14 + 19) + (levels.length - 1) * 7 + 15;
  236. style.innerHTML = "<style>\n\
  237. #noobscriptUI, #noobscriptUI > div > div {\n\
  238. background-color:rgba(40,40,40,.5);\n\
  239. margin-left: 3px;\n\
  240. border-radius:4px;\n\
  241. pointer-events:all\n\
  242. }\n\
  243. #noobscriptUI {\n\
  244. top: -" + (height + 12) + "px;\n\
  245. transition: 1s;\n\
  246. margin-left:10px;\n\
  247. position:absolute;\n\
  248. padding-left:24px;\n\
  249. margin-top:9px;\n\
  250. padding-top:15px;\n\
  251. width:580px;\n\
  252. height: " + height + "px;\n\
  253. font-family:arial;\n\
  254. left:25%\n\
  255. }\n\
  256. #noobscriptUI:hover{\n\
  257. top:0px\n\
  258. }\n\
  259. #noobscriptUI > div > div {\n\
  260. color:#fff;\n\
  261. padding:7px;\n\
  262. height:19px;\n\
  263. display:inline-block;\n\
  264. cursor:pointer;\n\
  265. font-size:15px\n\
  266. }\n\
  267. </style>"
  268.  
  269. headAppend.appendChild(style);
  270. headAppend.appendChild(css);
  271.  
  272.  
  273. var contAppend = document.getElementById("gameUiContainer"),
  274. menuA = document.createElement("div");
  275.  
  276. var code = ['<div id="noobscriptUI">\n'];
  277.  
  278. levels.forEach((items, i) => {
  279. code.push(i === 0 ? ' <div>\n' : ' <div style="margin-top:7px;">\n');
  280. items.forEach((el) => {
  281. code.push(' ' + el.html + '\n');
  282. })
  283. code.push(' </div>\n');
  284. })
  285. code.push(' <div id="confinfo" style="margin-top:4px; color: white; text-align: center; font-size: 10px; white-space:pre"></div>')
  286. code.push('</div>');
  287.  
  288. menuA.innerHTML = code.join("");
  289. contAppend.insertBefore(menuA, contAppend.firstChild)
  290. contAppend.appendChild(toast)
  291. var toastTimeout = false;
  292. window.showToast = function (msg) {
  293. toast.textContent = msg;
  294.  
  295. if (toastTimeout) clearTimeout(toastTimeout);
  296. else toast.className = "show";
  297. toastTimeout = setTimeout(function () {
  298. toast.className = 'hide'
  299. setTimeout(function () {
  300. toast.className = '';
  301. }, 400);
  302. toastTimeout = false;
  303. }, 3000);
  304. }
  305. window.statusBar = function () {
  306. var el = document.getElementById('confinfo');
  307. var text = [];
  308.  
  309. window.statusItems.forEach((item, i) => {
  310. if (i !== 0) text.push(' ');
  311. if (item.name) text.push(item.name + ': ');
  312. text.push(item.value());
  313. })
  314.  
  315. el.textContent = text.join('');
  316. }
  317. window.statusBar();
  318.  
  319. window.initFuncs.forEach((func) => {
  320. func();
  321. })
  322. }
  323. setTimeout(() => {
  324. window.makeUI();
  325. }, 1000)