Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save NorbiPeti/778846df82ad4321648bf38fdc504c68 to your computer and use it in GitHub Desktop.

Select an option

Save NorbiPeti/778846df82ad4321648bf38fdc504c68 to your computer and use it in GitHub Desktop.
Channel usage: Type #channelname to switch channels. Type any message WITHOUT # characters to type in that channel. Type #all to switch back to global chat.
// ==UserScript==
// @name Robin channel manager and spam filter
// @namespace http://gist.github.com/NorbiPeti
// @version 0.1
// @description Filter spa,
// @author NorbiPeti, originally from nschubach
// @match https://www.reddit.com/robin/
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
var channelname="";
$(document).on('DOMNodeInserted', function(e) {
var re = null;
if(window.channelname)
re = new RegExp("(?:\s)*"+window.channelname+"+");
$('.robin-message--message', e.currentTarget).each(function() {
if (/[\u0080-\uFFFF]|(?:\[Robin Autovoter)/.test($(this).text()) || (window.channelname && !re.test($(this).text()))) {
$(this).parent().remove();
console.log("removed stuff");
}
});
});
$('#robinSendMessage').submit(function(ev) {
var re = new RegExp("#.+");
var input=$('input[name=message]');
if(re.test(input.val()))
window.channelname=input.val();
else if(window.channelname)
input.val(input.val()+" "+window.channelname);
if(window.channelname=="#all")
window.channelname="";
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment