Remove annoying users from StackOverflow

Masks out the comments and the names of users you don't like on StackOverflow

Versione datata 17/06/2024. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @namespace https://trajano.net
// @name     Remove annoying users from StackOverflow
// @description Masks out the comments and the names of users you don't like on StackOverflow
// @version  1
// @include  https://stackoverflow.com/*
// @grant    none
// @license EPL-2.0
// ==/UserScript==
(function() {
    'use strict';

    const ids = [-1, 1507691, 216691, 3001761, 4216641];
    const selector = ids.map(( id ) => `[data-comment-owner-id="${id}"]`);
    const styles = `
        ${selector.map( s => `${s} .comment-copy > *`)},
				${selector.map( s => `${s} .comment-date > *`)} {
            color: transparent;
            background: rgba(0, 0, 0, 0.15);
        }
        ${selector.map( s => `${s} div a.comment-user`)} {
            display: none;
        }
    `;

    document.head.appendChild(
        document.createElement("style")
    ).innerHTML = styles;

    function maskComments () {
        document.querySelectorAll(selector.join(',')).forEach(createMask);
    }

    function createMask ( element ) {
        const commentCopy = element.querySelector(".comment-copy");
        for ( const child of commentCopy.childNodes ) {
            if ( child.nodeName === "#text" && child.nodeValue !== " " ) {
                const fragment = document.createDocumentFragment();
                for ( const token of child.nodeValue.split(" ") ) {
                    const span = document.createElement("span");
                    span.textContent = token;
                    fragment.append(span, " ");
                }
                commentCopy.replaceChild( fragment, child );
            }
        }
    }

    maskComments();

})();