Another Auto Clicker for More Ore

Another Auto Clicker for More Ore (working as of v1.5.7 Beta). Clicks weak spots (with a randomized delay), manual attacks for quests, gold nuggets, and hulk smashes.

As of 2022-06-14. See the latest version.

// ==UserScript==
// @name        Another Auto Clicker for More Ore
// @namespace   Violentmonkey Scripts
// @match       https://syns.studio/more-ore/
// @grant       none
// @version     1.4
// @author      BlueberryPir8
// @icon        https://syns.studio/more-ore/misc-tinyRock.22ef93dd.ico
// @license     MIT
// @compatible  firefox >=52
// @compatible  chrome >=57
// @compatible  edge >=14
// @description Another Auto Clicker for More Ore (working as of v1.5.7 Beta). Clicks weak spots (with a randomized delay), manual attacks for quests, gold nuggets, and hulk smashes.
// ==/UserScript==

/* jshint esversion: 6 */

Element.prototype._addEventListener = Element.prototype.addEventListener;
Element.prototype.addEventListener = function (...args) {
  const weakSpot = this.classList?.contains("weak-spot") ? "Weak Spot" : null;
  const manualAttack = this.classList?.contains("manual-attack")
    ? "Manual Attack"
    : null;
  if (!(weakSpot || manualAttack)) {
    this._addEventListener(...args);
    return;
  }
  let cb = args[1];
  args[1] = function cbOverride(...args2) {
    args2[0] = Object.assign({}, args2[0]);
    args2[0].isTrusted = true;
    return cb(...args2);
  };
  return this._addEventListener(...args);
};

let prev;
let shortTimer = 0;
let longTimer = 0;

function frame(ts) {
  if (!prev) {
    prev = ts;
  }
  const delta = ts - prev;
  shortTimer += delta;
  longTimer += delta;

  if (shortTimer > 50) {
    setTimeout(() => {
      if (document.querySelector(".weak-spot")) {
        document.querySelector(".weak-spot").click();
      }
    });
    shortTimer = shortTimer % 50;
  }

  if (longTimer > 200) {
    setTimeout(() => {
      if (document.querySelector(".manual-attack")) {
        if (
          !document.querySelector(".quest-banner-container > .quest-success") &&
          !document.querySelector(".quest-banner-container > .quest-failed")
        )
          document.querySelector(".manual-attack").click();
      }
    });
    setTimeout(() => {
      if (document.querySelector(".gold-nugget-container")) {
        document.querySelector(".gold-nugget-container").click();
      }
    });
    setTimeout(() => {
      if (document.querySelector(".active-skill-hulkSmash")) {
        const elem = document.querySelector(".active-skill-hulkSmash");
        if (!elem.classList?.contains("on-cooldown")) elem.click();
      }
    });
    longTimer = longTimer % 200;
  }

  prev = ts;

  window.requestAnimationFrame(frame);
}

window.requestAnimationFrame(frame);