Advertisement
Guest User

cursors.io hack

a guest
Jun 25th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 49.39 KB | None | 0 0
  1. /*
  2. ___ _ _ _ __ ___ ___ _ __ ___ _ ___
  3. / __| | | | `__/ __|/ _ \| `__/ __| | |/ _ \
  4. | (__| |_| | | \__ \ (_) | | \__ \_| | (_) |
  5. \___|\__,_|_| |___/\___/|_| |___(_)_|\___/
  6.  
  7. script for texting and drawing in CURSORS.IO
  8. //done, no pathfinder
  9. */
  10. /* How to use:
  11. 1. Go to cursors.io, open console (ctrl + shift + j or F12)
  12. and paste this entire script into the console, then hit enter.
  13. 2. To type: type message and hit enter (shift+enter for new row)
  14. 3. To move your cursor only when clicking: press numpad .
  15. Use it to pass red walls levels ;)
  16. To move your cursor normally: press numpad . again
  17. 4. To draw a circle: press numpad 0
  18. To stop drawing a circle: press numpad 0 again
  19. 5. To draw arrows, use the arrow keys
  20. 6. To draw different images press numpad 1 - numpad 9 keys
  21. 7. To make drawings bigger/smaller use numpad + and -
  22. 8. Reset drawing size with numpad *
  23. 9. To show/hide cursors ids: press F8
  24. 10. Change ids position with: F9
  25. 11. To show this help: press F4
  26. */
  27.  
  28. var A = window;
  29. var E = document;
  30. var posX, posY;
  31. var lastX, lastY;
  32. var serverPosX, serverPosY;
  33. var initialLoad = true;
  34. var clicksCount = 3;
  35. var auraEnabled = false;
  36. var auraTime = 0;
  37. var auraRadius = 10;
  38. var movementEnabled = true;
  39. var showcursorsid = false;
  40.  
  41. var fontSize = 2;
  42. var kerning = 3;
  43. var alphabet = {
  44. 33:[ [0,1,2,1],[2.5,1,3,1] ],
  45. 34:[[0,0.5,1,0.5],[0,1.25,1,1.25]],
  46. 35:[ [0.5,-0.25,0.5,2.3], [1.5,-0.25,1.5,2.3], [-0.25,0.5,2.3,0.5], [-0.25,1.5,2.3,1.5] ],
  47. 39:[[0,0.5,1,0.5]], // '
  48. 40:[[0,2,0.5,1],[0.5,1,1.5,1],[1.5,1,2,2]],
  49. 41:[[0,0,0.5,1],[0.5,1,1.5,1],[1.5,1,2,0]],
  50. 43:[ [0,1,2,1],[1,0,1,2] ],
  51. 44:[[2.5,0,3.5,0]],
  52. 45:[ [0.6,0.3,0.6,1.7] ],
  53. 46:[[2,0,1.5,0]],
  54. 47:[ [2,0.4,0,1.6] ],
  55. 48:[[2,0,0,0],[0,0,0,2],[0,2,2,2],[2,2,2,0]],
  56. 49:[[0,1,2,1],[1,0,0,1],[2,0,2,2]],
  57. 50:[[0,0,0,2],[0,2,1,2],[1,2,1,0],[1,0,2,0],[2,0,2,2]],
  58. 51:[[0,0,0,2],[0,2,2,2],[2,2,2,0],[1,0,1,2]],
  59. 52:[[0,0,1,0],[1,0,1,2],[0,2,2,2]],
  60. 53:[[0,2,0,0],[0,0,1,0],[1,0,1,2],[1,2,2,2],[2,2,2,0]],
  61. 54:[[0,2,0,0],[0,0,2,0],[2,0,2,2],[2,2,1,2],[1,2,1,0]],
  62. 55:[[0,0,0,2],[0,2,2,0]],
  63. 56:[[0,0,0,2],[0,2,2,2],[2,2,2,0],[2,0,0,0],[1,0,1,2]],
  64. 57:[[0,0,1,0],[1,0,1,2],[0,2,2,2],[0,0,0,2],[2,0,2,2]],
  65. 58:[ [0.5,0,1,0],[1.5,0,2,0] ],
  66. 59:[ [0.5,0,1,0],[2.2,0,3.5,0] ],
  67. 61:[ [0.5,0,0.5,2], [1.5,0,1.5,2] ],
  68. 63:[[1,0,0,0],[0,0,0,2],[0,2,1,2],[1,2,1,1],[1,1,2,1],[2.5,1,3,1] ],
  69. 92:[ [0,0.4,2,1.6] ],
  70. 95:[ [2,0,2,2] ],
  71. 96:[[0,0.5,1,0.5]], // ` display same as 39
  72. 97:[[2,0,0,0],[0,2,0,0],[0,2,2,2],[1,0,1,2]],
  73. 98:[[2,0,0,0],[0,0,0,2],[0,2,2,2],[2,2,2,0],[1,0,1,2]],
  74. 99:[[2,2,2,0],[2,0,0,0],[0,0,0,2]],
  75. 100:[[2,0,0,0],[0,0,0,1],[0,1,1,2],[1,2,2,1],[2,1,2,0]],
  76. 101:[[2,2,2,0],[2,0,0,0],[0,0,0,2],[1,0,1,2]],
  77. 102:[[2,0,0,0],[0,0,0,2],[1,0,1,2]],
  78. 103:[[1,1,1,2],[1,2,2,2],[2,2,2,0],[2,0,0,0],[0,0,0,2]],
  79. 104:[[0,0,2,0],[0,2,2,2],[1,0,1,2]],
  80. 105:[[0,0,0,2],[0,1,2,1],[2,0,2,2]],
  81. 106:[[0,0,0,2],[0,1,2,1],[2,0,2,1]],
  82. 107:[[0,0,2,0],[1,0,0,2],[1,0,2,2]],
  83. 108:[[0,0,2,0],[2,0,2,2]],
  84. 109:[[0,0,2,0],[0,0,2,1],[2,1,0,2],[0,2,2,2]],
  85. 110:[[0,0,2,0],[0,0,2,2],[0,2,2,2]],
  86. 111:[[2,0,0,0],[0,0,0,2],[0,2,2,2],[2,2,2,0]],
  87. 112:[[2,0,0,0],[0,0,0,2],[0,2,1,2],[1,2,1,0]],
  88. 113:[[2,0,0,0],[0,0,0,2],[0,2,2,2],[2,2,2,0],[1,1,2,2]],
  89. 114:[[2,0,0,0],[0,0,0,2],[0,2,1,2],[1,2,1,0],[1,1,2,2]],
  90. 115:[[0,0,0,2],[1,0,1,2],[2,0,2,2],[0,0,1,0],[1,2,2,2]],
  91. 116:[[0,0,0,2],[0,1,2,1]],
  92. 117:[[0,0,2,0],[0,2,2,2],[2,0,2,2]],
  93. 118:[[0,0,2,1],[0,2,2,1]],
  94. 119:[[0,0,2,0],[0,2,2,2],[2,0,1,1],[2,2,1,1]],
  95. 120:[[0,0,2,2],[2,0,0,2]],
  96. 121:[[0,0,1,1],[0,2,1,1],[2,1,1,1]],
  97. 122:[[0,0,0,2],[0,2,2,0],[2,0,2,2]],
  98. };
  99.  
  100. var imageScale = 1.0;
  101. var imgData = [
  102. /* arrow left */
  103. [[0,0,0,9],[0,0,-3,3],[0,0,3,3]],
  104.  
  105. /* arrow up */
  106. [[0,0,9,0],[0,0,3,-3],[0,0,3,3]],
  107.  
  108. /* arrow right */
  109. [[0,0,0,-9],[0,0,-3,-3],[0,0,3,-3]],
  110.  
  111. /* arrow down */
  112. [[0,0,-9,0],[0,0,-3,-3],[0,0,-3,3]],
  113.  
  114. /*star 5*/
  115. [[8,0,8,24],[8,24,24,4],[24,4,0,12],[0,12,24,20],[24,20,8,0]],
  116.  
  117. /* reversed star */
  118. [[0,4,24,12],[24,12,0,20],[0,20,16,0],[16,0,16,24],[16,24,0,4]],
  119.  
  120. /*tictactoe*/
  121. [[72,24,0,24],[0,48,72,48],[24,0,24,72],[48,0,48,72],[0,0,0,72],[0,72,72,72],[72,72,72,0],[72,0,0,0]],
  122.  
  123. /*pentashot*/
  124. [[50,16,66,17],[66,17,65,32],[51,26,72,36],[65,32,65,33],[72,36,64,52],[49,35,69,58],[69,58,54,71],[54,71,35,48],[49,65,33,70],[33,70,25,49],[16,46,16,63],[16,63,30,63],[50,16,51,19],[51,19,51,26],[51,26,49,35],[49,35,46,40],[46,40,43,43],[43,43,38,47],[38,47,32,49],[32,49,27,49],[27,49,24,49],[24,49,21,48],[21,48,16,46],[16,46,13,44],[13,44,10,41],[10,41,8,38],[8,38,5,32],[5,32,4,24],[4,24,5,18],[5,18,8,11],[8,11,12,7],[12,7,16,4],[16,4,21,2],[21,2,25,1],[25,1,31,1],[31,1,35,2],[35,2,40,4],[40,4,45,8],[45,8,48,13],[48,13,50,16]],
  125.  
  126. /*triforce*/
  127. [[20,0,0,10],[0,10,20,20],[20,20,20,0],[10,5,10,15],[10,15,20,10],[20,10,10,5],[2,9,2,11],[3,9,3,11],[4,8,4,12],[5,8,5,12],[6,7,6,13],[7,7,7,13],[8,6,8,14],[9,6,9,14],[12,4,12,6],[12,14,12,16],[13,4,13,6],[13,14,13,16],[14,3,14,7],[14,13,14,17],[15,3,15,7],[15,13,15,17],[16,2,16,8],[16,12,16,18],[17,2,17,8],[17,12,17,18],[18,1,18,9],[18,11,18,19],[19,1,19,9],[19,11,19,19]],
  128.  
  129. /*heart*/
  130. [[9,5,4,0],[4,0,2,0],[2,0,1,1],[4,10,9,5],[1,1,1,3],[1,3,3,5],[3,5,1,7],[1,7,1,9],[1,9,2,10],[2,10,4,10]],
  131.  
  132. /*dickboob*/
  133. [[78,21,53,17],[53,17,47,13],[47,13,42,14],[42,14,33,20],[33,20,12,30],[12,30,2,43],[2,43,1,61],[1,61,11,74],[11,74,27,81],[27,81,61,89],[61,89,79,98],[79,98,70,110],[70,110,67,120],[67,120,67,128],[67,128,32,132],[32,132,30,140],[30,140,35,148],[35,148,53,151],[53,151,68,147],[68,147,68,151],[68,151,61,156],[61,156,67,161],[67,161,70,156],[70,156,72,163],[72,163,74,156],[74,156,75,168],[75,168,82,169],[82,169,91,164],[91,164,92,157],[92,157,111,154],[111,154,128,142],[128,142,132,130],[132,130,136,129],[136,129,163,133],[163,133,165,130],[165,130,159,114],[159,114,152,105],[152,105,148,105],[148,105,148,119],[148,119,138,117],[138,117,145,103],[145,103,147,89],[147,89,181,85],[181,85,178,73],[178,73,166,61],[166,61,163,62],[163,62,161,68],[161,68,167,77],[167,77,146,79],[146,79,145,68],[145,68,137,53],[137,53,117,36],[80,110,82,117],[82,117,76,127],[76,127,65,128],[81,118,91,111],[75,126,78,142],[78,142,84,152],[84,152,92,157],[86,106,86,109],[55,144,57,142],[62,143,61,145],[95,125,99,124],[109,125,110,123],[113,130,116,127],[118,135,120,132],[54,18,49,24],[49,24,41,28],[41,28,35,26],[35,26,30,22],[33,25,37,34],[37,34,42,36],[42,36,50,34],[50,34,53,26],[53,26,54,18],[37,41,42,36],[50,34,56,33],[56,33,57,39],[57,39,54,46],[54,46,49,45],[49,45,50,39],[23,62,29,51],[29,51,40,48],[40,48,45,51],[45,51,48,57],[48,57,46,65],[46,65,39,72],[39,72,30,71],[30,71,25,67],[25,67,23,61],[27,63,33,64],[33,64,39,61],[39,61,42,54],[42,54,45,55],[45,55,44,61],[44,61,39,69],[39,69,29,69],[29,69,27,63],[68,20,48,73],[71,72,107,81],[107,81,114,79],[114,79,120,79],[120,79,121,84],[121,84,113,84],[113,84,120,88],[120,88,117,91],[117,91,110,90],[110,90,111,100],[111,100,107,100],[107,100,105,89],[105,89,70,78],[76,21,80,21],[80,21,87,8],[87,8,98,3],[98,3,105,3],[105,3,107,1],[107,1,108,1],[108,1,109,4],[109,4,116,10],[116,10,118,17],[118,17,115,35],[115,35,117,36],[115,35,105,33],[105,33,93,35],[93,35,80,39],[115,35,120,44],[120,44,120,59],[120,59,115,66],[115,66,108,72],[108,72,99,74],[99,74,93,73],[112,7,107,8],[107,8,102,7],[102,7,101,3],[102,48,105,44],[105,44,109,45],[109,45,112,49],[112,49,108,56],[108,56,104,55],[104,55,102,48],[105,49,106,48],[106,48,107,49],[107,49,106,50],[106,50,105,49]],
  134.  
  135. ];
  136.  
  137. function sa(f) {
  138. return f << 1;
  139. }
  140.  
  141. function ta(f) {
  142. return f << 1;
  143. }
  144.  
  145. function U() {
  146. return E.pointerLockElement === y || E.mozPointerLockElement === y || E.webkitPointerLockElement === y;
  147. }
  148.  
  149. function ba() {
  150. a.fillStyle = "#000000";
  151. a.font = "35px NovaSquare";
  152. a.fillText("Please do not embed our website, thank you.", 400 - a.measureText("Please do not embed our website, thank you.").width / 2, 300);
  153. a.font = "16px NovaSquare";
  154. a.fillText("Play http://cursors.io/", 400 - a.measureText("Play http://cursors.io/").width /
  155. 2, 330);
  156. top.location = "http://cursors.io";
  157. throw "Please do not embed our website, thank you.";
  158. }
  159.  
  160. function ua(f) {
  161. V(f);
  162. }
  163.  
  164. function W(f, b) {
  165. J = f;
  166. K = b;
  167. k = v = f;
  168. q = w = b;
  169. B = v << 1;
  170. C = w << 1;
  171. }
  172.  
  173. function Ma() {
  174. //var eng = document.body.childNodes[1].getElementsByTagName("a")[0];
  175. //eng.outerHTML = "<label style='float:right;'>Press F4 for help</label>";
  176. var eng = document.querySelectorAll("a[href='https://m28.studio/']");
  177. eng[0].outerHTML = "<label style='float:right;'>Press F4 for help</label>";
  178.  
  179. /*eng.href = "http://cursors.io/";
  180. eng.target = "_blank";
  181. eng.innerHTML = "More levels!";
  182. eng.style.visibility = "hidden";*/
  183. }
  184.  
  185. function va(f) {
  186. if (D) return L = !1, V(f), !1;
  187. U() ? X || (X = !0, W(k, q)) : (X = !1, D || M.checked || y.requestPointerLock && y.requestPointerLock());
  188. if (L) L = !1, Q();
  189. else if (V(f), (f.ctrlKey || f.shiftKey) && !H.checked) Y = !0, R = k, S = q;
  190. else if (100 < t - ca && v == k && w == q) {
  191. ca = t;
  192. I.push([v << 1, w << 1, t]);
  193. wa(v, w, clicksCount);
  194. var b = [v, w];
  195. N.push(b);
  196. setTimeout(function() {
  197. N.remove(b);
  198. }, 1E3);
  199. }
  200. return !1;
  201. }
  202.  
  203. function xa(f) {
  204. Y = !1;
  205. }
  206.  
  207. function ya() {
  208. A.localStorage && M && (A.localStorage.setItem("noCursorLock", M.checked ? "1" : "0"), A.localStorage.setItem("noDrawings", H.checked ? "1" : "0"));
  209. }
  210.  
  211. function V(f) {
  212. if (U()) {
  213. var b = f.webkitMovementX || f.mozMovementX || f.movementX || 0;
  214. f = f.webkitMovementY || f.mozMovementY || f.movementY || 0;
  215. 300 > Math.abs(b) + Math.abs(f) && (B += b, C += f, v = B >> 1, w = C >> 1);
  216. } else f.offsetX ? (B = f.offsetX, C = f.offsetY) : f.layerX && (B = f.layerX, C = f.layerY), v = B >> 1, w = C >> 1;
  217. lastX = posX;
  218. lastY = posY;
  219. posX = k;
  220. posY = q;
  221. if (Z(), !U() || v == k && w == q || (f = b = 0, v > k && (b = 1),
  222. w > q && (f = 1), v = k, w = q, B = (v << 1) + b, C = (w << 1) + f), Y && (R != k || S != q) && 50 < t - da) {
  223. b = R;
  224. f = S;
  225. var a = k,
  226. d = q;
  227. if (!D && null != u && u.readyState == WebSocket.OPEN) {
  228. var g = new ArrayBuffer(9),
  229. e = new DataView(g);
  230. e.setUint8(0, 3);
  231. e.setUint16(1, b, !0);
  232. e.setUint16(3, f, !0);
  233. e.setUint16(5, a, !0);
  234. e.setUint16(7, d, !0);
  235. u.Send(g);
  236. }
  237. R = k;
  238. S = q;
  239. da = t;
  240. }
  241. }
  242.  
  243. function Z() {
  244. ea(k, q) && Q();
  245. if (z(k, q)) {
  246. var a;
  247. a: {
  248. a = k;
  249. var b = q,
  250. c = [],
  251. d = new Uint8Array(12E4);
  252. c.push([a, b]);
  253. d[a + 400 * b] = 1;
  254. do {
  255. var g = c.shift(),
  256. e = g[0],
  257. g = g[1];
  258. if (!(0 > e || 0 > g || 400 <= e || 300 <= g)) {
  259. if (!z(e, g)) {
  260. a = {
  261. x: e,
  262. y: g
  263. };
  264. break a;
  265. }
  266. d[e - 1 + 400 * g] || (c.push([e - 1, g]), d[e - 1 + 400 * g] = 1);
  267. d[e + 1 + 400 * g] || (c.push([e + 1, g]), d[e + 1 + 400 * g] = 1);
  268. d[e + 400 * (g - 1)] || (c.push([e, g - 1]), d[e + 400 * (g - 1)] = 1);
  269. d[e + 400 * (g + 1)] || (c.push([e, g + 1]), d[e + 400 * (g + 1)] = 1);
  270. }
  271. } while (0 < c.length);
  272. a = {
  273. x: a,
  274. y: b
  275. };
  276. }
  277. k = a.x;
  278. q = a.y;
  279. }
  280. if (k != v || q != w) a = fa(k, q, v, w), k = a.x, q = a.y;
  281. ea(k, q) && Q();
  282. }
  283.  
  284. function next() {
  285. console.log("Next map");
  286. initialLoad = true;
  287. T.set(za);
  288. r = [];
  289. I = [];
  290. O = [];
  291. }
  292.  
  293. function ga(f) {
  294. a.imageSmoothingEnabled = f;
  295. a.mozImageSmoothingEnabled = f;
  296. a.oImageSmoothingEnabled = f;
  297. a.webkitImageSmoothingEnabled = f;
  298. }
  299.  
  300. function Aa() {
  301. next();
  302. console.log("Connected!");
  303. }
  304.  
  305. function Ba(a) {
  306. next();
  307. console.log("Socket closed: " + a.reason);
  308. }
  309.  
  310. function Ca(a) {
  311. console.log("Socket error");
  312. }
  313.  
  314. function Da(a, b) {
  315. for (var c = "", d = 0, g = 0; 0 != (g = a.getUint8(b)); ++b) d <<= 8, d |= g, g & 128 || (c += String.fromCharCode(d), d = 0);
  316. 0 != d && (c += String.fromCharCode(d));
  317. return [c, b + 1];
  318. }
  319.  
  320. function Ea(a, b) {
  321. setTimeout(function() {
  322. var c = a.getUint16(b, !0),
  323. d = 0;
  324. a: for (; d < c; d++) {
  325. for (var g = a.getUint16(b + 2 + 4 * d, !0), e = a.getUint16(b + 4 + 4 * d, !0), n = 0; n < N.length; n++) {
  326. var l = N[n];
  327. if (l[0] == g && l[1] == e) {
  328. N.splice(n, 1);
  329. continue a;
  330. }
  331. }
  332. I.push([g << 1, e << 1, t]);
  333. }
  334. }, 100);
  335. return b + 2 + 4 * a.getUint16(b, !0);
  336. }
  337.  
  338. function Fa(a, b) {
  339. !H.checked && setTimeout(function() {
  340. for (var c = a.getUint16(b, !0), d = 0; d < c; d++) {
  341. var g = a.getUint16(b + 2 + 8 * d, !0),
  342. e = a.getUint16(b + 4 + 8 * d, !0),
  343. n = a.getUint16(b + 6 + 8 * d, !0),
  344. l = a.getUint16(b + 8 + 8 * d, !0);
  345. O.push([g << 1, e << 1, n << 1, l << 1, t]);
  346. }
  347. }, 50);
  348. return b + 2 + 8 * a.getUint16(b, !0);
  349. }
  350.  
  351. function Ga(a) {
  352. buttonIndex = 0;
  353. initialLoad = false;
  354. a = a.data;
  355. var b = new DataView(a);
  356. switch (b.getUint8(0)) {
  357. case 0:
  358. ha = b.getUint32(1, !0);
  359. break;
  360. case 1:
  361. var c;
  362. ia = c = b.getUint16(1, !0);
  363. ja = 100 <= c;
  364. var d = [],
  365. g;
  366. for (g in F) F.hasOwnProperty(g) && d.push(g);
  367.  
  368. for (var e =
  369. 0; e < c; e++) {
  370. g = b.getUint32(3 + 8 * e, !0);
  371. var n = b.getUint16(7 + 8 * e, !0),
  372. l = b.getUint16(9 + 8 * e, !0);
  373. if (g != ha) {
  374. if (null != F[g]) {
  375. for (var p = 0; p < d.length; p++)
  376. if (d[p] == g) {
  377. d.splice(p, 1);
  378. break;
  379. }
  380. g = F[g];
  381. g.oldX = g.getX();
  382. g.oldY = g.getY();
  383. g.newX = n;
  384. g.newY = l;
  385. g.time = t;
  386. } else F[g] = new ka(n, l);
  387. } else {
  388. serverPosX = n;
  389. serverPosY = l;
  390. }
  391. }
  392. for (e = 0; e < d.length; e++) delete F[d[e]];
  393. c = Ea(b, 3 + 8 * c);
  394. g = b.getUint16(c, !0);
  395. c += 2;
  396. for (d = 0; d < g; d++) {
  397. a: for (n = b.getUint32(c, !0), e = 0; e < r.length; e++)
  398. if (r[e].id == n) {
  399. var k = r[e];
  400. if (1 == k.type)
  401. for (var n = k.x | 0, l = k.y | 0, p = k.width | 0, k = k.height | 0, m = l; m < l + k; ++m)
  402. for (var h =
  403. n; h < n + p; ++h) --T[h + 400 * m];
  404. r.splice(e, 1);
  405. break a;
  406. }c += 4;
  407. }
  408. g = b.getUint16(c, !0);
  409. c += 2;
  410. for (d = 0; d < g; d++) {
  411. a: {
  412. e = b.getUint32(c, !0);
  413. for (n = 0; n < r.length; n++)
  414. if (r[n].id == e) {
  415. e = r[n];
  416. break a;
  417. }
  418. e = {
  419. id: e
  420. };
  421. r.push(e);
  422. }
  423. c += 4;c = la(b, c, e);
  424. }
  425. c = Fa(b, c);
  426. if (a.byteLength < c + 4) break;
  427. aa = b.getUint32(c, !0);
  428. break;
  429. case 4:
  430. next();
  431. W(b.getUint16(1, !0), b.getUint16(3, !0));
  432. g = b.getUint16(5, !0);
  433. c = 7;
  434. for (d = 0; d < g; d++) e = {}, e.id = b.getUint32(c, !0), c += 4, c = la(b, c, e), r.push(e);
  435. a.byteLength >= c + 4 ? G = Math.max(G, b.getUint32(c, !0)) : a.byteLength >= c + 2 && (G = Math.max(G, b.getUint16(c, !0)));
  436. Z();
  437. break;
  438. case 5:
  439. W(b.getUint16(1, !0), b.getUint16(3, !0)), 9 <= b.byteLength ? G = Math.max(G, b.getUint32(5, !0)) : 7 <= b.byteLength && (G = Math.max(G, b.getUint16(5, !0))), Z();
  440. }
  441. }
  442.  
  443. function Q() {
  444. if (!(D || L || null == u || u.readyState != WebSocket.OPEN || k == J && q == K) && movementEnabled) {
  445. var a = new ArrayBuffer(9);
  446. b = new DataView(a);
  447. b.setUint8(0, 1);
  448. b.setUint16(1, k, !0);
  449. b.setUint16(3, q, !0);
  450. b.setUint32(5, G, !0);
  451. u.send(a);
  452. J = k;
  453. K = q;
  454. }
  455.  
  456. }
  457.  
  458. function Au() {
  459. Throttler.sendOut();
  460. if (auraEnabled) drawAura(J, K);
  461. }
  462.  
  463. function wa(a, b, numClicks) {
  464. if (!D && null != u && u.readyState == WebSocket.OPEN) {
  465. var c = new ArrayBuffer(9),
  466. d = new DataView(c);
  467. d.setUint8(0, 2);
  468. d.setUint16(1, a, !0);
  469. d.setUint16(3, b, !0);
  470. d.setUint32(5, G, !0);
  471. for (var i = 0; i < numClicks; i++) { u.Send(c); }
  472. }
  473. }
  474.  
  475. function la(f, b, c) {
  476. function d() {
  477. c.x = f.getUint16(b, !0);
  478. b += 2;
  479. c.y = f.getUint16(b, !0);
  480. b += 2;
  481. c.width = f.getUint16(b, !0);
  482. b += 2;
  483. c.height = f.getUint16(b, !0);
  484. b += 2;
  485. }
  486. function g() {
  487. for (var a = f.getUint32(b, !0).toString(16); 6 > a.length;) a = "0" + a;
  488. b += 4;
  489. c.color = "#" + a;
  490. }
  491. var e = f.getUint8(b);
  492. b += 1;
  493. c.type = e;
  494. switch (e) {
  495. case 255:
  496. break;
  497. case 0:
  498. c.x = f.getUint16(b, !0);
  499. b += 2;
  500. c.y = f.getUint16(b, !0);
  501. b += 2;
  502. c.size = f.getUint8(b);
  503. b += 1;
  504. c.isCentered = !!f.getUint8(b);
  505. b += 1;
  506. e = Da(f, b);
  507. c.text = e[0];
  508. b = e[1];
  509. break;
  510. case 1:
  511. d();
  512. var n = !c.color;
  513. g();
  514. var e = c.x | 0,
  515. l = c.y | 0,
  516. p = c.width | 0,
  517. k = c.height | 0;
  518. if (n)
  519. for (n = l; n < l + k; ++n)
  520. for (var m = e; m < e + p; ++m) ++T[m + 400 * n];
  521. break;
  522. case 2:
  523. d();
  524. c.isBad = !!f.getUint8(b);
  525. b += 1;
  526. break;
  527. case 3:
  528. d();
  529. c.count = f.getUint16(b, !0);
  530. b += 2;
  531. g();
  532. break;
  533. case 4:
  534. d();
  535. c.count ? c.count > f.getUint16(b, !0) && (c.lastClickAt = t) : c.lastClickAt = 0;
  536. c.count = f.getUint16(b, !0);
  537. b += 2;
  538. g();
  539. break;
  540. case 5:
  541. c.x = f.getUint16(b, !0);
  542. b += 2;
  543. c.y = f.getUint16(b, !0);
  544. b += 2;
  545. c.queue = [ [0, c.x, c.y]];
  546. c.potentialQueue = [];
  547. c.explored = new Uint8Array(12E4);
  548. c.img = a.createImageData(400, 300);
  549. e = E.createElement("canvas");
  550. e.width = 400;
  551. e.height = 300;
  552. c.canvas = e;
  553. c.ctx = c.canvas.getContext("2d");
  554. break;
  555. default:
  556. throw Error("Unknown object type " + e);
  557. }
  558. return b;
  559. }
  560.  
  561. function ea(a, b) {
  562. if (-1 != J && -1 != K) {
  563. var c = fa(J, K, a, b);
  564. if (c.x != a || c.y != b) return !0;
  565. }
  566. for (c = 0; c < r.length; c++) {
  567. var d = r[c];
  568. if (2 == d.type && !(k < d.x || q < d.y || k >= d.x + d.width || q >= d.y + d.height)) return !0;
  569. }
  570. return !1;
  571. }
  572.  
  573. var showHelp = false;
  574. function ma() {
  575. a.clearRect(0, 0, a.canvas.width, a.canvas.height);
  576. a.save();
  577. if (null != u && u.readyState != WebSocket.OPEN || L) {
  578. var f;
  579. if (null == u) f = "Click to begin";
  580. else switch (u.readyState) {
  581. case WebSocket.CONNECTING:
  582. f = "Connecting";
  583. break;
  584. case WebSocket.CLOSING:
  585. case WebSocket.CLOSED:
  586. f = "Lost connection to server";
  587. break;
  588. default:
  589. f = "Click to begin";
  590. }
  591. a.font = 60 + "px NovaSquare";
  592. a.fillText(f, 400 - a.measureText(f).width / 2, 300);
  593. a.font = 20 + "px NovaSquare";
  594. f = "-> Texting and drawing script <-";
  595. a.fillText(f, 400 - a.measureText(f).width / 2, 345);
  596. na();
  597. oa(!1);
  598. } else {
  599. a.fillStyle = "#000000";
  600. a.save();
  601. a.globalAlpha = 1;
  602. var typeZeroCount = 0;
  603. var typeOneCount = 0;
  604. var typeTwoCount = 0;
  605. var typeThreeCount = 0;
  606. var typeFourCount = 0;
  607. for (f = 0; f < r.length; f++) {
  608. var b = r[f];
  609. if (0 == b.type) {
  610. a.font = b.size + "px NovaSquare";
  611. var c = b.x << 1,
  612. d = b.y << 1;
  613. b.isCentered && (c -= a.measureText(b.text).width / 2);
  614. a.fillStyle = "#000000";
  615. a.fillText(b.text, c, d);
  616. typeZeroCount++;
  617. } else if (1 == b.type) {
  618. a.fillStyle = b.color, a.fillRect(b.x << 1, b.y << 1, b.width << 1, b.height << 1);
  619. a.strokeStyle = "#000000", a.globalAlpha = .2, a.lineWidth = 2;
  620. a.strokeRect((b.x << 1) + 1, (b.y << 1) + 1, (b.width << 1) - 2, (b.height << 1) - 2);
  621. a.globalAlpha = 1;
  622. typeOneCount++;
  623. } else if (2 == b.type) {
  624. a.fillStyle = b.isBad ? "#FF0000" : "#00FF00", a.globalAlpha = .2;
  625. a.fillRect(b.x << 1, b.y << 1, b.width << 1, b.height << 1);
  626. a.globalAlpha = 1;
  627. typeTwoCount++;
  628. } else if (3 == b.type) {
  629. var c = b.x << 1,
  630. d = b.y << 1,
  631. g = b.width << 1,
  632. e = b.height << 1;
  633. a.fillStyle = b.color;
  634. a.globalAlpha = .2;
  635. a.fillRect(c, d, g, e);
  636. a.globalAlpha = .5;
  637. a.fillStyle = "#000000";
  638. if (40 > b.width || 40 > b.height) {
  639. a.font = 30 + "px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 10);
  640. } else {
  641. a.font = 60 + "px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 20);
  642. };
  643. a.globalAlpha = 1;
  644. typeThreeCount++;
  645. } else if (4 == b.type) {
  646. c = b.x << 1;
  647. d = b.y << 1;
  648. g = b.width << 1;
  649. e = b.height << 1;
  650. a.fillStyle = b.color;
  651. a.strokeStyle = b.color;
  652. a.globalAlpha = 1;
  653. a.fillRect(c, d, g, e);
  654. a.globalAlpha = .2;
  655. a.fillStyle = "#000000";
  656. a.fillRect(c, d, g, e);
  657. a.globalAlpha = 1;
  658. a.fillStyle = b.color;
  659. var n = 150 > t - b.lastClickAt, l = n ? 8 : 12;
  660. a.fillRect(c + l, d + l, g - 2 * l, e - 2 * l);
  661. a.strokeStyle = "#000000";
  662. a.globalAlpha = .1;
  663. a.beginPath();
  664. a.moveTo(c, d);
  665. a.lineTo(c + l, d + l);
  666. a.moveTo(c + g, d);
  667. a.lineTo(c + g - l, d + l);
  668. a.moveTo(c, d + e);
  669. a.lineTo(c + l, d + e - l);
  670. a.moveTo(c + g, d + e);
  671. a.lineTo(c + g - l, d + e - l);
  672. a.moveTo(c, d);
  673. a.rect(c, d, g, e);
  674. a.rect(c + l, d + l, g - 2 * l, e - 2 * l);
  675. a.stroke();
  676. a.fillStyle = "#000000";
  677. a.globalAlpha = .5;
  678. if (50 > b.width || 50 > b.height) {
  679. a.font = 35 + "px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 13);
  680. } else {
  681. a.font = 45 + "px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 16);
  682. }
  683. n && (a.fillStyle = "#000000", a.globalAlpha = .15, a.fillRect(c + l, d + l, g - 2 * l, e - 2 * l));
  684. a.globalAlpha = 1;
  685. typeFourCount++;
  686. } else 5 == b.type && (ga(!1), a.drawImage(b.canvas, 0, 0, 400, 300, 0, 0, 800, 600, ga(!0)));
  687. }
  688. if (r.length == 8 && typeZeroCount == 4 && typeOneCount == 3 && typeTwoCount == 1 && typeThreeCount == 0 && typeFourCount == 0) {
  689. a.globalAlpha = 1;
  690. f = "(Or just play cursors.io)", a.font = 15 + "px NovaSquare", a.fillStyle = "#000000";
  691. a.fillText(f, 400 - a.measureText(f).width / 2, 408);
  692. }
  693. a.restore();
  694. if (!D) {
  695. a.font = 12 + "px NovaSquare", a.strokeStyle = "#000000", a.fillStyle = "#FFFFFF", a.lineWidth = 2.5;
  696. f = ja ? "Area too full, not all cursors are shown" : 30 < ia ? "Area too full, drawing is disabled" : "Use shift+click to draw";
  697. a.globalAlpha = .5, a.strokeText(f, 10, 590), a.globalAlpha = 1;
  698. a.fillText(f, 10, 590);
  699. if (aa != 0) {
  700. f = aa + " players online", b = a.measureText(f).width, a.globalAlpha = .5, a.strokeText(f, 790 - b, 590), a.globalAlpha = 1;
  701. a.fillText(f, 790 - b, 590);
  702. };
  703. if (!movementEnabled) {
  704. f = "movement disabled";
  705. a.globalAlpha = .5, a.strokeText(f, 10, 15), a.globalAlpha = 1;
  706. a.fillText(f, 10, 15);
  707. f = "press numpad . to enable";
  708. a.globalAlpha = .5, a.strokeText(f, 10, 30), a.globalAlpha = 1;
  709. a.fillText(f, 10, 30);
  710. }
  711. }
  712. na();
  713. if (!H.checked) {
  714. a.save();
  715. a.strokeStyle = "#000000";
  716. a.lineWidth = 1;
  717. t = +new Date;
  718. a.beginPath();
  719. for (f = 0; f < O.length; f++) {
  720. b = O[f];
  721. c = 10 - (t - b[4]) / 1E3;
  722. if (c <= 0) {
  723. O.splice(f, 1),
  724. --f;
  725. } else {
  726. 1 < c && (c = 1), a.globalAlpha = .3 * c;
  727. a.moveTo(b[0] - .5, b[1] - .5);
  728. a.lineTo(b[2] - .5, b[3] - .5);
  729. }
  730. }
  731. a.stroke();
  732. a.restore();
  733. }
  734. a.save();
  735. //for (var p in F) F.hasOwnProperty(p) && a.drawImage(P, scale(sa(F[p].getX()) - 6), scale(ta(F[p].getY()) - 6), scale(P.width), scale(P.height));
  736.  
  737. for (var p in F) {
  738. F.hasOwnProperty(p) && a.drawImage(P, sa(F[p].getX()) - 6, ta(F[p].getY()) - 6);
  739. // show ids?
  740. if (showcursorsid) {
  741. if(cursorIDPos==2){
  742. cp=a.measureText(p).width;
  743. a.globalAlpha = .5; a.strokeText( p, sa(F[p].getX()) - cp + cursorIDX, ta(F[p].getY()) + cursorIDY );
  744. a.globalAlpha= 1; a.fillText( p, sa(F[p].getX()) - cp + cursorIDX, ta(F[p].getY()) + cursorIDY );
  745. }
  746. else{
  747. a.globalAlpha = .5; a.strokeText( p, sa(F[p].getX()) + cursorIDX, ta(F[p].getY()) + cursorIDY );
  748. a.globalAlpha= 1; a.fillText( p, sa(F[p].getX()) + cursorIDX, ta(F[p].getY()) + cursorIDY );
  749. }
  750. }
  751. }
  752. if (showcursorsid) {
  753. if(cursorIDPos==2){
  754. cp=a.measureText(ha).width;
  755. a.globalAlpha = .5; a.strokeText( ha, sa(k) - cp + cursorIDX, ta(q) + cursorIDY ) ;
  756. a.globalAlpha= 1; a.fillText( ha, sa(k) - cp + cursorIDX, ta(q) + cursorIDY ) ;
  757. }
  758. else{
  759. a.globalAlpha = .5; a.strokeText( ha, sa(k) + cursorIDX, ta(q) + cursorIDY ) ;
  760. a.globalAlpha= 1; a.fillText( ha, sa(k) + cursorIDX, ta(q) + cursorIDY ) ;
  761. }
  762. }
  763.  
  764. a.restore();
  765. oa(!0);
  766. if (!D) {
  767. a.font = 15 + "px NovaSquare", a.strokeStyle = "#000000", a.fillStyle = "#FFFFFF", a.lineWidth = 2.5;
  768. if (message.length>0){
  769. b = a.measureText(message).width/2;
  770. a.globalAlpha = .5, a.strokeText(message, 400 - b, 580), a.globalAlpha = 1;
  771. a.fillText(message, 400 - b, 580);
  772. }
  773. for (var i=0; i < messages.length; i++){
  774. b = a.measureText(messages[i]).width/2;
  775. a.globalAlpha = .5, a.strokeText(messages[i], 400 - b, 580 - messages.length*15 + i*15 ), a.globalAlpha = 1;
  776. a.fillText(messages[i], 400 - b, 580 - messages.length*15 + i*15);
  777. }
  778. if (showHelp) {
  779. a.font = 12 + "px NovaSquare";
  780. f = "How to use (press F4 to hide):", a.globalAlpha = .5, a.strokeText(f, 10, 30), a.globalAlpha = 1, a.fillText(f, 10, 30);
  781. f = "-> To type: type message and hit enter (shift+enter for new row)", a.globalAlpha = .5, a.strokeText(f, 10, 45), a.globalAlpha = 1, a.fillText(f, 10, 45);
  782. f = "-> To enable or disable movement: press numpad .", a.globalAlpha = .5, a.strokeText(f, 10, 60), a.globalAlpha = 1, a.fillText(f, 10, 60);
  783. f = "-> To start/stop drawing circle: press numpad 0", a.globalAlpha = .5, a.strokeText(f, 10, 75), a.globalAlpha = 1, a.fillText(f, 10, 75);
  784. f = "-> To draw arrows, use the arrow keys", a.globalAlpha = .5, a.strokeText(f, 10, 90), a.globalAlpha = 1, a.fillText(f, 10, 90);
  785. f = "-> To draw images: press numpad 1 - numpad 9", a.globalAlpha = .5, a.strokeText(f, 10, 105), a.globalAlpha = 1, a.fillText(f, 10, 105);
  786. f = "-> To make images bigger/smaller use numpad + and -", a.globalAlpha = .5, a.strokeText(f, 10, 120), a.globalAlpha = 1, a.fillText(f, 10, 120);
  787. f = "-> To reset image size press *", a.globalAlpha = .5, a.strokeText(f, 10, 135), a.globalAlpha = 1, a.fillText(f, 10, 135);
  788. f = "-> To show/hide cursors ids: press F8", a.globalAlpha = .5, a.strokeText(f, 10, 150), a.globalAlpha = 1, a.fillText(f, 10, 150);
  789. f = "-> Change ids position: press F9", a.globalAlpha = .5, a.strokeText(f, 10, 165), a.globalAlpha = 1, a.fillText(f, 10, 165);
  790. }
  791. }
  792. }
  793. a.restore();
  794. A.requestAnimationFrame(ma)
  795. }
  796.  
  797. function scale(z) {
  798. return Math.round(z/600*a.canvas.height);
  799. }
  800.  
  801. function na() {
  802. a.save();
  803. a.strokeStyle = "#000000";
  804. t = +new Date;
  805. for (var f = 0; f < I.length; f++) {
  806. var b = I[f],
  807. c = (t - b[2]) / 1E3,
  808. d = 1 - 2 * c;
  809. 0 >= d ? (I.splice(f, 1), --f) : (c *= 50, a.beginPath(), a.globalAlpha = .3 * d, a.arc(b[0], b[1], c, 0, 2 * Math.PI, !1), a.stroke());
  810. }
  811. a.restore()
  812. }
  813.  
  814. function oa(f) {
  815. if (D) a.save(), a.globalAlpha = 1, a.drawImage(P, B - 5, C - 5, P.width, P.height);
  816. else {
  817. var b = 0,
  818. c = 0;
  819. if (v != k || w != q) {
  820. a.save();
  821. if (f) {
  822. a.globalAlpha = .2, a.fillStyle = "#FF0000", a.beginPath();
  823. a.arc(B + 2, C + 8, 20, 0, 2 * Math.PI, !1);
  824. a.fill();
  825. }
  826. a.globalAlpha = .5;
  827. a.drawImage(P, B - 5, C - 5, P.width, P.height);
  828. a.restore();
  829. } else {
  830. b = B & 1, c = C & 1;
  831. }
  832. a.save();
  833. if (f) {
  834. a.globalAlpha = .2, a.fillStyle = "#FFFF00", a.beginPath();
  835. a.arc((k << 1) + b + 2, (q << 1) + c + 8, 20, 0, 2 * Math.PI, !1);
  836. a.fill();
  837. }
  838. a.globalAlpha = 1;
  839. a.drawImage(Ia, (k << 1) + b - 5, (q << 1) + c - 5, Ia.width, Ia.height);
  840. if (!movementEnabled) {
  841. a.strokeStyle = "#DD4444", a.lineWidth = 1;
  842. a.beginPath();
  843. a.arc(serverPosX << 1, serverPosY << 1, 4, 0, 2*Math.PI);
  844. a.stroke();
  845. }
  846. }
  847. a.restore();
  848. }
  849.  
  850. function ka(a, b) {
  851. this.oldX = this.newX = a;
  852. this.oldY = this.newY = b;
  853. this.time = t
  854. }
  855.  
  856. function pa(a) {
  857. return a * a * (3 - 2 * a)
  858. }
  859.  
  860. function fa(a, b, c, d) {
  861. a |= 0;
  862. b |= 0;
  863. c |= 0;
  864. d |= 0;
  865. if (z(a, b)) return {
  866. x: a,
  867. y: b
  868. };
  869. if (a == c && b == d) return {
  870. x: c,
  871. y: d
  872. };
  873. var g = a,
  874. e = b;
  875. c = c - a | 0;
  876. d = d - b | 0;
  877. var n =
  878. 0,
  879. l = 0,
  880. p = 0,
  881. k = 0;
  882. 0 > c ? n = -1 : 0 < c && (n = 1);
  883. 0 > d ? l = -1 : 0 < d && (l = 1);
  884. 0 > c ? p = -1 : 0 < c && (p = 1);
  885. var m = Math.abs(c) | 0,
  886. h = Math.abs(d) | 0;
  887. m <= h && (m = Math.abs(d) | 0, h = Math.abs(c) | 0, 0 > d ? k = -1 : 0 < d && (k = 1), p = 0);
  888. c = m >> 1;
  889. for (d = 0; d <= m && !z(a, b); d++) g = a, e = b, c += h, c >= m ? (c -= m, a += n, b += l) : (a += p, b += k);
  890. return {
  891. x: g,
  892. y: e
  893. }
  894. }
  895.  
  896. function z(a, b) {
  897. return 0 > a || 400 <= a || 0 > b || 300 <= b ? !0 : T[a + 400 * b]
  898. }
  899.  
  900. function Ja() {
  901. for (var a = 0; a < r.length; a++) {
  902. var b = r[a];
  903. 5 == b.type && Ka(b)
  904. }
  905. }
  906.  
  907. function Ka(a) {
  908. function b(a, b, c) {
  909. e.push([c, a, b]);
  910. l[a + 400 * b] = !0;
  911. g(a, b)
  912. }
  913.  
  914. function c(a, b, c) {
  915. p.push([c,
  916. a, b
  917. ]);
  918. l[a + 400 * b] = !0
  919. }
  920.  
  921. function d(a, b) {
  922. return 255 != k[4 * (a + 400 * b) + 3] && !l[a + 400 * b]
  923. }
  924.  
  925. function g(a, b) {
  926. var c = 4 * (a + 400 * b);
  927. k[c + 0] = 255;
  928. k[c + 1] = 153;
  929. k[c + 2] = 153;
  930. k[c + 3] = 255
  931. }
  932. for (var e = a.queue, k = a.img.data, l = a.explored, p = a.potentialQueue, r = e.length, m = 0; m < p.length; m++) z(p[m][1], p[m][2]) || (g(p[m][1], p[m][2]), e.push(p[m]), p.splice(m, 1), --m);
  933. for (m = 0; m < r; ++m) z(e[m][1], e[m][2]) && (p.push(e[m]), e.splice(m, 1), --m, --r);
  934. for (r = 0; 50 > r && 0 != e.length; ++r) {
  935. for (var h = Number.POSITIVE_INFINITY, q = [e[0]], m = 1; m < e.length; ++m) {
  936. var x = e[m][0];
  937. .01 > Math.abs(x - h) ? q.push(e[m]) : x < h && (h = x, q = [e[m]])
  938. }
  939. for (m = 0; m < q.length; ++m) {
  940. var x = q[m][0],
  941. h = q[m][1],
  942. s = q[m][2],
  943. qa = e.indexOf(q[m]); - 1 != qa && e.splice(qa, 1);
  944. 0 < h && d(h - 1, s) && (z(h - 1, s) ? c(h - 1, s, x + 1) : b(h - 1, s, x + 1));
  945. 0 < s && d(h, s - 1) && (z(h, s - 1) ? c(h, s - 1, x + 1) : b(h, s - 1, x + 1));
  946. 400 > h + 1 && d(h + 1, s) && (z(h + 1, s) ? c(h + 1, s, x + 1) : b(h + 1, s, x + 1));
  947. 300 > s + 1 && d(h, s + 1) && (z(h, s + 1) ? c(h, s + 1, x + 1) : b(h, s + 1, x + 1));
  948. 0 < h && 0 < s && d(h - 1, s - 1) && (z(h - 1, s - 1) ? c(h - 1, s - 1, x + Math.SQRT2) : b(h - 1, s - 1, x + Math.SQRT2));
  949. 0 < h && 300 > s + 1 && d(h - 1, s + 1) && (z(h - 1, s + 1) ? c(h - 1, s + 1, x + Math.SQRT2) :
  950. b(h - 1, s + 1, x + Math.SQRT2));
  951. 400 > h + 1 && 0 < s && d(h + 1, s - 1) && (z(h + 1, s - 1) ? c(h + 1, s - 1, x + Math.SQRT2) : b(h + 1, s - 1, x + Math.SQRT2));
  952. 400 > h + 1 && 300 > s + 1 && d(h + 1, s + 1) && (z(h + 1, s + 1) ? c(h + 1, s + 1, x + Math.SQRT2) : b(h + 1, s + 1, x + Math.SQRT2))
  953. }
  954. }
  955. a.ctx.putImageData(a.img, 0, 0)
  956. }
  957. var y, a, ia = 0,
  958. Rat = A.devicePixelRatio;
  959. cp = 0,
  960. v = 0,
  961. w = 0,
  962. B = 0,
  963. C = 0,
  964. k = 0,
  965. q = 0,
  966. J = -1,
  967. K = -1,
  968. M = null,
  969. H = null,
  970. P = new Image;
  971. P.src = "img/cursor.png";
  972. var Ia = P,
  973. D = -1 != A.location.search.indexOf("editor"),
  974. I = [],
  975. O = [],
  976. t = 0,
  977. ca = 0,
  978. u = null,
  979. ha = -1,
  980. F = {},
  981. aa = 0,
  982. ja = !1,
  983. Y = !1,
  984. R = 0,
  985. S = 0,
  986. da = 0,
  987. X = !1,
  988. L = !D && !0,
  989. T = new Uint8Array(12E4),
  990. r = [],
  991. N = [];
  992. Array.prototype.remove =
  993. function(a) {
  994. a = this.indexOf(a);
  995. return -1 != a ? (this.splice(a, 1), !0) : !1
  996. };
  997. var G = 0;
  998. ka.prototype = {
  999. oldX: 0,
  1000. oldY: 0,
  1001. newX: 0,
  1002. newY: 0,
  1003. time: 0,
  1004. getX: function() {
  1005. var a = this.newX - this.oldX,
  1006. b = (t - this.time) / 100,
  1007. b = pa(0 >= b ? 0 : 1 <= b ? 1 : b);
  1008. return this.oldX + b * a
  1009. },
  1010. getY: function() {
  1011. var a = this.newY - this.oldY,
  1012. b = (t - this.time) / 100,
  1013. b = pa(0 >= b ? 0 : 1 <= b ? 1 : b);
  1014. return this.oldY + b * a
  1015. }
  1016. };
  1017.  
  1018. var za = new Uint8Array(12E4);
  1019. Array.prototype.remove = function(a) {
  1020. a = this.indexOf(a);
  1021. return -1 != a ? (this.splice(a, 1), !0) : !1
  1022. };
  1023. var imgSc = 1.0;
  1024. var message = new String();
  1025. var messages = new Array();
  1026.  
  1027. function drawM(m,d,x,y){
  1028. setTimeout(function () {
  1029. drawWord(m, x, y );
  1030. }, d);
  1031. }
  1032.  
  1033. function handleKeypress(e) {
  1034. if ((e.which >= 39 && e.which <= 41) ||
  1035. e.which == 43 || e.which == 92 ||
  1036. (e.which >= 44 && e.which <= 47) ||
  1037. (e.which >= 48 && e.which <= 59) ||
  1038. (e.which >= 65 && e.which <= 90) ||
  1039. (e.which >= 95 && e.which <= 122) ||
  1040. (e.which >= 32 && e.which <= 35) ||
  1041. e.which == 61 || e.which == 63 ) {
  1042. e.preventDefault();
  1043. message = message.concat(String.fromCharCode(e.which));
  1044. return;
  1045. }
  1046. switch(e.which) {
  1047. case 13:
  1048. e.preventDefault();
  1049. if (e.shiftKey) { //add new row
  1050. messages.push(message);
  1051. message = "";
  1052. }
  1053. else { //print all rows
  1054. messages.push(message);
  1055. for(var i=0; i < messages.length; i++){
  1056. if (i>0) var del = messages[i-1].length*i*50;
  1057. else var del=0;
  1058. drawM(messages[i],del,k,q+i*kerning*fontSize);//not ideal printing, but better than printing as columns
  1059. }
  1060. message = "";
  1061. messages = [];
  1062. }
  1063.  
  1064. break;
  1065. default:
  1066. return;
  1067. }
  1068. }
  1069.  
  1070. function handleKeydown(e) {
  1071. if (e.keyCode == 8 || e.keyCode == 9 || (e.keyCode >=37 && e.keyCode <= 40)
  1072. || (e.keyCode >= 96 && e.keyCode <= 122)
  1073. //|| e.keyCode == 12 || e.keyCode == 45 || (e.keyCode >= 33 && e.keyCode <= 36)
  1074. ) {
  1075. e.preventDefault();
  1076. }
  1077. if (e.keyCode == 8) {
  1078. if (message.length > 0) {
  1079. message = message.substring(0, message.length - 1);
  1080. }
  1081. else if (messages.length > 0) {
  1082. message = messages.pop();
  1083. }
  1084. }
  1085. switch(e.keyCode) {
  1086. case 37: // left arrow
  1087. imgSc=imageScale; imageScale=1.0;
  1088. drawImage(0, posX, posY); // draw arrow pointing left
  1089. imageScale=imgSc;
  1090. break;
  1091. case 38: // up arrow
  1092. imgSc=imageScale; imageScale=1.0;
  1093. drawImage(1, posX, posY); // draw arrow pointing up
  1094. imageScale=imgSc;
  1095. break;
  1096. case 39: // right arrow
  1097. imgSc=imageScale; imageScale=1.0;
  1098. drawImage(2, posX, posY); // draw arrow right
  1099. imageScale=imgSc;
  1100. break;
  1101. case 40: // down arrow
  1102. imgSc=imageScale; imageScale=1.0;
  1103. drawImage(3, posX, posY); // draw arrow down
  1104. imageScale=imgSc;
  1105. break;
  1106. case 106: //numpad *
  1107. imageScale = 1.0; // reset drawings size
  1108. break;
  1109. case 107: //numpad +
  1110. imageScale += 0.1; // make drawings bigger
  1111. break;
  1112. case 109: //numpad -
  1113. if(imageScale > 0.29)
  1114. imageScale -= 0.1; // make drawings smaller
  1115. break;
  1116. case 46: case 110: // numpad .
  1117. movementEnabled = !movementEnabled; // disable/enable movement by click
  1118. break;
  1119. case 45: case 96: // numpad 0
  1120. auraEnabled = !auraEnabled; // start/stop drawing circle
  1121. break;
  1122. case 97: //case 35: // numpad 1
  1123. drawImage(4, posX, posY); // star
  1124. break;
  1125. case 98: //case 40: // numpad 2
  1126. drawImage(5, posX, posY); // reversed star
  1127. break;
  1128. case 99: //case 34: // numpad 3
  1129. drawImage(6, posX, posY); // tictactoe
  1130. break;
  1131. case 100: //case 37: // numpad 4
  1132. drawImage(7, posX, posY); // cannon - pentashot
  1133. break;
  1134. case 101: //case 12: // numpad 5
  1135. drawImage(8, posX, posY); // triforce
  1136. break;
  1137. case 102: //case 39: // numpad 6
  1138. drawImage(9, posX,posY); // heart
  1139. break;
  1140. case 103: //case 36: // numpad 7
  1141. imageScale/=2.8;
  1142. drawImage(10, posX, posY); // dickboob
  1143. imageScale*=2.8;
  1144. break;
  1145. case 104: //case 38: // numpad 8
  1146.  
  1147. break;
  1148. case 105: //case 33: // numpad 9
  1149. drawWord(" trololo", posX, posY);
  1150. break;
  1151. case 115: // F4
  1152. showHelp = !showHelp; // show/hide help
  1153. break;
  1154. case 119: // F8
  1155. showcursorsid = !showcursorsid; // show/hide cursors ids
  1156. break;
  1157. case 120: // F9
  1158. cursorIDPos+=1;
  1159. changeCursorIDpos(cursorIDPos);
  1160. break;
  1161. default:
  1162. return;
  1163. }
  1164. }
  1165.  
  1166. var cursorIDPos=1;
  1167. var cursorIDX=-2;
  1168. var cursorIDY=24;
  1169.  
  1170. function changeCursorIDpos(c) {
  1171. switch(c){
  1172. case 1: cursorIDX=-2; cursorIDY=24; break;
  1173. case 2: cursorIDX=-3; cursorIDY=14; break;
  1174. case 3: cursorIDX=-2; cursorIDY=-3; break;
  1175. case 4: cursorIDX=10; cursorIDY=14; break;
  1176. default: cursorIDX=-2; cursorIDY=24; cursorIDPos=1;
  1177. }
  1178. }
  1179.  
  1180. function drawAura(x, y) {
  1181. var dt = 360/(1000/40)/2;
  1182. if (u != null && u.readyState == WebSocket.OPEN) {
  1183. var g = new ArrayBuffer(9),
  1184. e = new DataView(g);
  1185. e.setUint8(0, 3);
  1186. e.setUint16(1, x+Math.sin(degToRad(auraTime+dt))*auraRadius, !0);
  1187. e.setUint16(3, y+Math.cos(degToRad(auraTime+dt))*auraRadius, !0);
  1188. e.setUint16(5, x+Math.sin(degToRad(auraTime))*auraRadius, !0);
  1189. e.setUint16(7, y+Math.cos(degToRad(auraTime))*auraRadius, !0);
  1190. u.Send(g)
  1191. }
  1192.  
  1193. auraTime += dt;
  1194. }
  1195.  
  1196. function drawImage(ind, x, y) {
  1197. if (!imgData[ind]) return;
  1198. for (var i = 0; i < imgData[ind].length; i++) {
  1199. var g = new ArrayBuffer(9),
  1200. e = new DataView(g);
  1201. e.setUint8(0, 3);
  1202. e.setUint16(1, x+imgData[ind][i][1]*imageScale, !0);
  1203. e.setUint16(3, y+imgData[ind][i][0]*imageScale, !0);
  1204. e.setUint16(5, x+imgData[ind][i][3]*imageScale, !0);
  1205. e.setUint16(7, y+imgData[ind][i][2]*imageScale, !0);
  1206. u.Send(g);
  1207. }
  1208. }
  1209.  
  1210. function degToRad(deg) {
  1211. return deg * (Math.PI / 180);
  1212. }
  1213.  
  1214. function radToDeg(rad) {
  1215. return rad * (180 / Math.PI);
  1216. }
  1217.  
  1218. function drawLetter(a, x, y) {
  1219. var letter;
  1220. var capital = 1;
  1221. var shift = 0;
  1222. if (alphabet.hasOwnProperty(a)) {
  1223. letter = alphabet[a];
  1224. } else if (a + 32 >= 97 && a + 32 <= 122) {
  1225. capital = 1.5;
  1226. shift = -2;
  1227. letter = alphabet[a + 32];
  1228. } else return;
  1229. for (var i = 0; i < letter.length; i++) {
  1230. var g = new ArrayBuffer(9),
  1231. e = new DataView(g);
  1232. e.setUint8(0, 3);
  1233. e.setUint16(1, x+letter[i][1]*fontSize, !0);
  1234. e.setUint16(3, y+letter[i][0]*fontSize*capital + shift, !0);
  1235. e.setUint16(5, x+letter[i][3]*fontSize, !0);
  1236. e.setUint16(7, y+letter[i][2]*fontSize*capital + shift, !0);
  1237. u.Send(g);
  1238. }
  1239. }
  1240.  
  1241. function drawWord(s, x, y) {
  1242. if (s == null) return;
  1243. setTimeout(function () {
  1244. if (!z(Math.round(x+fontSize*kerning), Math.round(y))) {
  1245. drawLetter(s.charCodeAt(0), x, y);
  1246. if (s.length > 0) drawWord(s.substring(1, s.length), x+fontSize*kerning, y);
  1247. }
  1248. }, 1);
  1249. }
  1250.  
  1251. WebSocket.prototype.Send = function(frm) {
  1252. if (u != null && u.readyState == WebSocket.OPEN) {
  1253. if (Throttler.check(frm)) this.send(frm);
  1254. }
  1255. };
  1256. var Throttler = {
  1257. rate: 3,
  1258. per: 150,
  1259. storage: [],
  1260. allowed: 3,
  1261. lastFrameAt: 0,
  1262. sendOut: function() {
  1263. if (this.storage.length != 0) {
  1264. u.Send(this.storage.shift());
  1265. }
  1266. },
  1267. check: function(frm) {
  1268. var now = Date.now();
  1269. var allowance = this.allowed;
  1270. var timeDiff = now - this.lastFrameAt;
  1271. this.lastFrameAt = now;
  1272. allowance += timeDiff*(this.rate/this.per);
  1273. if (allowance > this.rate) allowance = this.rate;
  1274. this.allowed = allowance;
  1275. if (this.allowed < 1) {
  1276. if (this.storage.length < 400) {
  1277. var dv = new DataView(frm);
  1278. if (dv.getUint8(0) == 3) this.storage.push(frm);
  1279. }
  1280. return false;
  1281. }
  1282. this.allowed -= 1;
  1283. return true;
  1284. }
  1285. };
  1286.  
  1287. function connect() {
  1288. if (m28n.findServerPreference) {
  1289. if (!u) m28n.findServerPreference("cursors", function(e,a){
  1290. if (e||0 == a.length) {
  1291. setTimeout(self.connect, 1E3);
  1292. } else {
  1293. var ipv4 = a[0].ipv4;
  1294. var ipv6 = a[0].ipv6;
  1295. var port = a[0].port;
  1296. port = 2828;
  1297. u = new WebSocket("ws://" + (ipv4 || "[" + ipv6 + "]") + ":" + port);
  1298. setHandlers();
  1299. }
  1300. });
  1301. } else {
  1302. if (!u) u = new WebSocket("ws://s1.cursors.io:443/");
  1303. setHandlers();
  1304. }
  1305. function setHandlers() {
  1306. u.binaryType = "arraybuffer";
  1307. u.onopen = Aa, u.onmessage = Ga, u.onclose = Ba, u.onerror = Ca;
  1308. }
  1309. }
  1310.  
  1311. var messageDisplay;
  1312. function doit() {
  1313. document.body.innerHTML += '<div id="messageDisplay"></div>';
  1314. messageDisplay = document.getElementById("messageDisplay");
  1315.  
  1316. y = E.getElementById("canvas");
  1317. a = y.getContext("2d");
  1318.  
  1319. try {
  1320. A.top.location.origin != A.location.origin && ba()
  1321. } catch (f) {
  1322. ba()
  1323. }
  1324. y.width = 800 * Rat;
  1325. y.height = 600 * Rat;
  1326. a.scale(Rat, Rat);
  1327. y.onmousemove = ua;
  1328. y.onmousedown = va;
  1329. y.onmouseup = xa;
  1330. M = E.getElementById("noCursorLock");
  1331. H = E.getElementById("noDrawings");
  1332. null != localStorage && (Ma(), M.checked = "1" == A.localStorage.getItem("noCursorLock") ? !0 : !1, H.checked = "1" == A.localStorage.getItem("noDrawings") ? !0 : !1);
  1333. A.onbeforeunload = ya;
  1334. y.requestPointerLock = y.requestPointerLock || y.mozRequestPointerLock || y.webkitRequestPointerLock;
  1335. y.style.cursor = "none";
  1336. D || connect();
  1337. setInterval(Q, 20);
  1338. //setInterval(Ja, 40);
  1339. setInterval(Au, 50);
  1340. A.requestAnimationFrame(ma)
  1341.  
  1342. document.onkeypress = handleKeypress;
  1343. document.onkeydown = handleKeydown;
  1344. }
  1345. doit();
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352. /*
  1353. ___ _ _ _ __ ___ ___ _ __ ___ _ ___
  1354. / __| | | | `__/ __|/ _ \| `__/ __| | |/ _ \
  1355. | (__| |_| | | \__ \ (_) | | \__ \_| | (_) |
  1356. \___|\__,_|_| |___/\___/|_| |___(_)_|\___/
  1357.  
  1358. script for texting and drawing in CURSORS.IO
  1359.  
  1360. How to use:
  1361. -> To type: type message and hit enter; shift+enter for new row;
  1362. -> To move your cursor only when clicking: press numpad .
  1363. Use it to pass red walls levels ;)
  1364. -> To move your cursor normally: press numpad . again
  1365. -> To draw a circle: press numpad 0
  1366. -> To stop drawing a circle: press numpad 0 again
  1367. -> To draw arrows, use the arrow keys
  1368. -> To draw different images: press numpad 1 - numpad 9 keys
  1369. -> To make drawings bigger/smaller use numpad + and -
  1370. -> Reset drawing size with numpad *
  1371. -> To show/hide cursors ids: press F8
  1372. -> Change ids position with: F9
  1373. -> To show this help: press F4
  1374. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement