Motherless strikethrough

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

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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();
  });

})();