post

Code

StumbleUpon Digg Reddit Technorati

Greasemonkey Reddit Filter

I've been learning a bit of JavaScript - and this is one of the things I've come up with, so far.

Reddit Filter is fairly simple; it allows you to filter out submissions from certain URLs using a regular expression. Want to give it a shot? Follow these brief instructions:

  • Install GreaseMonkey - this is a neat little Firefox addon, which allows you to customise the way a webpage is displayed, using JavaScript. There even appears to be a version that works in IE.
  • Restart Firefox, then click on this link. You'll get a GreaseMonkey popup, and from there you can install the script.
  • You'll need to put your own regular expression into the config section of the script, to match URLs on reddit - to do this, you need to right click on the GreaseMonkey icon on the right hand side of your Firefox status bar, select 'Manage Use Scripts', select 'Reddit Filter' and hit 'Edit'.
  • The regular expression should match URLs in the form 'subdomain.domain.com' - essentially the script uses this string for each Reddit submission and matches it against your regex.
  • If you're not already familiar with regular expressions, take a look at this guide. The two most important things you need to know is that | is the 'or' operator, and you'll have to escape any special characters you want to include as literals. Special characters include + * . { } [ ] \ / ?
  • Here are some examples of regexes you can use to filter certain submissions:

self\.reddit\.com - Self referencing posts

xkcd\.com|barackobama\.com - The lovely websites of xkcd and Barack Obama

.*\.co.uk - All .co.uk addresses

Anyway - if anyone wants to use this source code, or improve it, please feel free! As I mentioned, I am new to JavaScript - it works perfectly for me, but if anyone has issues with it I'll be happy to hear.

Enjoy.

Popularity: 3%

1 Star2 Stars3 Stars4 Stars5 Stars
No Ratings Yet
Loading ... Loading ...

  • Curious Java Update Incentive
  • The First Month
  • Please, Celebrities, Stop Exposing Yourselves …
  • Discussion

    No comments for “Greasemonkey Reddit Filter”

    Post a comment

    Categories