// ==UserScript== // @name NSFW Board Remover & 4chan AMOLED Black // @namespace https://github.com/deactivated0 // @version 4.2 // @description AMOLED dark mode with full black footer navigation, black buttons, and automated NSFW redirection. // @author deactivated0 // @match https://*.4chan.org/* // @match https://*.4channel.org/* // @run-at document-start // @grant none // @updateURL https://raw.githubusercontent.com/deactivated0/4chan-amoled-black/main/4chan.user.js // @downloadURL https://raw.githubusercontent.com/deactivated0/4chan-amoled-black/main/4chan.user.js // ==/UserScript== (function () { 'use strict'; const BLOCKED_BOARDS = new Set([ "b", "r9k", "pol", "bant", "soc", "s4s", "s", "hc", "hm", "h", "e", "u", "d", "y", "t", "hr", "gif", "aco" ]); function currentBoard() { const m = location.pathname.match(/^\/([^/]+)/); return m ? m[1] : ""; } // 1. Immediate Redirection Check if (BLOCKED_BOARDS.has(currentBoard())) { window.location.replace("https://www.4chan.org/"); return; } // 2. Optimized Consolidated AMOLED & Black Footer CSS const themeCSS = ` :root { --bg: #000000; --bg2: #050505; --bg3: #0a0a0a; --text: #ffffff; --text2: #cfcfcf; --border: #202020; --quote: #789922; --highlight: #101010; } html, body, #doc, #hd, #bd, #ft { background: var(--bg) !important; background-color: var(--bg) !important; color: var(--text) !important; color-scheme: dark !important; } * { scrollbar-color: #444 #000; border-color: var(--border) !important; } ::-webkit-scrollbar { width: 12px; height: 12px; } ::-webkit-scrollbar-track { background: #000; } ::-webkit-scrollbar-thumb { background: #444; border-radius: 8px; } body, div, section, article, main, aside, header, footer, nav, form, fieldset, table, tr, td, th { color: var(--text) !important; } a, a:link, .boardlink, .boardlink:link, .boardlink:visited, .quotelink, a.quotelink, a[href^="#p"], .subject, .name { color: #ffffff !important; } a:visited { color: #d0d0d0 !important; } a:hover, .boardlink:hover, .quotelink:hover, a.quotelink:hover { color: #ffffff !important; text-decoration: underline !important; } /* Footer Container and List Item Background Fix */ #ft, #ft ul, #ft ul li, #ft li, #ft .fill { background: #000000 !important; background-color: #000000 !important; border-color: var(--border) !important; box-shadow: none !important; } /* Footer Link Buttons */ #ft ul li a { background: #000000 !important; color: #ffffff !important; border: 1px solid var(--border) !important; padding: 4px 10px !important; border-radius: 4px !important; text-decoration: none !important; display: inline-block !important; transition: background 0.2s, border-color 0.2s !important; } #ft ul li a:hover { background: #111111 !important; border-color: #444444 !important; text-decoration: none !important; } input, textarea, select, button { background: var(--bg3) !important; color: var(--text) !important; border: 1px solid var(--border) !important; box-shadow: none !important; } input::placeholder, textarea::placeholder { color: #888 !important; } hr { border-color: var(--border) !important; } img, video, canvas, svg, #logo-fp, #logo-fp a, #logo-fp img { background: transparent !important; } #announce, #boards, #popular-threads, #site-stats, .box-outer, .box-inner, .boxbar, .boxcontent, .column, .stat-cell, .c-thread, .c-board, .c-teaser { background: var(--bg) !important; color: var(--text) !important; border-color: var(--border) !important; box-shadow: none !important; } .box-outer, .box-inner, .c-thread { border: 1px solid var(--border) !important; } .boxbar { background: var(--bg2) !important; border-bottom: 1px solid var(--border) !important; } .boxbar h2, .boxbar h3, #filter-btn, #opts-btn, .c-board, .c-teaser, .stat-cell, #copyright, #ft, #ft a { color: #fff !important; } .c-thread { padding: 6px !important; } .post, .reply, .postContainer, .thread, .postInfo, .postMessage, .summary, .catalog-thread, .catalog-container, .box, .extButton, .replyhl, .menu, .dialog, .UIPanel, .backlink, .replyPreview, .modal, .popup, .dropdown, .postbtn, .fileText, .fileInfo, .board, .boardHeader, .boardList, .boardSection, .threadList, .catalogCell { background: var(--bg2) !important; color: var(--text) !important; border-color: var(--border) !important; box-shadow: none !important; } .highlight, .reply.highlight, .reply:target { background: var(--highlight) !important; } .quote { color: var(--quote) !important; font-weight: 500 !important; } .quotelink, a.quotelink, a[href^="#p"], .subject { font-weight: 700 !important; } .deadlink { color: #666666 !important; } .posteruid, .capcode { background: #111 !important; color: #fff !important; border-radius: 3px !important; padding: 0 3px !important; } .linkname, .intro, .postNum, .posttime, .dateTime, .posterhead { color: var(--text2) !important; } .sage, .sage a { color: #8a8a8a !important; } .spoiler { background: #222 !important; color: #222 !important; } .spoiler:hover { color: #fff !important; } `; function injectStyle(css) { const style = document.createElement('style'); style.textContent = css; (document.head || document.documentElement).appendChild(style); } injectStyle(themeCSS); // 3. Optimized DOM Cleaning Functions function cleanDOM() { document.querySelectorAll("a[href]").forEach(a => { try { const url = new URL(a.href, location.origin); const board = url.pathname.split("/").filter(Boolean)[0]; if (BLOCKED_BOARDS.has(board)) { const parent = a.parentNode; if (parent && parent.classList.contains("boardList")) { let next = a.nextSibling; if (next && next.nodeType === Node.TEXT_NODE && next.textContent.includes("/")) { next.textContent = next.textContent.replace(/^\s*\/|^\s*\]/, ""); } } a.remove(); } } catch {} }); document.querySelectorAll("option").forEach(opt => { const value = opt.value.replace(/^\/|\/$/g, ""); if (BLOCKED_BOARDS.has(value)) opt.remove(); }); if (location.hostname.startsWith("www.")) { document.querySelectorAll(".column").forEach(col => { const headings = col.querySelectorAll("h3"); headings.forEach(h => { const title = h.textContent.trim(); if (title === "Misc." || title === "Adult") col.remove(); }); }); } document.querySelectorAll(".c-thread").forEach(thread => { const a = thread.querySelector("a[href]"); if (!a) return; try { const url = new URL(a.href, location.origin); const board = url.pathname.split("/").filter(Boolean)[0]; if (BLOCKED_BOARDS.has(board)) thread.remove(); } catch {} }); } // 4. Performance-Optimized Execution Loops if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", cleanDOM); } else { cleanDOM(); } let isScheduled = false; const observer = new MutationObserver(() => { if (!isScheduled) { isScheduled = true; requestAnimationFrame(() => { cleanDOM(); isScheduled = false; }); } }); observer.observe(document.documentElement, { childList: true, subtree: true }); // Navigation Interception Clicks document.addEventListener("click", e => { const a = e.target.closest("a"); if (!a) return; try { const url = new URL(a.href, location.origin); const board = url.pathname.split("/").filter(Boolean)[0]; if (BLOCKED_BOARDS.has(board)) { e.preventDefault(); e.stopImmediatePropagation(); window.location.replace("https://www.4chan.org/"); } } catch {} }, true); })();