Reddit remove avatars

Remove the reddit avatars for easier reading.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Reddit remove avatars
// @name:de      Entferne Reddit Profilbilder
// @version      1.0
// @description  Remove the reddit avatars for easier reading.
// @description:de Entfernt alle Profilbilder aus den Kommentaren auf Reddit.
// @author       Drados
// @match        https://www.reddit.com/r/*
// @license      GPL-3.0 license
// @grant        GM_addStyle
// @run-at document-idle
// @namespace https://greasyfork.org/users/1559751
// ==/UserScript==


// this prevents usernames from being cut off
GM_addStyle ( `
.overflow-hidden {
    overflow: unset !important;
}
` );


function removeCommentAvatarDivs() {
  const e = document.querySelectorAll('div[slot="commentAvatar"]');
  e.forEach(div => div.remove());
}

// move usernamse to the left
function updateMargin() {
    const e = document.querySelectorAll('.author-name-meta');
    e.forEach(element => {
        element.style.marginLeft = '-1.5rem'; // changing this to -2 will look better but the collapsed comment button will overlap
    });
}

const observer = new MutationObserver((mutationsList) => {
    for (let mutation of mutationsList) {
        if (mutation.type === 'childList') {
            updateMargin();
            removeCommentAvatarDivs();
        }
    }
});

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