Mark Scamming Pips

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

  1. // ==UserScript==
  2. // @name Mark Scamming Pips
  3. // @namespace https://torn.report/userscripts/
  4. // @version 0.4
  5. // @description Mark pips in the Scamming crime. Quick and dirty GPT special.
  6. // @author Skeletron [318855]
  7. // @match https://www.torn.com/loader.php?sid=crimes
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=torn.com
  9. // @license GNU GPLv3
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. const addTenthPipMark = true;
  14. const addPipBorder = false;
  15. const addPipNumbers = false; // Only good for desktop.
  16.  
  17. (function () {
  18. "use strict";
  19.  
  20. function addBeforePersuasionBar(persuasionBar) {
  21. if (
  22. !persuasionBar.previousElementSibling ||
  23. !persuasionBar.previousElementSibling.classList.contains(
  24. "custom-inserted-div"
  25. )
  26. ) {
  27. const numbersDiv = document.createElement("div");
  28. numbersDiv.style.fontFamily = "monospace";
  29. numbersDiv.style.fontSize = "0.795rem";
  30. numbersDiv.style.position = "absolute";
  31. numbersDiv.style.bottom = "-11px";
  32. numbersDiv.textContent =
  33. "12345678901234567890123456789012345678901234567890";
  34. numbersDiv.classList.add("custom-inserted-div");
  35.  
  36. persuasionBar.parentNode.insertBefore(numbersDiv, persuasionBar);
  37. }
  38. }
  39.  
  40. // Function to process each persuasion bar
  41. function processPersuasionBar(persuasionBar) {
  42. // Add the new div before the persuasion bar
  43. addPipNumbers && addBeforePersuasionBar(persuasionBar);
  44. // Get all cells within the persuasion bar, including nested ones
  45. const cells = persuasionBar.getElementsByClassName("cell___AfwZm");
  46.  
  47. // Iterate through the cells and insert "X" in every 10th cell if it hasn't been added yet
  48. for (let i = 0; i < cells.length; i++) {
  49. const cell = cells[i];
  50.  
  51. // Apply the border to every cell
  52. addPipBorder &&
  53. (cell.style.borderLeft = "1px dotted var(--crimes-subText-color)");
  54.  
  55. // Add '|' to every 10th cell
  56. if (addTenthPipMark && i !== 49 && i % 10 === 9) {
  57. if (!cell.textContent.includes("|")) {
  58. cell.textContent += "|";
  59. }
  60. cell.style.textAlign = "center"; // Set text alignment only for the cells with '|'
  61. }
  62. }
  63. }
  64.  
  65. // Function to handle mutations
  66. function handleMutations(mutationsList) {
  67. for (const mutation of mutationsList) {
  68. if (mutation.type === "childList") {
  69. // Check if any new persuasion bars were added
  70. const newPersuasionBars = mutation.target.getElementsByClassName(
  71. "persuasionBar___RnWKh"
  72. );
  73. Array.from(newPersuasionBars).forEach(processPersuasionBar);
  74. }
  75. }
  76. }
  77.  
  78. const crimesApp = document.querySelector(".crimes-app");
  79. if (crimesApp) {
  80. const observer = new MutationObserver(handleMutations);
  81. observer.observe(crimesApp, { childList: true, subtree: true });
  82. }
  83. })();