// funnySCRIPT v0.0.
4
// Made by anon + ChatGPT (Mostly ChatGPT)
// INJECT VIA CONSOLE You may need to refresh page if it unsuccessful -- I don't
know why.
// "An idiot admires complexity" -Terry Davis
const minimalMouseEvent = {
   button: 2,
   buttons: 2,
   clientX: 315,
   clientY: 177,
   screenX: 315,
   screenY: 316,
   target: document.querySelector('#noa-container'),
   type: "mousedown",
   isTrusted: true,
   view: window,
   bubbles: true,
   cancelable: true,
};
let   clientOptions = null;
let   noa = null;
let   importantList = null;
let   scalingEnabled = false;
let   wireFramesBool = false;
let   espEnabled = false;
let   intervalId = null;
let   alreadyScaled = new WeakSet();
let   teleportTrigger = { type: 'mouse', code: 4 };
let   autoPotionEnabled = false;
let   autoPotionInterval = null;
let   nameTagsEnabled = false;
let   nameTagsIntervalId = null;
let   nameTagParent = null;
let   bhopEnabled = false;
let   bhopIntervalId = null;
let   playerKey = null;
let   moveState = null;
let   physState = null;
// Main Functions
function findAndSavePlayerInventoryParent(root = noa) {
  const visited = new WeakSet();
  function recurse(obj) {
    if (typeof obj !== 'object' || obj === null || visited.has(obj)) return;
    visited.add(obj);
    for (const key in obj) {
      if (!Object.hasOwn(obj, key)) continue;
      if (key === 'playerInventory') {
        window.playerInventoryParent = obj;
        console.log('✅ Found playerInventory parent:', obj);
        return obj;
      }
      const val = obj[key];
      if (typeof val === 'object') {
        const found = recurse(val);
        if (found) return found;
      }
      }
    }
    const result = recurse(root);
    if (!result) console.warn("❌ Could not find playerInventory.");
    return result;
}
function applyScaling() {
  if (!importantList?.humanoidMesh?.list) return;
  const list = importantList.humanoidMesh.list;
  // Armour mesh visibility moved to hitboxes
  const bodyArmour = importantList.humanoidMesh?.list?.[0]?.namedNodes?.['Body|
Armour'];
  if (bodyArmour && bodyArmour._sourceMesh) {
    bodyArmour._sourceMesh.visibility = espEnabled ? 0.15 : 1;
  }
  const lowerBodyArmour = importantList.humanoidMesh?.list?.[0]?.namedNodes?.
['LowerBody|Armour'];
  if (lowerBodyArmour && lowerBodyArmour._sourceMesh) {
    lowerBodyArmour._sourceMesh.visibility = espEnabled ? 0.15 : 1;
  }
    try {
      list[0].namedNodes.BodyMesh.material.wireframe = wireFramesBool;
      list[0].namedNodes["Body|Armour"].material.wireframe = false;
      list[0].namedNodes.BodyMesh._scaling._x = 1;
      list[0].namedNodes.BodyMesh._scaling._y = 1;
      list[0].namedNodes.BodyMesh._scaling._z = 1;
    } catch {}
    for (let i = 1; i < list.length; i++) {
      const bodyMesh = list[i]?.namedNodes?.BodyMesh;
      if (!bodyMesh?.['_scaling']) continue;
      if (scalingEnabled) {
        if (!alreadyScaled.has(bodyMesh)) {
          bodyMesh._scaling._x = 15;
          bodyMesh._scaling._y = 6;
          bodyMesh._scaling._z = 25;
          bodyMesh._scaling._isDirty = true;
          alreadyScaled.add(bodyMesh);
        }
      } else {
        bodyMesh._scaling._x = 1;
        bodyMesh._scaling._y = 1;
        bodyMesh._scaling._z = 1;
        bodyMesh._scaling._isDirty = true;
      }
      try { bodyMesh.material.wireframe = wireFramesBool; } catch {}
    }
    if (!scalingEnabled) alreadyScaled = new WeakSet();
}
function toggleScaling() {
  scalingEnabled = !scalingEnabled;
  if (scalingEnabled) intervalId = setInterval(applyScaling, 2000);
  else {
    clearInterval(intervalId);
    intervalId = null;
      applyScaling();
    }
    updateHitboxButton();
}
function toggleWireframe() {
  wireFramesBool = !wireFramesBool;
  applyScaling();
  updateWireframeButton();
}
function toggleESP() {
  if (!importantList) return;
  espEnabled = !espEnabled;
  function applyRenderGroupToNamedNodes(namedNodes) {
    if (!namedNodes || typeof namedNodes !== "object") return;
    for (const key in namedNodes) {
      const mesh = namedNodes[key];
      if (!mesh || typeof mesh !== "object") continue;
      let groupId = espEnabled ? 1 : 0;
      if (espEnabled) {
        if (key === "BodyMesh") groupId = 1;
        if (key === "Body|Armour") groupId = 2;
      }
      if (mesh.renderingGroupId !== undefined) {
        if (mesh.isAnInstance && mesh._sourceMesh)
mesh._sourceMesh.renderingGroupId = groupId;
        else mesh.renderingGroupId = groupId;
      }
    }
  }
  try {
    const hum = importantList.humanoidMesh?.list?.[0]?.namedNodes;
    const quad = importantList.fourLeggedMesh?.list?.[0]?.namedNodes;
    applyRenderGroupToNamedNodes(hum);
    applyRenderGroupToNamedNodes(quad);
  } catch (e) { console.warn("ESP toggle failed:", e); }
  updateESPButton?.();
}
// Utility Functions
function findNoaAndCi() {
  const visited = new WeakSet();
  function recurse(obj) {
    if (typeof obj !== 'object' || obj === null || visited.has(obj)) return null;
    visited.add(obj);
    try {
      if ('entities' in obj && obj.entities?.t) return obj;
    } catch {}
    for (const key in obj) {
      if (!Object.hasOwn(obj, key)) continue;
      try {
        const result = recurse(obj[key]);
        if (result) return result;
      } catch {}
    }
    return null;
  }
  noa = recurse(window);
  if (!noa) {
     console.warn("❌ Could not find noa");
     return;
  }
  console.log("Found and stored as noa:", noa);
  for (const key in noa) {
     if (Object.prototype.hasOwnProperty.call(noa, key)) {
       const val = noa[key];
       if (val && typeof val === 'object' && ('_Health' in val || '_totalMaxHealth'
in val)) {
         clientOptions = val;
         console.log("Found clientOptions:", clientOptions);
         break;
       }
     }
  }
  const findCi = (entities) => {
     for (const key in entities) {
       const candidate = entities[key];
       if (typeof candidate !== 'object' || !candidate) continue;
       const values = Object.values(candidate);
       const valid = values.filter(v => v && typeof v === 'object' && 'list' in v &&
'hash' in v && '_map' in v && '_pendingRemovals' in v);
       if (values.length > 10 && valid.length / values.length > 0.8) return key;
     }
  };
  const ciKey = findCi(noa.entities);
  if (ciKey) {
     importantList = noa.entities[ciKey];
     console.log("importantList identified:", ciKey);
  }
  findAndSavePlayerInventoryParent(noa);
  updateInjectButton();
}
function findElementByText(text) {
  const all = document.querySelectorAll('div, span, button, a');
  for (const el of all) if (el.textContent.trim() === text) return el;
  return null;
}
function clickTeleportButton() {
  const teleportButtonText = findElementByText('Teleport To Lobby Spawn');
  if (teleportButtonText) {
    let clickable = teleportButtonText;
    while (clickable && !clickable.onclick && clickable.tagName !== 'BUTTON')
clickable = clickable.parentElement;
    if (clickable) {
      console.log('Clicking teleport button:', clickable);
      clickable.click();
    } else {
      console.warn('No clickable parent found, trying to click text element
itself');
      teleportButtonText.click();
    }
  } else console.warn('Teleport button text not found in DOM');
}
// Name Tags Functions
function toggleNameTags() {
  nameTagsEnabled = !nameTagsEnabled;
  if (nameTagsEnabled) {
     if (!noa) {
       console.warn("Noa not yet available, delaying NameTag enable...");
       nameTagsEnabled = false;
       setTimeout(() => { toggleNameTags(); }, 1000);
       return;
     }
     const visited = new WeakSet();
     function findParentOfNameTag(obj) {
       if (typeof obj !== 'object' || obj === null || visited.has(obj)) return null;
       visited.add(obj);
       for (const key in obj) {
         if (!Object.hasOwn(obj, key)) continue;
         try {
           const value = obj[key];
           if (value && typeof value === 'object' && value.id === '1NameTag') return
obj;
           const result = findParentOfNameTag(value);
           if (result) return result;
         } catch {}
       }
       return null;
     }
     nameTagParent = findParentOfNameTag(noa);
     if (!nameTagParent) {
       console.warn("Could not find parent of NameTags.");
       nameTagsEnabled = false;
       return;
     }
     nameTagsIntervalId = setInterval(() => {
       for (const key in nameTagParent) {
         const tag = nameTagParent[key];
         if (tag && typeof tag === 'object' && typeof tag.id === 'string' &&
tag.id.includes('NameTag')) {
           try {
             const descVisible = Object.getOwnPropertyDescriptor(tag, '_isVisible');
             if (!descVisible || descVisible.configurable) {
               Object.defineProperty(tag, '_isVisible', {
                 get() { return true; },
                 set(val) { if (val !== true) {} },
                 configurable: true
               });
             }
             const descRenderGroup = Object.getOwnPropertyDescriptor(tag,
'renderingGroupId');
             if (!descRenderGroup || descRenderGroup.configurable) {
               Object.defineProperty(tag, 'renderingGroupId', {
                 get() { return 3; },
                 set(val) { if (val !== 3) {} },
                 configurable: true
               });
             }
           } catch (e) {}
         }
       }
     }, 5000);
    console.log("NameTag visibility lock: ON");
  } else {
    clearInterval(nameTagsIntervalId);
    nameTagsIntervalId = null;
    if (nameTagParent) {
      for (const key in nameTagParent) {
        const tag = nameTagParent[key];
        if (tag && typeof tag === 'object' && typeof tag.id === 'string' &&
tag.id.includes('NameTag')) {
           try {
             const current = tag._isVisible;
             delete tag._isVisible;
             tag._isVisible = current;
           } catch (e) { console.warn("Failed to unlock _isVisible on", tag); }
        }
      }
    }
    nameTagParent = null;
    console.log("NameTag visibility lock: OFF");
  }
  updateNameTagsButton();
}
// 🔍 Only search once
function initPlayerKey() {
  if (playerKey) return playerKey;
  const results = searchForTerm(noa.entities, "_hadJumpInputPrevTick");
  if (!results.length) {
    console.warn("❌ Could not find _hadJumpInputPrevTick");
    return null;
  }
  playerKey = results[0].path.split('.')[1]; // e.g. "Vd"
  console.log("✅ Cached player entity key:", playerKey);
  return playerKey;
}
// 🔍 Laggy search rewritten to avoid blocking UI after first call
function searchForTerm(root, term) {
  const results = [];
  const visited = new WeakSet();
  function recurse(obj, path) {
    if (typeof obj !== 'object' || obj === null || visited.has(obj)) return;
    visited.add(obj);
      for (const key in obj) {
        if (!Object.hasOwn(obj, key)) continue;
        const newPath = path ? `${path}.${key}` : key;
        if (key === term) {
          results.push({ obj, key, path: newPath });
        }
        const val = obj[key];
        if (typeof val === 'object') {
          recurse(val, newPath);
        }
      }
  }
  recurse(root, '');
    return results;
}
// 🟢 Toggled by button
function toggleBHOP() {
  bhopEnabled = !bhopEnabled;
    if (bhopEnabled) {
      const key = initPlayerKey();
      if (!key) {
        bhopEnabled = false;
        return;
      }
      moveState = noa.entities[key].moveState.list[0];
      physState = noa.entities[key].movement.list[0];
      bhopIntervalId = setInterval(bunnyHop, 60);
      console.log("BHOP: ON");
    } else {
      clearInterval(bhopIntervalId);
      bhopIntervalId = null;
      console.log("BHOP: OFF");
    }
    updateBHOPButton();
}
// ⛏ BHOP logic
function bunnyHop() {
  if (!bhopEnabled || !physState.isOnGround?.() || moveState.crouching ||
moveState.speed < 0.05) return;
    moveState.jumping = true;
    physState._hadJumpInputPrevTick = false;
    setTimeout(() => {
      moveState.jumping = false;
    }, 20);
}
// GUI Functions
function makeButton(label, onClick) {
  const btn = document.createElement('button');
  btn.textContent = label;
  btn.style.width = '100%';
  btn.style.padding = '8px 12px';
  btn.style.margin = '0';
  btn.style.border = 'none';
  btn.style.borderRadius = '0';
  btn.style.backgroundColor = 'transparent';
  btn.style.color = 'white';
  btn.style.cursor = 'pointer';
  btn.style.fontSize = '14px';
  btn.style.textAlign = 'left';
  btn.style.fontWeight = '600'; // This makes the text semibold
  btn.onclick = onClick;
  return btn;
}
function updateInjectButton() { injectBtn.style.color = noa ? '#00FF00' :
'#FF4444'; }
function updateHitboxButton() { hitboxBtn.style.color = scalingEnabled ?
'#00FF00' : 'white'; }
function updateWireframeButton() { wireframeBtn.style.color = wireFramesBool ?
'#00FF00' : 'white'; }
function updateESPButton() { espBtn.style.color = espEnabled ? '#00FF00' : 'white';
}
function updateNameTagsButton() { nameTagsBtn.style.color = nameTagsEnabled ?
'#00FF00' : 'white'; }
function updateBHOPButton() { bhopBtn.style.color = bhopEnabled ? '#00FF00' :
'white'; }
// GUI Setup
const gui = document.createElement('div');
gui.style.position = 'fixed';
gui.style.top = '10px';
gui.style.left = '10px';
gui.style.width = '240px';
gui.style.backgroundColor = 'rgba(0, 0, 0, 0.2)';
gui.style.color = 'white';
gui.style.padding = '0';
gui.style.zIndex = '9999';
gui.style.cursor = 'move';
gui.style.fontFamily = 'Arial, sans-serif';
gui.style.userSelect = 'none';
let optionsVisible = true;
let currentTitleColor = '#0070FF';
const title = document.createElement('div');
title.textContent = 'funnySCRIPT v0.0.4';
title.style.fontWeight = 'bold';
title.style.fontSize = '16px';
title.style.backgroundColor = currentTitleColor;
title.style.padding = '10px';
title.style.margin = '0';
title.style.color = 'white';
title.style.cursor = 'pointer';
let isDragging = false, offsetX = 0, offsetY = 0, dragStartX = 0, dragStartY = 0;
title.addEventListener('mousedown', (e) => {
  isDragging = true;
  offsetX = e.clientX - gui.offsetLeft;
  offsetY = e.clientY - gui.offsetTop;
  dragStartX = e.clientX;
  dragStartY = e.clientY;
});
document.addEventListener('mouseup', (e) => {
  if (isDragging) {
    const moved = Math.abs(e.clientX - dragStartX) + Math.abs(e.clientY -
dragStartY);
    if (moved < 5) {
      optionsVisible = !optionsVisible;
      guiOptions.style.display = optionsVisible ? 'block' : 'none';
    }
      isDragging = false;
  }
});
document.addEventListener('mousemove', (e) => {
  if (isDragging) {
    gui.style.left = `${e.clientX - offsetX}px`;
    gui.style.top = `${e.clientY - offsetY}px`;
  }
});
gui.appendChild(title);
const guiOptions = document.createElement('div');
gui.appendChild(guiOptions);
const colorInput = document.createElement('input');
colorInput.type = 'color';
colorInput.value = currentTitleColor;
colorInput.style.width = 'calc(100% - 20px)';
colorInput.style.padding = '5px';
colorInput.style.margin = '0 10px 10px 10px';
colorInput.style.backgroundColor = 'rgba(0, 0, 0, 0.3)';
colorInput.style.color = 'white';
colorInput.style.fontSize = '14px';
colorInput.style.border = 'none';
colorInput.style.borderRadius = '0';
colorInput.style.cursor = 'pointer';
colorInput.oninput = () => {
   currentTitleColor = colorInput.value;
   title.style.backgroundColor = currentTitleColor;
};
const   injectBtn = makeButton('Inject', findNoaAndCi);
const   hitboxBtn = makeButton('Hitbox', toggleScaling);
const   wireframeBtn = makeButton('Wireframes', toggleWireframe);
const   espBtn = makeButton('ESP', toggleESP);
const   nameTagsBtn = makeButton('Anti-Invisibility', toggleNameTags);
const   bhopBtn = makeButton('BHOP', toggleBHOP);
guiOptions.appendChild(injectBtn);
guiOptions.appendChild(bhopBtn);
guiOptions.appendChild(hitboxBtn);
guiOptions.appendChild(wireframeBtn);
guiOptions.appendChild(espBtn);
guiOptions.appendChild(nameTagsBtn);
const teleportLabel = document.createElement('label');
teleportLabel.textContent = '/spawn (survival):';
teleportLabel.style.display = 'block';
teleportLabel.style.margin = '10px 0 5px 0';
teleportLabel.style.padding = '0 10px';
const teleportSelect = document.createElement('select');
teleportSelect.style.width = 'calc(100% - 20px)';
teleportSelect.style.padding = '5px';
teleportSelect.style.margin = '0 10px 10px 10px';
teleportSelect.style.backgroundColor = 'rgba(0, 0, 0, 0.3)';
teleportSelect.style.color = 'white';
teleportSelect.style.fontSize = '14px';
teleportSelect.style.border = 'none';
teleportSelect.style.borderRadius = '0';
[
  { type: 'mouse', label: 'MouseB4', code: 3 },
  { type: 'mouse', label: 'MouseB5', code: 4 },
  { type: 'keyboard', label: 'Key: T', code: 'KeyT' },
  { type: 'keyboard', label: 'Key: Y', code: 'KeyY' },
  { type: 'keyboard', label: 'Key: R', code: 'KeyR' }
].forEach(opt => {
  const option = document.createElement('option');
  option.value = JSON.stringify({ type: opt.type, code: opt.code });
  option.textContent = opt.label;
  teleportSelect.appendChild(option);
});
teleportSelect.value = JSON.stringify(teleportTrigger);
teleportSelect.onchange = () => {
   teleportTrigger = JSON.parse(teleportSelect.value);
   console.log('Teleport trigger changed to:', teleportTrigger);
};
guiOptions.appendChild(teleportLabel);
guiOptions.appendChild(teleportSelect);
guiOptions.appendChild(colorInput);
document.body.appendChild(gui);
// Event Listeners
window.addEventListener('mousedown', (event) => {
  if (teleportTrigger.type === 'mouse' && event.button === teleportTrigger.code) {
    console.log(`Teleport triggered by mouse button ${event.button}`);
    event.preventDefault();
    clickTeleportButton();
  }
});
window.addEventListener('keydown', (event) => {
  if (teleportTrigger.type === 'keyboard' && event.code === teleportTrigger.code) {
    console.log(`Teleport triggered by keyboard key ${event.code}`);
    event.preventDefault();
    clickTeleportButton();
  }
});
// Initialize
updateInjectButton();
updateHitboxButton();
updateWireframeButton();
updateESPButton();
updateNameTagsButton();
updateBHOPButton();