Nyuhnyash / HabrUnbiasedComments

// ==UserScript==
// @name         HabrUnbiasedComments
// @namespace    https://openuserjs.org/users/Nyuhnyash
// @version      1.2.2
// @description  Удаление рейтинга и тусклости комментариев на Хабре
// @author       Nyuhnyash
// @copyright    2022, Nyuhnyash (https://openuserjs.org/users/Nyuhnyash)
// @licence      Apache-2.0
// @match        https://habr.com/*/post/*
// @match        https://habr.com/*/blog/*
// @match        https://habr.com/*/news/*
// @run-at       document-end
// @icon         https://dr.habracdn.net/habr/oldassets/61828bec/images/favicon-32x32.png
// ==/UserScript==

// Old design
let collection = document.getElementsByClassName('comment__message'); // comment__message_downgrade
for (const comment of collection) {
    comment.className = "comment__message";
}

collection = document.getElementsByClassName("voting-wjt_comments");
for (const voter of collection) {
    voter.remove();
}


// New design
function cleanComments() {
    collection = document.getElementsByClassName('tm-comment__body-content_muted');
    for (const shadedComment of collection) {
        shadedComment.style.removeProperty("opacity");
    }
    console.log('clean');

    collection = document.getElementsByClassName("tm-votes-meter");
    for (const voter of collection) {
        voter.style.display = 'none';
    }
}

cleanComments();

const commentsWrapper = document.getElementsByClassName('tm-comments-wrapper')[0];
const observer = new MutationObserver(cleanComments);
observer.observe(commentsWrapper, {
    childList: true,
    subtree: true
});