Make S**tposts Great Again!

Take that, you s**tposters!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Make S**tposts Great Again!
// @namespace    LordBusiness.MSG
// @version      1.5
// @description  Take that, you s**tposters!
// @author       Me, you, and everybody else.
// @match        https://www.torn.com/forums.php*
// @match        https://www.torn.com/pc.php*
// @match        https://www.torn.com/laptop.php*
// @run-at       document-start
// @require      https://cdn.jsdelivr.net/npm/[email protected]/randomColor.min.js
// @resource     font https://cdn.jsdelivr.net/gh/LBusiness/res@master/font.ttf
// @grant        GM_addStyle
// @grant        GM_getResourceURL
// ==/UserScript==



// Add the IDs of your favorite shitposters here:
const shitPosters = [1028023, 1002535, 2052465]

// Set this to true if you'd like to see the effect on all users.
const allUsersAreShit = false

const userSelectors = shitPosters.map(user => `#forums-page-wrap > .forums-thread-wrap .thread-list [data-author${allUsersAreShit ? '' : '="'+ user + '"'}] .post.unreset`).join(),
      font = GM_getResourceURL('font');
GM_addStyle(`
    @font-face {
	    font-family: 'Comic-Sans';
   		src: url(data:font/tff;base64,${ font.substring(24) });
    }

    .verified-shitpost,
    ${userSelectors} {
        font-family: 'Comic-Sans';
        font-size: 2.5em;
        letter-spacing: 2px;
        line-height: 30px !important;
    }
`);

window.addEventListener('DOMContentLoaded', event => {
    'use strict';

    const checkQuote = quoteNode => {
        if(!quoteNode) return;
        const quoteAuthor = Number(quoteNode.querySelector(':scope > .author-quote a').href.replace(/[^0-9]/g, ''));

        if(allUsersAreShit || shitPosters.includes(quoteAuthor)) {
            quoteNode.querySelector(':scope > .quote-post').classList.add('verified-shitpost');
            quoteNode.querySelector(':scope > .quote-post').style.color = randomColor({ luminosity: 'dark' });
        }
        checkQuote(quoteNode.querySelector(':scope > .post-quote'));
    },

          checkThreadForShitPosts = thread => {
        const posts = thread.querySelectorAll('[data-author]');
        for(const post of posts) {
            const postAuthor = Number(post.getAttribute('data-author'))
            if(allUsersAreShit || shitPosters.includes(postAuthor)) {
                post.querySelector('.post.unreset').style.color = randomColor({ luminosity: 'dark' });
            }

            checkQuote(post.querySelector('.quote.unreset > .post-quote'));
        }
    },
          forumWrapObserver = new MutationObserver(mutationList => {
              for(const MutationRecord of mutationList) {
                  for(const addedNode of MutationRecord.addedNodes) {
                if(addedNode.classList && addedNode.classList.contains('forums-thread-wrap')) {
                    checkThreadForShitPosts(addedNode);
                    return;
                }
            }
        }
    });

    if(location.href.startsWith('https://www.torn.com/forums.php')) {
        forumWrapObserver.observe(document.getElementById('forums-page-wrap'), {childList: true })
    }
});