Zero Hedge - Auto-expand Comments

Automatically expands the fun comments.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Zero Hedge - Auto-expand Comments
// @match       https://www.zerohedge.com/*
// @version     1.0
// @author      MedX
// @namespace   MedX-AA
// @license     MIT
// @icon        https://s2.googleusercontent.com/s2/favicons?domain=www.zerohedge.com
// @description Automatically expands the fun comments.
// ==/UserScript==

(function() {
    'use strict';

    function clickComments() {
        const buttons = document.getElementsByClassName("BlockComments_showBtn__Ds_Lu");
        if (buttons.length > 0) {
            for (const button of buttons) {
                button.click();
            }
            observer.disconnect(); // Stop observing once clicked.
        }
    }

    const observer = new MutationObserver(mutations => {
        clickComments();
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true,
    });

    // Initial check, in case the elements are already loaded.
    clickComments();
})();