UserJS to block Facebook application posts
Wednesday, January 27, 2010 1:17:58 PM
Are you annoyed as I am by Facebook applications (eg, FarmVille, Mafia Wars, Bejeweled, etc)? Do you hate sifting through the clutter of Facebook application posts just to find your friends' posts? Well, I've been experimenting with a script to hide most FB application posts, and a few select image gallery posts (eg, from FarmVille, etc.)
Notes:
To view/download, click here:
As you can probably see, this script currently uses a 4-second timer to periodically check for newer (AJAX) posts. Once I determine the proper event-handling hook in Facebook, I'll remove this timer in a future release.
Enjoy.
Notes:
- If you do subscribe to a few Facebook applications, and do use them periodically, then this script is NOT for you.
- This script does not replace the default [Hide Application] and [Block Application] functionality on Facebook.
To view/download, click here:
// ==UserScript==
// @name Hide specific application posts on Facebook
// @author Lee Harvey
// @namespace http://my.opera.com/Lee_Harvey/
// @version 1.0
// @description Hides specific application stories, posts, and
// galleries on Facebook -- for example, FarmVille Photos, and
// Mafia Wars objects.
// ==/UserScript==
/*
* This script is granted to the Public Domain.
*/
if (document.domain.match(/^(www\.)?facebook\.com$/) ||
document.domain.match(/\.fbcdn\.net$/)) {
var tmrHideFBCrap = null;
function hideFBCrap() {
var a = document.getElementsByTagName("A");
for (var i=0,h,p,e; e = a[i]; i++) {
h = e.getAttribute("href");
if (!h || (!h.match(/^\/apps\/application\.php\?id\=/) &&
!e.innerHTML.match(/^FarmVille/i) &&
!e.innerHTML.match(/^Bejeweled/i) &&
!e.innerHTML.match(/^Mafia Wars/i))) continue;
p = e.parentElement;
while (p) {
if (p.id && p.id.match(/^div_story_/) &&
p.className && p.className.match(/UIStory/) &&
p.tagName.match(/^DIV$/i)) {
p.style.display = "none";
break;
}
p = p.parentElement;
}
}
tmrHideFBCrap = window.setTimeout(hideFBCrap, 4000);
}
function docLoad(e) {
hideFBCrap();
tmrHideFBCrap = window.setTimeout(hideFBCrap, 4000);
}
function docUnload(e) {
if (tmrHideFBCrap) window.clearTimeout(tmrHideFBCrap);
tmrHideFBCrap = null;
}
document.addEventListener("load", docLoad, 0);
document.addEventListener("unload", docUnload, 0);
}
As you can probably see, this script currently uses a 4-second timer to periodically check for newer (AJAX) posts. Once I determine the proper event-handling hook in Facebook, I'll remove this timer in a future release.
Enjoy.

metude # Wednesday, January 27, 2010 4:51:52 PM
William Perezwilliamgelion # Friday, January 7, 2011 9:21:40 AM