Mark Scamming Pips

Mark pips in the Scamming crime. Quick and dirty GPT special.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Mark Scamming Pips
// @namespace    https://torn.report/userscripts/
// @version      0.4
// @description  Mark pips in the Scamming crime. Quick and dirty GPT special.
// @author       Skeletron [318855]
// @match        https://www.torn.com/loader.php?sid=crimes
// @icon         https://www.google.com/s2/favicons?sz=64&domain=torn.com
// @license      GNU GPLv3
// @grant        none
// ==/UserScript==

const addTenthPipMark = true;
const addPipBorder = false;
const addPipNumbers = false; // Only good for desktop.

(function () {
  "use strict";

  function addBeforePersuasionBar(persuasionBar) {
    if (
      !persuasionBar.previousElementSibling ||
      !persuasionBar.previousElementSibling.classList.contains(
        "custom-inserted-div"
      )
    ) {
      const numbersDiv = document.createElement("div");
      numbersDiv.style.fontFamily = "monospace";
      numbersDiv.style.fontSize = "0.795rem";
      numbersDiv.style.position = "absolute";
      numbersDiv.style.bottom = "-11px";
      numbersDiv.textContent =
        "12345678901234567890123456789012345678901234567890";
      numbersDiv.classList.add("custom-inserted-div");

      persuasionBar.parentNode.insertBefore(numbersDiv, persuasionBar);
    }
  }

  // Function to process each persuasion bar
  function processPersuasionBar(persuasionBar) {
    // Add the new div before the persuasion bar
    addPipNumbers && addBeforePersuasionBar(persuasionBar);
    // Get all cells within the persuasion bar, including nested ones
    const cells = persuasionBar.getElementsByClassName("cell___AfwZm");

    // Iterate through the cells and insert "X" in every 10th cell if it hasn't been added yet
    for (let i = 0; i < cells.length; i++) {
      const cell = cells[i];

      // Apply the border to every cell
      addPipBorder &&
        (cell.style.borderLeft = "1px dotted var(--crimes-subText-color)");

      // Add '|' to every 10th cell
      if (addTenthPipMark && i !== 49 && i % 10 === 9) {
        if (!cell.textContent.includes("|")) {
          cell.textContent += "|";
        }
        cell.style.textAlign = "center"; // Set text alignment only for the cells with '|'
      }
    }
  }

  // Function to handle mutations
  function handleMutations(mutationsList) {
    for (const mutation of mutationsList) {
      if (mutation.type === "childList") {
        // Check if any new persuasion bars were added
        const newPersuasionBars = mutation.target.getElementsByClassName(
          "persuasionBar___RnWKh"
        );
        Array.from(newPersuasionBars).forEach(processPersuasionBar);
      }
    }
  }

  const crimesApp = document.querySelector(".crimes-app");
  if (crimesApp) {
    const observer = new MutationObserver(handleMutations);
    observer.observe(crimesApp, { childList: true, subtree: true });
  }
})();