// ==UserScript== // @name Bloxd Keep Run / Crouch // @namespace http://tampermonkey.net/ // @version 2.0.6 // @description Help you keep running or crouching in Bloxd.io with the key X and V. // @icon https://bloxd.io/apple-touch-icon.png?v=2 // @author Gnosis // @grant none // @run-at document-start // @license GPL3 // @match https://bloxd.io/* // @downloadURL none // ==/UserScript== (function() { 'use strict'; const infoDisplay = document.createElement('div') infoDisplay.style.position = 'absolute' infoDisplay.style.left = '0px' infoDisplay.style.bottom = '10em' infoDisplay.style.whiteSpace = 'pre' infoDisplay.style.padding = '5px' infoDisplay.style.background = '#00000088' infoDisplay.style.zIndex = '999' window.addEventListener('load', () => document.querySelector('.WholeAppWrapper').appendChild(infoDisplay)) let isRunning = '' let isCrouching = '' let isKeepingRunning = false let isKeepingCrouching = false function updateInfoDisplay() { infoDisplay.textContent = `Running: ${isRunning || 'no'}${isKeepingRunning ? '(x)' : ''}\nCrouching: ${isCrouching || 'no'}${isKeepingCrouching ? '(v)': ''}` } const shiftKeyData = { key: 'Shift', code: 'ShiftLeft', keyCode: 16, which: 16, shiftKey: true, ControlKey: false, altKey: false, metaKey: false, repeat: false, bubbles: true, cancelable: true } const cKeyData = { key: 'c', code: 'KeyC', keyCode: 67, which: 67, shiftKey: false, ControlKey: false, altKey: false, metaKey: false, repeat: false, bubbles: true, cancelable: true } const shiftDown = new KeyboardEvent('keydown', shiftKeyData) const shiftUp = new KeyboardEvent('keyup', shiftKeyData) const cDown = new KeyboardEvent('keydown', cKeyData) const cUp = new KeyboardEvent('keyup', cKeyData) document.addEventListener('keyup', e => { if (e.key === 'x') { if (isRunning === '') { isRunning = 'Shift' isKeepingRunning = true document.dispatchEvent(shiftDown) } else if (isRunning === 'Shift') { isRunning = '' isKeepingRunning = false document.dispatchEvent(shiftUp) } } else if (e.key === 'v') { if (isCrouching === '') { isCrouching = 'c' isKeepingCrouching = true document.dispatchEvent(cDown) } else if (isCrouching === 'c') { isCrouching = '' isKeepingCrouching = false document.dispatchEvent(cUp) } } else if (e.key === 'Shift' && isRunning === 'Shift') { if (isKeepingRunning) { e.stopImmediatePropagation() return } isRunning = '' } else if (e.key === 'Control' && isRunning === 'Control') { isRunning = '' } else if (e.key === 'z' && isCrouching === 'z') { isCrouching = '' } else if (e.key === 'c' && isCrouching === 'c') { if (isKeepingCrouching) { e.stopImmediatePropagation() return } isCrouching = '' } updateInfoDisplay() }) document.addEventListener('keydown', e => { if (e.key === 'Shift' && isRunning === '') { isRunning = 'Shift' } else if (e.key === 'Control' && isRunning === '') { isRunning = 'Control' } else if (e.key === 'z' && isCrouching === '') { isCrouching = 'z' } else if (e.key === 'c' && isCrouching === '') { isCrouching = 'c' } updateInfoDisplay() }) setInterval(() => { if (isKeepingRunning && !isKeepingCrouching) { document.dispatchEvent(shiftDown) } if (isKeepingCrouching && !isKeepingRunning) { document.dispatchEvent(cDown) } }, 100) updateInfoDisplay() })();