Hide Disqus Comments

Hides Disqus comment sections on websites

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

You will need to install an extension such as Tampermonkey to install this 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!)

Advertisement:

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!)

Advertisement:

// ==UserScript==
// @name         Hide Disqus Comments
// @namespace    https://greasyfork.org/
// @version      1.0
// @description  Hides Disqus comment sections on websites
// @author       You
// @match        *://*/*
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const hideDisqus = () => {
        const selectors = [
            '#disqus_thread',
            'iframe[src*="disqus.com"]',
            'iframe[src*="disquscdn.com"]',
            'div[data-tracking-area="comments"]',
            '.comments',
            '.comment-section',
            '[id*="disqus"]'
        ];

        selectors.forEach(sel => {
            document.querySelectorAll(sel).forEach(el => {
                el.style.display = 'none';
            });
        });
    };

    // Run immediately
    hideDisqus();

    // Watch for dynamically loaded comments
    const observer = new MutationObserver(() => hideDisqus());
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

})();