Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.75 KB | None | 0 0
  1. { // For copy/paste purpose...
  2. /* Usually, in most emscripten games "JSEvents" interface is private, therefore we expose it to global scope by using debugger (i.e Developer Tools)... */
  3. if (false) {
  4. /* Note: unityWebView.game.Module could be named differently (based on a game), for example like "gameInstance.Module" etc.. */
  5. // Copy this to the debugger and execute to stop at the breakpoint, where we will expose "JSEvents" to global scope.
  6. debug(unityWebView.game.Module.SetFullscreen);
  7. unityWebView.game.Module.SetFullscreen();
  8. undebug(unityWebView.game.Module.SetFullscreen);
  9. //window.JSEvents = JSEvents; // expose this...
  10. }
  11. }
  12. // after successful JSEvents exposure, simply execute the code below which will take advantage of JSEvents to emulate mouse clicks on pre-programmed positions at custom period of time.
  13. var findHandler = (function() {
  14. let handlerMap = {};
  15.  
  16. for(let handlerId in JSEvents.eventHandlers) {
  17. let handler = JSEvents.eventHandlers[handlerId];
  18. handlerMap[handler.eventTypeString] = handlerId;
  19. }
  20.  
  21. return function(handlerType) {
  22. return { handlerId: handlerMap[handlerType], handler: JSEvents.eventHandlers[handlerMap[handlerType]] };
  23. };
  24. })();
  25.  
  26. var removeHandler = function(handlerType) {
  27. let eventHandler = findHandler(handlerType);
  28. if (eventHandler.handler)
  29. JSEvents._removeHandler(eventHandler.handlerId);
  30. };
  31.  
  32. var autoClick = (function() {
  33. let mouseMoveHandler = findHandler("mousemove").handler;
  34. let mouseDownHandler = findHandler("mousedown").handler;
  35. let mouseUpHandler = findHandler("mouseup").handler;
  36.  
  37. let target = unityWebView.game.Module.ctx.canvas;
  38.  
  39. let mouseEvent = {
  40. "screenX": 0,
  41. "screenY": 0,
  42. "clientX": 0,
  43. "clientY": 0,
  44. "ctrlKey": false,
  45. "shiftKey": false,
  46. "altKey": false,
  47. "metaKey": false,
  48. "button": 0,
  49. "buttons": 0,
  50. "movementX": 0,
  51. "movementY": 0,
  52. };
  53.  
  54. return function(x, y) {
  55. mouseEvent.screenX = mouseEvent.clientX = x;
  56. mouseEvent.screenY = mouseEvent.clientY = y;
  57.  
  58. JSEvents.fillMouseEventData(JSEvents.mouseEvent, mouseEvent, target);
  59. unityWebView.game.Module["dynCall_iiii"](mouseMoveHandler.callbackfunc, 8, JSEvents.mouseEvent, 0);
  60. unityWebView.game.Module["dynCall_iiii"](mouseDownHandler.callbackfunc, 5, JSEvents.mouseEvent, 0);
  61. unityWebView.game.Module["dynCall_iiii"](mouseUpHandler.callbackfunc, 6, JSEvents.mouseEvent, 0);
  62. };
  63. })();
  64.  
  65. var bounds = { width: unityWebView.game.Module.canvas.width, height: unityWebView.game.Module.canvas.height };
  66.  
  67. var autoClicker = {
  68. interval: 85,
  69. timerId: autoClicker && autoClicker.timerId,
  70. timeoutClick: function(id, x, y, interval) {
  71. autoClicker[id] = autoClicker[id] || setTimeout(function() {
  72. autoClick(x, y);
  73. autoClicker[id] = null;
  74. }, interval);
  75. },
  76. init: function() {
  77. removeHandler("blur");
  78. clearInterval(autoClicker.timerId);
  79. autoClicker.timerId = setInterval(function() {
  80. /* Auto-Clicking positions goes here... */
  81.  
  82. autoClick(bounds.width - 135, bounds.height - 278);
  83.  
  84. autoClicker.timeoutClick("autoProgress_start", bounds.width + 105, bounds.height - 351, autoClicker.interval / 5);
  85. autoClicker.timeoutClick("autoProgress_next/finish", bounds.width + 116, bounds.height - 351, autoClicker.interval / 4);
  86.  
  87. autoClicker.timeoutClick("level_up_Mizuki", bounds.width - 470, bounds.height - 527, autoClicker.interval / 3);
  88. autoClicker.timeoutClick("level_up_Bunny", bounds.width - 470, bounds.height - 418, autoClicker.interval / 2);
  89. autoClicker.timeoutClick("level_up_Estelle", bounds.width - 470, bounds.height - 312, autoClicker.interval / 1);
  90. // autoClicker.timeoutClick("level_up_Megane", bounds.width - 470, bounds.height - 205, autoClicker.interval / 3);
  91. // autoClicker.timeoutClick("level_up_Angela", bounds.width - 470, bounds.height - 96, autoClicker.interval / 2);
  92. // autoClicker.timeoutClick("level_up_Lyrsa", bounds.width - 470, bounds.height + 12, autoClicker.interval / 1);
  93.  
  94. autoClicker.timeoutClick("autoSkill_NeptunesTouch", bounds.width - 97, bounds.height - 15, 58 * 1000);
  95. autoClicker.timeoutClick("autoSkill_ExitingFlirt", bounds.width - 28, bounds.height - 15, 59 * 1000);
  96. autoClicker.timeoutClick("autoSkill_ManlySweat", bounds.width + 34, bounds.height - 15, 61 * 1000);
  97.  
  98. autoClicker.timeoutClick("autoBonusClaimer", bounds.width + 210, bounds.height - 165, 30 * 1000);
  99.  
  100. }, autoClicker.interval);
  101. }
  102. };
  103.  
  104. /* Toggle ON/OFF Switch via 'Spacebar' and custom active zone */
  105.  
  106. var toggleState = true;
  107.  
  108. if (typeof printMousePos !== "undefined")
  109. document.removeEventListener("click", printMousePos);
  110.  
  111. if (typeof activeZone !== "undefined")
  112. document.removeEventListener("mousemove", activeZone);
  113.  
  114. if (typeof toggleButton !== "undefined")
  115. document.removeEventListener("keyup", toggleButton);
  116.  
  117. var printMousePos = function(mouseEvt) {
  118. console.log(`${mouseEvt.clientX}, ${mouseEvt.clientY}`);
  119. console.log(`autoClick(bounds.width - ${bounds.width - mouseEvt.clientX}, bounds.height - ${bounds.height - mouseEvt.clientY});`);
  120. };
  121.  
  122. var activeZone = function(evt) {
  123. if (!toggleState)
  124. return false;
  125.  
  126. if (evt.clientX < bounds.width / 1.5) {
  127. if (autoClicker.timerId) {
  128. clearInterval(autoClicker.timerId);
  129. autoClicker.timerId = null;
  130. console.log("[ActionZone] AutoClicker OFF!");
  131. }
  132. } else if (autoClicker.timerId == null) {
  133. autoClicker.init();
  134. console.log("[ActionZone] AutoClicker ON!");
  135. }
  136. };
  137.  
  138. var toggleButton = function(evt) {
  139. if (evt.keyCode == 32) {
  140. toggleState = !toggleState;
  141. if (toggleState && autoClicker.timerId == null) {
  142. autoClicker.init();
  143. console.log("[KeyPress] AutoClicker ON!");
  144. } else {
  145. clearInterval(autoClicker.timerId);
  146. autoClicker.timerId = null;
  147. console.log("[KeyPress] AutoClicker OFF!");
  148. }
  149. }
  150. };
  151.  
  152. document.addEventListener("click", printMousePos);
  153. document.addEventListener("mousemove", activeZone);
  154. document.addEventListener("keyup", toggleButton);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement