Forum Post: A short Javascript to ignore user articles and comments
Posted 13 years ago on Jan. 9, 2012, 4:30 a.m. EST by Thrasymaque
(-2138)
This content is user submitted and not an official statement
I got fed up with the postings and comments of certain users so I decided to write a short Javascript to ignore them. I run it with the GreaseMonkey extension for Firefox. If you're using another browser, you will need to find some way to run it after the page has finished loading.
After a page has loaded, all the postings and comments from the users in the ignore list will be hidden. The only "bug" at this time is that users that are loaded by Ajax after the main page load will not be ignored. This affects the bubbling page where only the first 30 or so postings will be filtered.
Freedom of speech is important, but the freedom to filter out what you don't want to read is also important.
Upcoming features
I will be adding the ability to filter out comments and posts containing certain keywords of your choosing. I will do this in a few days and post the additions here. (I'm tired of reading the comments of users who can't write without using profanity.)
Instructions
- Setup the script with GreaseMonkey on Firefox, or on another browser using the appropriate plugin.
- Make sure the script runs for all URLs that begin with http://occupywallst.org/forum/
- Open the script, and edit the list of usernames to ignore.
// ==UserScript==
// @name occupywallst ignorer
// @namespace occupywallst_ignorer
// @description Ignores user comments and postings on occupywallstr.org
// @include occupywallst.org/forum/*
// ==/UserScript==
var ignore_list = [
'someusername', 'anotherusername', 'yetanotherusername'
];
// *******************************************
// * Verifies if an object is in an array
// *
// * @param mixed obj
// * @return bool is in array
// *******************************************
Array.prototype.contains = function(obj)
{
var i = this.length;
while (i--)
{
if (this[i] === obj)
{
return true;
}
}
return false;
}
// *******************************************
// * Hides an element
// *
// * @param string class
// * @return void
// *******************************************
function hide(className)
{
var e = document.getElementsByClassName(className);
for (var i=0; i<e.length; i++)
{
var user = e[i].getElementsByClassName('user');
user = user[0].innerHTML;
if (ignore_list.contains(user))
{
e[i].style.display = 'none';
}
}
}
// *******************************************
// * Runs the script after the DOM is loaded
// *******************************************
window.addEventListener("load", function(e)
{
hide('article');
hide('recent-comment');
hide('comment');
}, false);
I was all bummed because I ue Opera, but then found out it runs "many" GreaseMonkey scripts without a plug-in ! See http://www.opera.com/docs/userjs/examples/#greasemonkey . I don't know when I'm going to be able to try it though; I have a lot of work coming at me Monday through the end of January. Nice to know it works in any case. I can probably help incorporate some tricks.
Another script I had made a while back. It can be installed like my broken link fixer I just posted.
[Removed]