Lagom / Lagom-flw:1.1.0.0.3

// ==UserScript==
// @name         Lagom-flw:1.1.0.0.3
// @namespace    http://openuserjs.org/users/Lagom
// @version      1.0
// @description  flw:1.1.0.0.3
// @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        https://*.tribalwars.com.pt/game.php?*screen=memo*
// @match        https://*.tribalwars.com.pt/game.php?*screen=place*
// @grant        GM_getResourceText
// @grant        GM_addStyle
// @grant        GM_getValue
// @grant        unsafeWindow
// ==/UserScript==

(function () {
  "use strict";

  function handleBuilding() {
    function convertToTimeZone(dateString = null) {
      const date = new Date(dateString || Date.now());
  
      const formattedDate = new Intl.DateTimeFormat("en-US", {
        timeZone: timeZone,
        year: "numeric",
        month: "2-digit",
        day: "2-digit",
        hour: "2-digit",
        minute: "2-digit",
        second: "2-digit",
        hour12: false,
      }).format(date);
  
      const [month, day, year, hour, minute, second] =
        formattedDate.match(/\d+/g);
      return new Date(`${year}-${month}-${day}T${hour}:${minute}:${second}`);
    }
  
    function generateUUID() {
      return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
        /[xy]/g,
        function (c) {
          var r = (Math.random() * 16) | 0,
            v = c == "x" ? r : (r & 0x3) | 0x8;
          return v.toString(16);
        }
      );
    }
  
    function clickButton(id, timeout = 0) {
      const button = document.querySelector(`#${id}`);
  
      if (button) {
        setTimeout(() => {
          button.click();
        }, timeout);
      }
    }
  }

  handleBuilding();

})();