torn.com No dark text in forum

torn.com No Dark Text - Removes all dark text in the forum, so it's readable in dark mode

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         torn.com No dark text in forum
// @namespace    xentac
// @version      20251216.2
// @description  torn.com No Dark Text - Removes all dark text in the forum, so it's readable in dark mode
// @author       xentac [3354782]
// @match        *.torn.com/forums.php*
// @license MIT
// ==/UserScript==

"use strict";

function removeDarkStyling(node) {
  //console.log(node);
  if (node.querySelectorAll) {
    var spans = node.querySelectorAll(".post span");

    for (var i = 0; i < spans.length; i++) {
      const elem = spans[i];
      // TODO: Write a better color parser. Everything below a certain RGB value should be nulled
      if (elem.style.color == "rgb(51, 51, 51)") {
        elem.style.color = null;
      } else if (elem.style.color == "rgb(34, 34, 34)") {
        elem.style.color = null;
      } else if (elem.style.color == "var(--te-text-color-gray5)") {
        elem.style.color = null;
      } else if (elem.style.color == "rgb(0, 0, 0)") {
        elem.style.color = null;
      } else if (elem.style.color == "black") {
        elem.style.color = null;
      }
    }
  }
}

function react(mutation) {
  mutation.addedNodes.forEach(removeDarkStyling);
}

function reactAll(mutations) {
  mutations.forEach(react);
}

(function () {
  const target = document.querySelector("#forums-page-wrap");
  removeDarkStyling(target);
  const observer = new MutationObserver(reactAll);
  observer.observe(target, { childList: true, subtree: true });
  //observer.disconnect();
})();