Substack User Block

Hide spammers/trolls

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Substack User Block
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Hide spammers/trolls
// @author       Kronzky
// @match        *://*.substack.com/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==


let blockedNames = ["ForHimItWas", "e.pierce", "Boris Petrov", "Iconoclast"]; // Names to block (case-insensitive)
let minLikes = 2; // Show post anyway, if likes are above this minimum


let commentCount = 0
function hideStuff() {
    var comments = document.getElementsByTagName('table');
    if (comments.length==commentCount) {return};
    commentCount = comments.length;
    for (var comment of comments) {
        if (((comment.className.indexOf("comment-content"))!=-1) && ((comment.className.indexOf("CHECKED"))==-1)) {
            comment.className += " CHECKED";
            let commenterMeta = comment.getElementsByClassName('commenter-name')[0];
            if (commenterMeta.getElementsByTagName('a').length!=0) {
                let commenterName = commenterMeta.getElementsByTagName('a')[0].innerHTML;
                for (var blocked of blockedNames) {
                    if (blocked.toUpperCase() === commenterName.toUpperCase()) {
                        let commentBody = comment.getElementsByClassName('comment-body')[0];
                        let commentActions = comment.getElementsByClassName('comment-actions')[0];
                        if (commentActions.innerHTML.indexOf("Unhide")==-1) {
                            let likelink = commentActions.getElementsByTagName('a')[0].innerHTML;
                            let likes = Number(likelink.substr(likelink.lastIndexOf('>')+2));
                            if (likes<=minLikes) {
                                commentBody.style = "display:none";
                                commentActions.innerHTML += "<span><a href='#' onclick='unhide(this);return false'>Unhide</a></span>";
                            };
                        };
                        break;
                    };
                };
            };
        };
    };
};

window.unhide = function (elem) {
    elem.style = "display:none";
    elem.parentElement.parentElement.parentElement.getElementsByClassName('comment-body')[0].style = "display:block";
};

(function() {
    'use strict';
    hideStuff();
    window.addEventListener("scroll", hideStuff, false);
})();