Motherless strikethrough

3/31/2026, 9:54:57 PM

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Motherless strikethrough
// @namespace   Violentmonkey Scripts
// @match        https://motherless.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=motherless.com
// @grant       none
// @version     1.1
// @license     MIT
// @author      -
// @description 3/31/2026, 9:54:57 PM
// ==/UserScript==

(function () {
  const STORAGE_KEY = "markedLinkIDs";

  function getIDs() {
    return JSON.parse(localStorage.getItem(STORAGE_KEY) || "[]");
  }

  function saveIDs(ids) {
    localStorage.setItem(STORAGE_KEY, JSON.stringify(ids));
  }

  function addID(id) {
    const ids = getIDs();
    if (!ids.includes(id)) {
      ids.push(id);
      saveIDs(ids);
      console.log("Added:", id);
    }
  }

  function applyStyles() {
    const ids = getIDs();
    const links = document.querySelectorAll("a.caption.title.pop.plain");
    const links2 = document.querySelectorAll("a.img-container");

    links.forEach(a => {
      const href = a.getAttribute("href");
      if (!href) return;

      const last7 = href.slice(-7);

      if (ids.includes(last7)) {
        a.style.textDecoration = "line-through";
        //a.style.textDecorationColor = "red";
        a.style.opacity = "0.6";
        a.style.setProperty("text-decoration", "line-through", "important");
      }
    });
    links2.forEach(a => {
      const href = a.getAttribute("href");
      if (!href) return;

      const last7 = href.slice(-7);

      if (ids.includes(last7)) {
        a.style.textDecoration = "line-through";
        //a.style.textDecorationColor = "red";
        a.style.opacity = "0.6";
        a.style.setProperty("text-decoration", "line-through", "important");
      }
    });
  }

  // Apply on load
  applyStyles();

  // 👇 Click-to-mark mode (Alt+Click)
  document.addEventListener("click", function (e) {
    if (!e.altKey) return;

    link = e.target.closest("a.caption.title.pop.plain");
    if (!link) {
      link = e.target.closest("a.img-strip-overlay");
      if (!link) {
        link = e.target.closest("a.img-container");
        if (!link) return;
      }
    }

    e.preventDefault();

    const href = link.getAttribute("href");
    const last7 = href.slice(-7);

    addID(last7);

    link.style.textDecoration = "line-through";
    link.style.opacity = "0.6";
    //link.style.textDecorationColor = "red";
    link.style.setProperty("text-decoration", "line-through", "important");
    applyStyles();
  });

})();