brother-torn / Kama Motivated Resources

// ==UserScript==
// @name         Kama Motivated Resources
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Makes resources motivating with a balanced tools burst effect
// @author       Kama & Brother
// @match        https://www.torn.com/gym.php*
// @grant        none
// @run-at       document-idle
// @downloadURL  https://openuserjs.org/install/brother-torn/Kama_Motivated_Resources.user.js
// @updateURL    https://openuserjs.org/meta/brother-torn/Kama_Motivated_Resources.meta.js
// @license      AGPL-3.0-only
// ==/UserScript==

(function () {
  "use strict";

  const toolEmojis = [
    '🍆'
  ];

  function createToolBurst(startX, startY) {
    const dropCount = 40;
    const particles = [];

    for (let i = 0; i < dropCount; i++) {
      const tool = document.createElement('div');

      tool.innerText = toolEmojis[Math.floor(Math.random() * toolEmojis.length)];
      tool.style.position = 'fixed';
      tool.style.left = '0px';
      tool.style.top = '0px';
      tool.style.fontSize = (Math.random() * 16 + 20) + 'px';
      tool.style.zIndex = '9999999';
      tool.style.pointerEvents = 'none';
      tool.style.userSelect = 'none';

      document.body.appendChild(tool);

      const angle = Math.random() * Math.PI * 2;
      const velocity = (Math.random() * 12 + 8) * 0.75;

      particles.push({
        el: tool,
        x: startX,
        y: startY,
        vx: Math.cos(angle) * velocity,
        vy: (Math.sin(angle) * velocity) - 9,
        rot: Math.random() * 360,
        rotV: (Math.random() - 0.5) * 20
      });
    }

    function animate() {
      let active = false;

      for (let i = particles.length - 1; i >= 0; i--) {
        const p = particles[i];

        p.vy += 0.6;
        p.x += p.vx;
        p.y += p.vy;
        p.rot += p.rotV;

        p.el.style.transform = `translate3d(${p.x}px, ${p.y}px, 0) rotate(${p.rot}deg)`;

        if (p.y > window.innerHeight + 50) {
          p.el.remove();
          particles.splice(i, 1);
        } else {
          active = true;
        }
      }

      if (active) {
        requestAnimationFrame(animate);
      }
    }

    requestAnimationFrame(animate);
  }

  document.addEventListener("click", (e) => {
    const btn = e.target.closest?.(".torn-btn");
    if (!btn) return;

    let x = e.clientX;
    let y = e.clientY;

    if (!Number.isFinite(x) || !Number.isFinite(y)) {
      const r = btn.getBoundingClientRect();
      x = r.left + r.width / 2;
      y = r.top + r.height / 2;
    }

    createToolBurst(x, y);
  }, true);
})();