A Temporary Banlist Solution for Steemit Abuse

in #abuse8 years ago

Hopefully you haven't noticed, but some users are being abused on Steemit. There's a Mute button, but it's not yet implemented in the front end (keep using it though, as I've heard it will be at some point). After hearing some pretty serious (and scary) stories, I ran into one user in the Slack channel who I tried to help with a script to hide all comments from specific users.

Using Tampermonkey, I created this script:

// ==UserScript==
// @name         Steemit Banscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Banscript for Steemit via JavaScript
// @author       https://steemit.com/@lukestokes
// @match        https://steemit.com/*
// @grant        ????
// ==/UserScript==
(function() {
    'use strict';

    // wait for the page to load
    window.addEventListener("load", wait_for_comments, false);

    // wait for the comments to show up.
    function wait_for_comments() {
        if (!document.getElementById("comments")) {
            console.log("Steemit BanScript: no comments yet...");
            setTimeout(function() {
                wait_for_comments();
            }, 500);
        } else {
            console.log("Steemit BanScript: We have comments!");
            setTimeout(function() {
                banscript();
            }, 500);
        }
    }

    function banscript() {

        // ADD YOUR BAN LIST HERE
        var banlist = ['earnest', 'xxxxxxxxxx'];

        var i, j;
        var comments = document.getElementsByClassName("hentry Comment root");
        for (i = 0; i < comments.length; i++) {
            for (j = 0; j < banlist.length; j++) {
                if (comments[i].id.indexOf("#@" + banlist[j] + "/") === 0) {
                    comments[i].style.display = "none";
                }
            }
        }
        var replies = document.getElementsByClassName("hentry Comment reply");
        for (i = 0; i < replies.length; i++) {
            for (j = 0; j < banlist.length; j++) {
                if (replies[i].id.indexOf("#@" + banlist[j] + "/") === 0) {
                    replies[i].style.display = "none";
                }
            }
        }

    }

})();

If you replace the entire script (including the original comments from Tampermonkey), this should work for you.

All you have to do is add users to your banlist array here:

        // ADD YOUR BAN LIST HERE
        var banlist = ['earnest', 'xxxxxxxxxx'];

Just add in new entries, like the so:

        // ADD YOUR BAN LIST HERE
        var banlist = ['earnest', 'jerk1', 'jerk2', 'jerk3'];

And save it.

banlist.png

With the script enabled, you should not longer see comments from usernames in your banlist array.

Warning

You should never run untrusted JavaScript, especially not on Steemit. You could easily get hacked that way, so please, please, please don't just run any old script someone tells you to run.

Hopefully you can understand what's going on above to feel comfortable running this script as it just loops through the comments and hides any which are authored by someone in the array you define. All replies to them will also be hidden.

Limitations:

  • This script doesn't hide entries on your Replies page. I had something working for that as well, but it got tricky when you click through from the top nav and I ended up just ditching it. If you really want that also, leave a comment and I can keep working on it.
  • This is a temporary solution. Ideally, the Steemit team will get the Mute functionality working soon.
  • Every time you want ban someone, you have to edit the script.

Please share this post with anyone you think may need it.

Sort:  

This is awesome, thank you.

Thanks @eeks! I hope it helps protect some people and this community.

My pleasure. Happy to contribute something useful to the community.

Very useful thank you for share!

You're welcome!

So if you ban someone you won't see their comments.Great!

Yes, you just have to edit the file to include their user name. After the page is done loading, the script runs and hides all their comments in that thread.

Quality content. Well stated and has utility.

Thanks Bill!

Coin Marketplace

STEEM 0.23
TRX 0.26
JST 0.040
BTC 97955.34
ETH 3472.91
USDT 1.00
SBD 3.29