Skip to content

Instantly share code, notes, and snippets.

@jartur
Created August 29, 2009 11:02
Show Gist options
  • Save jartur/177459 to your computer and use it in GitHub Desktop.
Save jartur/177459 to your computer and use it in GitHub Desktop.
// Tested with Opera only!
//
// ==UserScript==
// @name reddit sfw
// @description Removes reddits from /r/nsfw & with [NSFW] tag in title
// @include http://www.reddit.com/*
// ==/UserScript==
var items = document.getElementsByClassName("thing");
for (i=0; i < items.length; i++)
{
if(items[i].tagName.match(/div/i))
{
var remove = false;
// Check based on url
var els = items[i].getElementsByClassName("comments");
if(els.length > 0)
{
if(els[0].href && els[0].href.match(/nsfw/))
{
remove = true;
}
}
// Check based on title
els = items[i].getElementsByClassName("title");
if(els.length > 0)
{
if(els[0].innerText && els[0].innerText.match(/nsfw/i))
{
remove = true;
}
}
// Hide it
if(remove)
{
items[i].style.display = "none";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment