Skip to content

Instantly share code, notes, and snippets.

@julianh2o
Created April 1, 2016 23:13
Show Gist options
  • Save julianh2o/1a3be7f1dc981982b0428645048c8093 to your computer and use it in GitHub Desktop.
Save julianh2o/1a3be7f1dc981982b0428645048c8093 to your computer and use it in GitHub Desktop.

Revisions

  1. julianh2o created this gist Apr 1, 2016.
    25 changes: 25 additions & 0 deletions spamfilter.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    // ==UserScript==
    // @name Reddit Robin Spam Filter
    // @namespace http://julianhartline.com/
    // @version 0.13
    // @description Adds mute functionality and spam filter
    // @author Julian Hartline (julianh2o)
    // @match https://www.reddit.com/robin
    // @grant none
    // ==/UserScript==

    var storageKey = "RedditRobinMutedUsers";
    var savedMutes = localStorage.getItem(storageKey) || '';
    $("#robinDesktopNotifier").after($("<input id='mutedUsers' placeholder='Muted usernames, separated by comma'>").val(savedMutes).change(function() {
    localStorage.setItem(storageKey,$(this).val());
    }));
    $("#robinChatMessageList").on("DOMNodeInserted",function(e) {
    if ($(e.target).is(".robin-message")) {
    var mutedUsers = $("#mutedUsers").val().replace(/ /g,"").split(",");
    var uname = $(e.target).find(".robin--username").text();
    if ($.inArray(uname,mutedUsers) !== -1) {
    console.log("Spam Filtered Message: ",$(e.target).text());
    $(e.target).hide();
    }
    }
    });