/lmg/ Recap Script Modified For /aids/

Bookmarklet

javascript:(() => { const boardsEnabled = ["g", "vg"]; const threadsEnabled = ["/lmg/", "/aids/"]; const recapText = [ "Recent Highlights from the Previous Thread", "Ghetto Recap", ]; const isArchive = location.host === "desuarchive.org"; const opSelector = isArchive ? ".post_is_op" : ".post.op"; const postSelector = isArchive ? ".post_wrapper" : ".postMessage"; const previousLinkSelector = isArchive ? '.backlink[href*="thread"]' : 'blockquote a[href*="thread"]'; const quoteSelector = isArchive ? "span.greentext" : "span.quote"; const backlinkClass = isArchive ? "backlink" : "quotelink"; const board = location.href.match(/\/(\w+)\/thread\//)?.[1]; const isThread = threadsEnabled.some( (v) => document.querySelector(opSelector)?.textContent.match(v) !== null ); if (boardsEnabled.indexOf(board) !== -1 && isThread) { const recapPosts = [...document.querySelectorAll(postSelector)].filter( (v) => recapText.some((text) => v.textContent.toLowerCase().includes(text.toLowerCase()) ) ); for (const post of recapPosts) { const previousThreadUrl = document.querySelector(previousLinkSelector).href; const threadId = previousThreadUrl.match(/thread\/(\d{9})/)[1]; let postHTML = post.innerHTML; const quoteIds = postHTML.matchAll(/(?<!&gt;)&gt;(\d{9})/g); for (const [, id] of quoteIds) { const re = new RegExp(`(?<!&gt;)&gt;${id}`, "g"); const backlink = `<a href="/${board}/thread/${threadId}#p${id}" class="${backlinkClass}" data-function="highlight" data-backlink="true" data-board="${board}" data-post="${id}">&gt;&gt;${id}</a>`; postHTML = postHTML.replaceAll(re, backlink); } post.innerHTML = postHTML; } }})();

User Script

// ==UserScript==
// @name     Linkify 4chan Recap
// @version  1
// @include  https://boards.4chan.org/*
// @include  https://desuarchive.org/*
// @grant    none
// ==/UserScript==

(() => {
  const boardsEnabled = ["g", "vg"];
  const threadsEnabled = ["/lmg/", "/aids/"];
  const recapText = [
    "Recent Highlights from the Previous Thread",
    "Ghetto Recap",
  ];

  const isArchive = location.host === "desuarchive.org";

  const opSelector = isArchive ? ".post_is_op" : ".post.op";
  const postSelector = isArchive ? ".post_wrapper" : ".postMessage";
  const previousLinkSelector = isArchive
    ? '.backlink[href*="thread"]'
    : 'blockquote a[href*="thread"]';
  const quoteSelector = isArchive ? "span.greentext" : "span.quote";
  const backlinkClass = isArchive ? "backlink" : "quotelink";

  const board = location.href.match(/\/(\w+)\/thread\//)?.[1];
  const isThread = threadsEnabled.some(
    (v) => document.querySelector(opSelector)?.textContent.match(v) !== null
  );

  if (boardsEnabled.indexOf(board) !== -1 && isThread) {
    const recapPosts = [...document.querySelectorAll(postSelector)].filter(
      (v) =>
        recapText.some((text) =>
          v.textContent.toLowerCase().includes(text.toLowerCase())
        )
    );

    for (const post of recapPosts) {
      const previousThreadUrl =
        document.querySelector(previousLinkSelector).href;
      const threadId = previousThreadUrl.match(/thread\/(\d{9})/)[1];

      let postHTML = post.innerHTML;

      const quoteIds = postHTML.matchAll(/(?<!&gt;)&gt;(\d{9})/g);
      for (const [, id] of quoteIds) {
        const re = new RegExp(`(?<!&gt;)&gt;${id}`, "g");
        const backlink = `<a
          href="/${board}/thread/${threadId}#p${id}"
          class="${backlinkClass}"
          data-function="highlight"
          data-backlink="true"
          data-board="${board}"
          data-post="${id}">&gt;&gt;${id}</a>`;
        postHTML = postHTML.replaceAll(re, backlink);
      }

      post.innerHTML = postHTML;
    }
  }
})();

F.A.Q.

Why?

Since Friday September 20th, posts with more than 9 replies are rejected as spam.
Links have been replaced with greentext in the recap to avoid mass-replying while still providing sources. Those who find the recaps useful can use this script to restore link functionality.

4chan-x? Post Previews? (You)s?

GreaseMonkey: Everything should just work.
TamperMonkey: Go to the settings of the user script, and set it to Run at: document-body.

None of this is my work, all credit goes to Recap Anon from /lmg/

Edit Report
Pub: 27 Sep 2024 10:34 UTC
Edit: 27 Sep 2024 22:19 UTC
Views: 1316