Forked from nschubach/gist:27fcf78f1ecbf914310450a98937ba02
Last active
April 1, 2016 23:20
-
-
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.
This file contains hidden or 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 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