Motherless strikethrough2

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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

(function () {
  const STORAGE_KEY = "markedLinkIDs";
  const SELECTORS = "a.caption.title.pop.plain, a.img-container, a.img-strip-overlay, div.media-meta-title";

  // --- Data Management ---
  const getIDs = () => JSON.parse(localStorage.getItem(STORAGE_KEY) || "[]");
  const saveIDs = (ids) => localStorage.setItem(STORAGE_KEY, JSON.stringify(ids));

  function toggleID(id) {
    let ids = getIDs();
    const index = ids.indexOf(id);

    if (index > -1) {
      ids.splice(index, 1); // Removes specific ID
      console.log("Removed:", id);
    } else {
      ids.push(id); // Adds ID
      console.log("Added:", id);
    }
    saveIDs(ids);
    applyStyles();
  }

  // --- UI Logic ---
  function applyStyles() {
    const ids = getIDs();
    /* Get all from AI script, using CSS selectors. */
    document.querySelectorAll(SELECTORS).forEach(el => {
      const href = el.getAttribute("href") || "";
      const last7 = href.slice(-7);
      const isMarked = ids.includes(last7);

      // Set styles based on marked status (Reset to defaults if not marked)
      el.style.opacity = isMarked ? "0.5" : "1";
      if (isMarked) {
        el.style.setProperty("text-decoration", "line-through", "important");
      } else {
        el.style.removeProperty("text-decoration");
      }
    });
    /* Do similar for H1 title, so it shows up when on the page for the image or video. */
    const last7URL = (location.pathname).slice(-7);
    const isMarkedURL = ids.includes(last7URL);
    document.querySelectorAll("h1").forEach(el => {
      el.style.opacity = isMarkedURL ? "0.5" : "1";
      if (isMarkedURL) {
        el.style.setProperty("text-decoration", "line-through", "important");
      } else {
        el.style.removeProperty("text-decoration");
      }
    });
  }

  // --- Event Handling ---
  document.addEventListener("click", (e) => {
    if (!e.altKey) return;

    const link = e.target.closest(SELECTORS);
    if (!link) return;

    e.preventDefault();
    const last7 = link.getAttribute("href")?.slice(-7);
    if (last7) toggleID(last7);
  });

  // Initial Run
  applyStyles();
})();