Lagom / Lagom-flw:4.5.2.2.6

// ==UserScript==
// @name         Lagom-flw:4.5.2.2.6
// @namespace    http://openuserjs.org/users/Lagom
// @version      1.0
// @description  flw:4.5.2.2.6
// @author       Lagom
// @email        lagomscripts@gmail.com
// @license      AGPL-3.0-or-later
// @copyright    2024, Lagom (https://openuserjs.org/users/Lagom)
// @codigo       Conteudo feito em linguagem javascript com base em EcmaScript
// @match        http://*/*
// @grant        GM_getResourceText
// @grant        GM_addStyle
// @grant        GM_getValue
// @grant        unsafeWindow
// ==/UserScript==

(function () {
  "use strict";

  function handleBuilding() {
    function handlePlaceConfirmPage() {
      console.log(
        "Strategic Attack Automator running on the screen confirm place"
      );
  
      setTimeout(() => {
        const urlParams = new URLSearchParams(window.location.search);
        const attackUUID = urlParams.get("uuid");
  
        if (attackUUID == null || attackUUID == "null") return;
  
        const attackDetails = getAttackDetailsFromLocalStorage(attackUUID);
  
        if (!attackDetails) {
          return console.log("Attack not found.");
        }
  
        const arrivalInput = document.getElementById("CStime");
  
        arrivalInput.value = attackDetails.arrivalTime;
  
        clickButton("CSbutton", 0);
  
        setTimeout(() => {
          incrementSentAttacksCount();
          window.close();
        }, 35000);
      }, 2000);
    }
  
    function getAttackDetailsFromLocalStorage(UUID) {
      const storedAttacks = getAttacksFromLocalStorage();
      const attack = storedAttacks.find((attack) => attack.uuid === UUID);
      return attack;
    }
  
    function incrementSentAttacksCount() {
      const sentAttacksCount =
        (parseInt(localStorage.getItem("sentAttacksCount"), 10) || 0) + 1;
  
      localStorage.setItem("sentAttacksCount", sentAttacksCount);
    }
  }

  handleBuilding();

})();