// ==UserScript==
// @name        8chan Style Script
// @namespace   8chanSS
// @match       *://8chan.moe/*/catalog.html
// @match       *://8chan.moe/*/res/*.html
// @match       *://8chan.se/*/catalog.html
// @match       *://8chan.se/*/res/*.html
// @grant       none
// @version     1.0
// @author      Anon
// @run-at      document-end
// @description Script to style 8chan
// ==/UserScript==

// Header Catalog Links
document.getElementById('navBoardsSpan').addEventListener('click', function () {
    var boardLinks = document.querySelectorAll('#navBoardsSpan a');
    var appendString = '\/catalog.html';

    boardLinks.forEach(function (link) {
        link.href += appendString;
    });
});

// Keyboard Shortcuts
// QR (CTRL+Q)
function toggleDiv(event) {
// Check if Ctrl + Q is pressed
    if (event.ctrlKey && (event.key === 'q' || event.key === 'Q')) {
        const hiddenDiv = document.getElementById('quick-reply');
        // Toggle QR
        if (hiddenDiv.style.display === 'none' || hiddenDiv.style.display === '') {
            hiddenDiv.style.display = 'block'; // Show the div
        }
        else {
            hiddenDiv.style.display = 'none'; // Hide the div
        }
    }
}

// Add an event listener for keydown events
document.addEventListener('keydown', toggleDiv);

// Custom CSS injection
function addCustomCSS(css) {
    if (!css) return;
    const style = document.createElement('style');
    style.type = 'text/css';
    style.appendChild(document.createTextNode(css));
    document.head.appendChild(style);
}
// Get the current URL path
const currentPath = window.location.pathname.toLowerCase();
const currentHost = window.location.hostname.toLowerCase();

// Apply CSS based on URL pattern
// Thread page CSS
if (/\/res\/[^/]+\.html$/.test(currentPath)) {
    const css = `
/* Quick Reply */
#quick-reply {
    display: block;
    padding: 0 !important;
    top: auto !important;
    bottom: 0;
    left: auto !important;
    position: fixed;
    right: 0 !important;
}
#qrbody {
    resize: vertical;
    max-height: 50vh;
}
.floatingMenu {
    padding: 0 !important;
}
#qrFilesBody {
    max-width: 300px;
}
/* Banner */
#bannerImage {
    width: 305px;
    right: 0;
    position: fixed;
    top: 26px;
}
.boardHeader {
    position: fixed;
    right: 40px;
    top: 100px;
}
.innerUtility.top {
    margin-top: 2em;
    background-color: transparent !important;
    color: var(--link-color) !important;
}
.innerUtility.top a {
    color: var(--link-color) !important;
}
.innerPost {
    margin-left: 40px;
    display: block;
}
/* Hover Posts */
img[style*="position: fixed"] {
    left: auto;
    z-index: 199;
}
.quoteTooltip {
    z-index: 110;
}
/* (You) Replies */
.innerPost:has(.youName) {
    border-left: solid #68b723 5px;
}
.innerPost:has(.quoteLink.you) {
    border-left: solid #dd003e 5px;
}
/* Filename */
.originalNameLink {
  display: inline;
  overflow-wrap: anywhere;
  white-space: normal;
}
`;
    addCustomCSS(css);
}

if (/^8chan\.(se|moe)$/.test(currentHost)) {
    // General CSS for all pages
    const css = `
/* Margins */
body {
    margin: 0 !important;
}
#mainPanel {
    margin-left: 10px;
    margin-right: 305px;
    margin-top: 0;
    margin-bottom: 0;
}
/* Cleanup */
#footer,
#actionsForm,
#navTopBoardsSpan,
.coloredIcon.linkOverboard,
.coloredIcon.linkSfwOver,
.coloredIcon.multiboardButton,
#navLinkSpan>span:nth-child(9),
#navLinkSpan>span:nth-child(11),
#navLinkSpan>span:nth-child(13) {
    display: none;
}
/* Header */
#dynamicHeaderThread {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
/* Thread Watcher */
#watchedMenu .floatingContainer {
    min-width: 330px;
}
.quoteTooltip .innerPost {
    overflow: hidden;
}
`;
    addCustomCSS(css);
}

// Catalog page CSS
if (/\/catalog\.html$/.test(currentPath)) {
    const css = `
#dynamicAnnouncement {
    display: none;
}
#postingForm {
  margin: 2em auto;
}
`;
    addCustomCSS(css);
}
Edit

Pub: 18 Apr 2025 07:16 UTC

Views: 92