Created
April 1, 2016 23:13
-
-
Save julianh2o/1a3be7f1dc981982b0428645048c8093 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment