How do I make isTrusted true when I [code]
- User
How do I make isTrusted true when I
// ==UserScript== // @name Arras.io Aimcult Goober // @namespace http://tampermonkey.net/ // @version 1.0.0 // @description aim obfuscation with aim helper // @author mache102 // @match https://arras.io/ // @icon https://www.google.com/s2/favicons?sz=64&domain=arras.io // @grant none // ==/UserScript== var key_utils = (function() { // map event.key to event.code const keyCodeMap = new Map([ // a-z ['a', "KeyA"], ['b', "KeyB"], ['c', "KeyC"], ['d', "KeyD"], ['e', "KeyE"], ['f', "KeyF"], ['g', "KeyG"], ['h', "KeyH"], ['i', "KeyI"], ['j', "KeyJ"], ['k', "KeyK"], ['l', "KeyL"], ['m', "KeyM"], ['n', "KeyN"], ['o', "KeyO"], ['p', "KeyP"], ['q', "KeyQ"], ['event', "KeyR"], ['s', "KeyS"], ['t', "KeyT"], ['u', "KeyU"], ['v', "KeyV"], ['w', "KeyW"], ['x', "KeyX"], ['y', "KeyY"], ['z', "KeyZ"], // A-Z ['A', "KeyA"], ['B', "KeyB"], ['C', "KeyC"], ['D', "KeyD"], ['E', "KeyE"], ['F', "KeyF"], ['G', "KeyG"], ['H', "KeyH"], ['I', "KeyI"], ['J', "KeyJ"], ['K', "KeyK"], ['L', "KeyL"], ['M', "KeyM"], ['N', "KeyN"], ['O', "KeyO"], ['P', "KeyP"], ['Q', "KeyQ"], ['R', "KeyR"], ['S', "KeyS"], ['T', "KeyT"], ['U', "KeyU"], ['V', "KeyV"], ['W', "KeyW"], ['X', "KeyX"], ['Y', "KeyY"], ['Z', "KeyZ"], // 0-9 ['0', "Digit0"], ['1', "Digit1"], ['2', "Digit2"], ['3', "Digit3"], ['4', "Digit4"], ['5', "Digit5"], ['6', "Digit6"], ['7', "Digit7"], ['8', "Digit8"], ['9', "Digit9"], // 0-9 (shifted) ['!', "Digit1"], ['@', "Digit2"], ['#', "Digit3"], ['$', "Digit4"], ['%', "Digit5"], ['^', "Digit6"], ['&', "Digit7"], ['*', "Digit8"], ['(', "Digit9"], [')', "Digit0"], // common keys for games (space, shift, ctrl, alt, arrow keys, etc.) [' ', "Space"], ['Space', ' '], ['Shift', "ShiftLeft"], ['Control', "ControlLeft"], ['Alt', "AltLeft"], ['ArrowUp', "ArrowUp"], ['ArrowDown', "ArrowDown"], ['ArrowLeft', "ArrowLeft"], ['ArrowRight', "ArrowRight"], ['`', "Backquote"], ['-', "Minus"], ['=', "Equal"], ['[', "BracketLeft"], [']', "BracketRight"], ['\\', "Backslash"], [';', "Semicolon"], ['\'', "Quote"], [',', "Comma"], ['.', "Period"], ['/', "Slash"], // other keys ['Escape', "Escape"], ['Enter', "Enter"], ['Tab', "Tab"], ['CapsLock', "CapsLock"], ['Backspace', "Backspace"], ['Delete', "Delete"], ['Insert', "Insert"], ['Home', "Home"], ['End', "End"], ['PageUp', "PageUp"], ['PageDown', "PageDown"], ['ContextMenu', "ContextMenu"], ['ScrollLock', "ScrollLock"], ['Pause', "Pause"], ]); return { // check if an activation sequence (string) matches the event's keydown matchesActivationSeq: function(e, keybind) { if (!keybind) { return false; } const parts = keybind.split('+'); const key = parts.pop(); // The last part is the key const modifiers = { Shift: e.shiftKey, Ctrl: e.ctrlKey, Alt: e.altKey, Meta: e.metaKey // Meta is the Command key on Mac and Windows key on Windows }; // Check if all specified modifiers are pressed for (const modifier of parts) { if (!modifiers[modifier]) { return false; // If any modifier is not pressed, return false } } // Check if the actual key pressed matches the specified key // Note: For digits and symbols, use e.key instead of e.code because e.code might not match the actual character depending on the keyboard layout return e.code === keyCodeMap.get(key) || e.key === key; }, keyCodeMap: keyCodeMap }; })(); var utils = (function() { return { set_lskey: function(key, value) { localStorage.setItem(key, JSON.stringify(value)); }, get_lskey: function(key) { return JSON.parse(localStorage.getItem(key)); }, clamp_val: function(val, min, max) { return Math.min(Math.max(val, min), max); }, debounce: function (func, wait) { let timeout; return function(...args) { const context = this; const later = () => { timeout = null; func.apply(context, args); }; clearTimeout(timeout); timeout = setTimeout(later, wait); }; } }; })(); (function() { const KEYBIND_KEY = '`'; const KEYBIND_KEY_2 = '-'; const PRESS_COUNT = 2; const PRESS_TIME = 1.0; let mpos = {x: 0, y: 0}; let goober_enabled = false; let aimhelp_enabled = false; let prog_input = false; let manual_firing = false; let aimhelp_opacity = 0.2; let radius = 200; let radius2 = 10; let eps = Math.PI / 32; const LS_GOOBER_ENABLE_KEY = 'goober_enabled'; const LS_AIMHELP_ENABLE_KEY = 'aimhelp_enabled'; // load from local storage if (utils.get_lskey(LS_GOOBER_ENABLE_KEY) !== null) { goober_enabled = !!(utils.get_lskey(LS_GOOBER_ENABLE_KEY)); } if (utils.get_lskey(LS_AIMHELP_ENABLE_KEY) !== null) { aimhelp_enabled = !!(utils.get_lskey(LS_AIMHELP_ENABLE_KEY)); } let eventListenerElementMap = new Map(); function simulateMouseMove(xy_, c = true) { let xy = xy_; if (c) { xy = {x: xy_.x + window.innerWidth / 2, y: -xy_.y + window.innerHeight / 2}; } let event = { clientX: xy.x, clientY: xy.y }; prog_input = true; let el = eventListenerElementMap.get('mousemove'); el.dispatchEvent(new MouseEvent('mousemove', event)); } const originalGlobalAddEventListener = EventTarget.prototype.addEventListener; EventTarget.prototype.addEventListener = function(type, listener, options) { eventListenerElementMap.set(type, this); if (type === 'mousemove') { const originalListener = listener; listener = function(event) { // record mousepos for aim indicator console.log(JSON.stringify(event)); if (!prog_input) { mpos = {x: event.clientX - window.innerWidth / 2, y: -event.clientY + window.innerHeight / 2}; } if (goober_enabled) { // obfuscation enabled if (manual_firing) { // user is manually aiming if (prog_input) return; // ignore programmatic input (i.e. aim obfuscation) } else { if (!prog_input) { return; // ignore user aim to continue aim obfuscation } } } let event_ = { clientX: event.clientX, clientY: event.clientY, isTrusted: true }; originalListener.call(this, event_); prog_input = false; }; } else if (type === 'mousedown' || type === 'mouseup') { const originalListener = listener; listener = function(event) { if (type === 'mousedown') { manual_firing = true; } let event_ = { clientX: event.clientX, clientY: event.clientY, isTrusted: true }; originalListener.call(this, event_); if (type === 'mouseup') { manual_firing = false; } }; } return originalGlobalAddEventListener.call(this, type, listener, options); }; const r_min = 100; const r_max = 200; function get_radius() { return r_min + (r_max - r_min) / 2; } let move_interval; function goober(mspt, f) { const start = performance.now(); // call f every mspt ms move_interval = setInterval(function() { let t = performance.now() - start; let rot = f(t, mspt); let R = get_radius(); // entirely optional, constant radius fine too let x = R * Math.cos(rot); let y = R * Math.sin(rot); simulateMouseMove({x: x, y: y}, true); }, mspt); } // dont set this too low or lag let mspt = 33; let f = function(t, m) { // shrimple function for aim obfuscation return t * 2 * Math.PI * (t / 1000); }; const canvas = document.createElement('canvas'); canvas.id = 'amx_canvas'; canvas.width = window.innerWidth; canvas.height = window.innerHeight; const ctx = canvas.getContext('2d'); ctx.fillStyle = `rgba(255, 0, 0, ${aimhelp_opacity})`; ctx.strokeStyle = `rgba(255, 0, 0, ${aimhelp_opacity})`; ctx.lineWidth = 5; document.body.appendChild(canvas); // resize canvas along with window window.addEventListener('resize', utils.debounce(function() { canvas.width = window.innerWidth; canvas.height = window.innerHeight; }, 250)); function draw_aimhelp() { ctx.clearRect(0, 0, canvas.width, canvas.height); if (mpos.y === 0 && mpos.x === 0) return; let rot = -Math.atan2(mpos.y, mpos.x); radius = Math.pow(Math.pow(mpos.x, 2) + Math.pow(mpos.y, 2), 0.5); ctx.beginPath(); ctx.arc(window.innerWidth / 2, window.innerHeight / 2, radius, rot - eps, rot + eps); ctx.arc(window.innerWidth / 2, window.innerHeight / 2, radius2, rot + eps, rot - eps); ctx.fill(); // ctx.stroke(); } let aimhelp_interval; function aimhelp() { // draw circle around mouse aimhelp_interval = setInterval(function() { draw_aimhelp(); }, mspt); } let style = document.createElement('style'); style.innerHTML = ` #amx_c { position: absolute; left: 0%; top: 10%; min-height: 200px; max-width: 300px; z-index: 999999; background-color: rgba(255, 255, 255, 0.1); border: 1px solid black; display: block; font: bold 13.1806px / 21.089px Ubuntu; } #goober_status { position: absolute; left: 10%; top: 0; z-index: 999999; background-color: rgba(255, 0, 0, 0.5); color: rgba(0, 0, 0, 1); } #aimhelp_status { position: absolute; left: 10%; top: 40px; z-index: 999999; background-color: rgba(255, 0, 0, 0.5); color: rgba(0, 0, 0, 1); } #amx_canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 999999; background:transparent; pointer-events: none; } `; document.head.appendChild(style); let goober_status; function toggle_goober() { goober_enabled = !goober_enabled; utils.set_lskey(LS_GOOBER_ENABLE_KEY, goober_enabled); // set if (!goober_status) { return; } goober_status.innerText = goober_enabled ? 'Aimcult ON' : 'Aimcult OFF'; goober_status.style.background = goober_enabled ? 'rgba(0, 255, 0, 0.5)' : 'rgba(255, 0, 0, 0.5)'; clearInterval(move_interval); if (goober_enabled) { goober(mspt, f); } } function toggle_aim_helper() { aimhelp_enabled = !aimhelp_enabled; utils.set_lskey(LS_AIMHELP_ENABLE_KEY, aimhelp_enabled); if (!aimhelp_status) { return; } aimhelp_status.innerText = aimhelp_enabled ? 'Aim Helper ON' : 'Aim Helper OFF'; aimhelp_status.style.background = aimhelp_enabled ? 'rgba(0, 255, 0, 0.5)' : 'rgba(255, 0, 0, 0.5)'; clearInterval(aimhelp_interval); if (aimhelp_enabled) { aimhelp(); } } if (goober_enabled) { goober(mspt, f); } if (aimhelp_enabled) { aimhelp(); } const amx_c = document.createElement('div'); amx_c.id = 'amx_c'; // button displaying the current goober_status of the script goober_status = document.createElement('button'); goober_status.id = 'goober_status'; goober_status.innerText = goober_enabled ? 'Aimcult ON' : 'Aimcult OFF'; goober_status.style.background = goober_enabled ? 'rgba(0, 255, 0, 0.5)' : 'rgba(255, 0, 0, 0.5)'; // onclick goober_status.onclick = function() { toggle_goober(); }; amx_c.appendChild(goober_status); aimhelp_status = document.createElement('button'); aimhelp_status.id = 'aimhelp_status'; aimhelp_status.innerText = aimhelp_enabled ? 'Aim Helper ON' : 'Aim Helper OFF'; aimhelp_status.style.background = aimhelp_enabled ? 'rgba(0, 255, 0, 0.5)' : 'rgba(255, 0, 0, 0.5)'; aimhelp_status.onclick = function() { toggle_aim_helper(); }; amx_c.appendChild(aimhelp_status); let goober_pressCount = 0; let goober_lastPressTime = 0; document.addEventListener('keydown', function(event) { if (event.key === KEYBIND_KEY) { let currentTime = Date.now(); if (currentTime - goober_lastPressTime > PRESS_TIME * 1000) { goober_pressCount = 0; } goober_pressCount++; goober_lastPressTime = currentTime; if (goober_pressCount === PRESS_COUNT) { toggle_goober(); goober_pressCount = 0; } } }); let aimhelp_pressCount = 0; let aimhelp_lastPressTime = 0; document.addEventListener('keydown', function(event) { if (event.key === KEYBIND_KEY_2) { let currentTime = Date.now(); if (currentTime - aimhelp_lastPressTime > PRESS_TIME * 1000) { aimhelp_pressCount = 0; } aimhelp_pressCount++; aimhelp_lastPressTime = currentTime; if (aimhelp_pressCount === PRESS_COUNT) { toggle_aim_helper(); aimhelp_pressCount = 0; } } }); document.body.appendChild(amx_c); })(); - Assistant
- User
el.dispatchEvent(new MouseEvent('mousemove', event)); it happens in this line
- Assistant
- User
ok it make isTrusted true all the time but my tank still doesn't spin between clicks
- Assistant