Krunker Skid - bushfire-disaster-appeal

krunker.io modification

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  1. // ==UserScript==
  2. // @name Krunker Skid - bushfire-disaster-appeal
  3. // @namespace https://www.communityenterprisefoundation.com.au/make-a-donation/bushfire-disaster-appeal/
  4. // @version 1.9.6.2
  5. // @description krunker.io modification
  6. // @author Skid Lamer
  7. // @match *://krunker.io/*
  8. // @run-at document-start
  9. // @grant none
  10. // @noframes
  11. // ==/UserScript==
  12. //******************************************************************************************************************
  13. // If you steal my script and pretend you made it IDC as long as you leave the link to donate to the bushfire appeal
  14. // and this notice, thankyou - Skid Lamer.
  15. //******************************************************************************************************************
  16. (function() {
  17. //'use strict';
  18. //======================================================================================>
  19. var count = 0,
  20. vars = {};
  21. const downKeys = new Set();
  22. const upKeys = new Set();
  23. const defined = object => typeof object !== "undefined";
  24. console.json = object => console.log(JSON.stringify(object, undefined, 2));
  25. let toJson = object => console.log(JSON.stringify(object, undefined, 2));
  26. let getDistance3D = (fromX, fromY, fromZ, toX, toY, toZ) => {
  27. var distX = fromX - toX,
  28. distY = fromY - toY,
  29. distZ = fromZ - toZ;
  30. return Math.sqrt(distX * distX + distY * distY + distZ * distZ);
  31. }
  32.  
  33. let getDistance = (player1, player2) => {
  34. return getDistance3D(player1.x, player1.y, player1.z, player2.x, player2.y, player2.z);
  35. }
  36.  
  37. let getDirection = (fromZ, fromX, toZ, toX) => {
  38. return Math.atan2(fromX - toX, fromZ - toZ);
  39. }
  40.  
  41. let getXDir = (fromX, fromY, fromZ, toX, toY, toZ) => {
  42. var dirY = Math.abs(fromY - toY),
  43. dist = getDistance3D(fromX, fromY, fromZ, toX, toY, toZ);
  44. return Math.asin(dirY / dist) * (fromY > toY ? -1 : 1);
  45. }
  46.  
  47. let getAngleDist = (start, end) => {
  48. return Math.atan2(Math.sin(end - start), Math.cos(start - end));
  49. }
  50.  
  51. addEventListener("keydown", e => {
  52. if ("INPUT" == window.document.activeElement.tagName) return;
  53. const key = e.key.toUpperCase();
  54. const code = e.code;
  55. if (!downKeys.has(code)) downKeys.add(code);
  56. });
  57.  
  58. addEventListener("keyup", e => {
  59. const key = e.key.toUpperCase();
  60. const code = e.code;
  61. if (downKeys.has(code)) downKeys.delete(code);
  62. if (!upKeys.has(code)) upKeys.add(code);
  63. })
  64.  
  65. const Pi = Math.PI / 2;
  66. const PI2 = 2 * Math.PI;
  67. const consts = {
  68. cameraHeight: 1.5,
  69. playerHeight: 11,
  70. cameraHeight: 1.5,
  71. headScale: 2,
  72. crouchDst: 3,
  73. camChaseTrn: 0.0022,
  74. camChaseSpd: 0.0012,
  75. camChaseSen: 0.2,
  76. camChaseDst: 24,
  77. recoilMlt: 0.3,
  78. nameOffset: 0.6,
  79. nameOffsetHat: 0.8,
  80. verClans: [
  81. "DEV",
  82. "FaZe",
  83. "Lore",
  84. "nV",
  85. "Oxic",
  86. "Verb",
  87. "Omen",
  88. "ロリ幼女",
  89. "VOID",
  90. "JBP",
  91. "PHIL",
  92. "TIMP",
  93. "24/7",
  94. "g59",
  95. "GLXY",
  96. "MMOK",
  97. "ODTY"
  98. ],
  99. };
  100. const input = {
  101. speed: 1,
  102. ydir: 2,
  103. xdir: 3,
  104. shoot: 5,
  105. scope: 6,
  106. jump: 7,
  107. crouch: 8,
  108. reload: 9,
  109. weapon: 10,
  110. };
  111. let settings = {
  112. isSliding: false,
  113. distance: Infinity,
  114. scopingOut: false,
  115. canShoot: true,
  116. }
  117.  
  118. function onTick(me, world, inputs, renderer) {
  119. 'use strict';
  120. const controls = world.controls;
  121. let getInView = (entity) => (null == world[vars.canSee](me, entity.x, entity.y, entity.z)) && (null == world[vars.canSee](renderer.camera[vars.getWorldPosition](), entity.x, entity.y, entity.z, 10));
  122. let getIsFriendly = (entity) => (me && me.team ? me.team : me.spectating ? 0x1 : 0x0) == entity.team;
  123. let keyDown = (code) => {
  124. return downKeys.has(code);
  125. }
  126. let keyUp = (code) => {
  127. if (upKeys.has(code)) {
  128. upKeys.delete(code);
  129. return true;
  130. }
  131. return false;
  132. }
  133.  
  134. // AutoAim
  135. let ty = controls.object.rotation.y;
  136. let tx = controls[vars.pchObjc].rotation.x;
  137. let target = world.players.list.filter(x => {
  138. x[vars.cnBSeen] = true;
  139. const inView = getInView(x);
  140. const isFriendly = getIsFriendly(x);
  141. return defined(x[vars.objInstances]) && x[vars.objInstances] && x.active && !x.renderYou && inView && !isFriendly
  142. }).sort((p1, p2) => p1[vars.objInstances].position.distanceTo(me) - p2[vars.objInstances].position.distanceTo(me)).shift();
  143. if (target) {
  144. if (me.weapon[vars.nAuto] && me[vars.didShoot]) {
  145. inputs[input.shoot] = 0;
  146. } else if (!me.aimVal) {
  147. inputs[input.shoot] = 1;
  148. inputs[input.scope] = 1;
  149. } else {
  150. inputs[input.scope] = 1;
  151. }
  152. let offset1 = ((consts.playerHeight - consts.cameraHeight) - (target.crouchVal * consts.crouchDst));
  153. let offset2 = consts.playerHeight - consts.headScale / 2 - target.crouchVal * consts.crouchDst;
  154. ty = getDirection(controls.object.position.z, controls.object.position.x, target.z, target.x);
  155. tx = getXDir(controls.object.position.x, controls.object.position.y, controls.object.position.z, target.x, target.y + offset2, target.z);
  156. tx -= consts.recoilMlt * me[vars.recoilAnimY];
  157. } else {
  158. inputs[input.shoot] = controls[vars.mouseDownL];
  159. inputs[input.scope] = controls[vars.mouseDownR];
  160. }
  161.  
  162. // silent aim
  163. inputs[input.xdir] = +(tx % PI2).toFixed(3);
  164. inputs[input.ydir] = +(ty % PI2).toFixed(3);
  165.  
  166. // auto bHop
  167. let autoBhop = (value) => {
  168. if (!value) return;
  169. if (keyDown("Space") || value == 1 || value == 3) {
  170. controls.keys[controls.jumpKey] = !controls.keys[controls.jumpKey];
  171. if (value >= 2) {
  172. if (settings.isSliding) {
  173. controls.keys[controls.crouchKey] = 1;
  174. return;
  175. }
  176. if (me.yVel < -0.04 && me.canSlide) {
  177. settings.isSliding = true;
  178. setTimeout(() => {
  179. settings.isSliding = false;
  180. controls.keys[controls.crouchKey] = 0;
  181. }, 350);
  182. controls.keys[controls.crouchKey] = 1;
  183. }
  184. }
  185. }
  186. }
  187. autoBhop(2);
  188.  
  189. // auto reload
  190. const ammoLeft = me[vars.ammos][me[vars.weaponIndex]];
  191. if (!ammoLeft) inputs[input.reload] = 1;
  192.  
  193. }
  194.  
  195. function onRender(canvas, scale, world, renderer, me, scale2) {
  196. if (world && world.players) {
  197. world.players.list.map((entity, index, array)=> {
  198. if (defined(entity[vars.objInstances]) && entity[vars.objInstances]) {
  199. for (let i = 0; i < entity[vars.objInstances].children.length; i++) {
  200. const object3d = entity[vars.objInstances].children[i];
  201. for (let j = 0; j < object3d.children.length; j++) {
  202. const mesh = object3d.children[j];
  203. if (mesh && mesh.type == "Mesh") {
  204. const material = mesh.material;
  205. material.depthTest = 0;
  206. material.alphaTest = 1;
  207. //material.emissive.r = 1;
  208. material.emissive.g = 1;
  209. material.emissive.b = 1;
  210. material.wireframe = true;
  211. }
  212. }
  213. }
  214. }
  215. });
  216. }
  217. if (me) {
  218. // onTick Hook
  219. if (!defined(me.procInputs)) {
  220. // Do once:
  221. me.procInputs = me[vars.procInputs];
  222. me[vars.procInputs] = function() {
  223. const inputs = arguments[0];
  224. //const world = arguments[1];
  225. onTick(this, world, inputs, renderer);
  226. return me.procInputs(...arguments);
  227. }
  228. }
  229. }
  230. }
  231.  
  232. function findVariables(script) {
  233. const regex = new Map()
  234. .set("procInputs", /this\['(\w+)']=function\((\w+),(\w+),\w+,\w+\){(this)/)
  235. .set("objInstances", /\[\w+\]\['\w+'\]=!\w+,this\['\w+'\]\[\w+\]\['\w+'\]&&\(this\['\w+'\]\[\w+\]\['(\w+)'\]\['\w+'\]=!\w+/)
  236. //renderYou //.set("isYou", /,this\['\w+'\]=!\w+,this\['\w+'\]=!\w+,this\['(\w+)'\]=\w+,this\['\w+'\]\['length'\]=\w+,this\[/)
  237. .set("cnBSeen", /\['(\w+)']=!0x0,!spectating/)
  238. .set("canSee", /,this\['(\w+)'\]=function\(\w+,\w+,\w+,\w+,\w+\){if\(!\w+\)return!\w+;/)
  239. .set("pchObjc", /\(\w+,\w+,\w+\),this\['(\w+)'\]=new \w+\['\w+'\]\(\)/)
  240. .set("recoilAnimY", /\w*1,this\['\w+'\]=\w*0,this\['\w+'\]=\w*0,this\['\w+'\]=\w*1,this\['\w+'\]=\w*1,this\['\w+'\]=\w*0,this\['\w+'\]=\w*0,this\['(\w+)'\]=\w*0,this\['\w+'\]=\w*0,this\['\w+'\]=\w*0,this\['\w+'\]=\w*0,/)
  241. .set("mouseDownL", /this\['\w+'\]=function\(\){this\['(\w+)'\]=\w*0,this\['(\w+)'\]=\w*0,this\['\w+'\]={}/)
  242. .set("mouseDownR", /this\['(\w+)']=0x0,this\['keys']=/)
  243. .set("getWorldPosition", /\['camera']\['(\w+)']\(\);if/)
  244. .set("maxHealth", /this\['health']\/this\['(\w+)']\?/)
  245. .set("didShoot", /0x0,this\['(\w+)']=!0x1,this\['lodActive']=!0x1/)
  246. .set("ammos", /{!\w+\['reloadTimer']&&\w+\['(\w+)']/)
  247. .set("nAuto", /'(\w+)':!0x0,'burst':/)
  248. .set("weaponIndex", /\['reloadTimer']&&\w+\['\w+']\[\w+\['(\w+)']/)
  249. for (const [name, search] of regex) {
  250. const found = search.exec(script);
  251. if (!found) {
  252. alert(`Failed to find ${name}`);
  253. vars[name] = null;
  254. continue;
  255. } else {
  256. console.log("found ", name, " - ", found[1]);
  257. vars[name] = found[1];
  258. }
  259. }
  260. }
  261.  
  262. class Hook {
  263. constructor(target, fn, blocking = false) {
  264. this.hook = {
  265. apply: function(_target, _this, _arguments) {
  266. let _returnValue = _target.apply(_this, _arguments);
  267. // uncomment for hook logs - skid
  268. /*
  269. console.log('//======================================================================================>');
  270. console.log('HOOKED: ', _target.name, '\n');
  271. console.log('Parent: ', _this);
  272. console.log('Arguments: ', _arguments);
  273. console.log('ReturnValue: ', _returnValue);
  274. console.log('//======================================================================================>');
  275. */
  276.  
  277. fn({
  278. main: _this,
  279. args: _arguments,
  280. rv: _returnValue
  281. });
  282.  
  283. if (!blocking) return _returnValue;
  284. }
  285. };
  286. return new Proxy(target, this.hook);
  287. }
  288. };
  289.  
  290. //======================================================================================>
  291.  
  292. TextEncoder.prototype.encodeInto = new Hook(TextEncoder.prototype.encodeInto, (params) => {
  293. const data = params.args;
  294. if (!count) {
  295. findVariables(data[0]);
  296. }
  297. count++;
  298. });
  299.  
  300. const original_CRC2dSave = CanvasRenderingContext2D.prototype.restore;
  301. CanvasRenderingContext2D.prototype.restore = function() {
  302. const render = arguments.callee.caller;
  303. const args = [this.canvas, ...render.arguments];
  304. render.bind(render.caller, onRender(...args));
  305. return original_CRC2dSave.apply(this, arguments);
  306. }
  307.  
  308. //======================================================================================>
  309. })();