arras - build parser

use window.build to get the current player build! note: with release of future builds pointer to values may change

// ==UserScript==
// @name        arras - build parser
// @namespace   Violentmonkey Scripts
// @match       https://arras.io/*
// @grant       none
// @version     1.0
// @author      ales
// @description use window.build to get the current player build! note: with release of future builds pointer to values may change
// @run-at      document-start
// @license MIT
// ==/UserScript==

// prevent randomness in encoded values
crypto.getRandomValues = () => [0]

let WebAssembly_instantiateStreaming = WebAssembly.instantiateStreaming
WebAssembly.instantiateStreaming = async function(wasm, imports) {

  let instance = await WebAssembly_instantiateStreaming.call(this, wasm, imports)
  window.exports = instance.instance.exports
  let memory_export = instance.instance.exports.g // "g" might change with future builds but ¯\_(ツ)_/¯

  Object.defineProperty(window, "HEAPU32", { get() { return new Uint32Array(memory_export.buffer) } })

  return instance
}

let ptr = 344648

Object.defineProperty(window, "build", {
  get() {

    let c
    let build

    c = HEAPU32[ptr + 1]
    max_health = ((c >> 16) & 0xFF) ^ 159 // max health
    body_damage = (c & 0xFF) ^ 213 // body damage

    c = HEAPU32[ptr + 2]
    bullet_health = ((c >> 16) & 0xFF) - 193 // bullet health
    bullet_speed = (c & 0xFF) - 240 // bullet speed

    c = HEAPU32[ptr + 3]
    bullet_damage = ((c >> 16) & 0xFF) ^ 43 // bullet damage
    bullet_penetration = (c & 0xFF) ^ 199 // bullet penetration

    c = HEAPU32[ptr + 4]
    movement_speed = ((c >> 16) & 0xFF) - 47 // movement speed
    reload = (c & 0xFF) - 214 // reload

    c = HEAPU32[ptr + 5]
    shield_capacity = ((c >> 16) & 0xFF) ^ 86 // shield capacity
    shield_regeneration = (c & 0xFF) ^ 41 // shield regeneration

    build = new Uint8Array([body_damage, max_health, bullet_speed, bullet_health, bullet_penetration, bullet_damage, reload, movement_speed, shield_regeneration, shield_capacity])

    return {
      build_points: HEAPU32[ptr] - 1607198298,
      body_damage: build[0],
      max_health: build[1],
      bullet_speed: build[2],
      bullet_health: build[3],
      bullet_penetration: build[4],
      bullet_damage: build[5],
      reload: build[6],
      movement_speed: build[7],
      shield_regeneration: build[8],
      shield_capacity: build[9],
      string: `${build[0]}/${build[1]}/${build[2]}/${build[3]}/${build[4]}/${build[5]}/${build[6]}/${build[7]}/${build[8]}/${build[9]}`
    }
  }
})