Changeset 168

Show
Ignore:
Timestamp:
11/18/07 21:54:21 (14 months ago)
Author:
chris
Message:

Added the ability to choose what to block or not
Added a count of blocked news feeds to the heading
Added the ability to block app invite requests from the sidebar
Added the ability to choose to remove or keep the requests sidebar if all items are hidden

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • facebook-app-spam/trunk/facebookappspamremover.user.js

    r167 r168  
    11// Facebook App Spam Remover 
    2 // Version 1.03-SVN 
     2// Version 1.04-SVN 
    33 
    44// This Greasemonkey script removes the application spam which has 
    55// recently started to appear in the news feed on facebook. 
     6 
     7// Hide spam from the news feed? 
     8hide_news_feed_spam = true; 
     9 
     10// If any news feed entries have been hidden, setting this to true will 
     11// show a count of the number of hidden feeds in the news feed heading. 
     12show_hidden_news_feed_entries_count = true; 
     13 
     14// Hide application notifications from the sidebar? 
     15hide_side_bar_spam = true; 
     16 
     17// If application notifications have been hidden, and there are no other 
     18// requests, setting this to true will show how many have been hidden. 
     19// Otherwise it will hide the entire requests section of the sidebar. 
     20keep_requests_when_all_hidden = false; 
    621 
    722// Copyright (c) 2007, Chris Stretton 
     
    4964 
    5065divs = document.getElementsByTagName('div'); 
    51 spampattern = new RegExp("(^|\\s)(social_ad|ad_capsule|app_story)(\\s|$)"); 
    52 bumperpattern = new RegExp("(^|\\s)bumper(\\s|$)"); 
    53 classpattern = new RegExp("(^|\\s)(one_liner|one_liner_cluster)(\\s|$)"); 
     66 
     67// define regexps 
     68spam = new RegExp("(^|\\s)(social_ad|ad_capsule|app_story)(\\s|$)"); 
     69bumper = new RegExp("(^|\\s)bumper(\\s|$)"); 
     70oneliners = new RegExp("(^|\\s)(one_liner|one_liner_cluster)(\\s|$)"); 
     71requests = new RegExp("(^|\\s)requests(\\s|$)"); 
     72sidespam = new RegExp("(^|\\s)app_\\d+_sidebar(\\s|$)"); 
     73 
     74hiddenentries = 0; 
    5475for (i = 0; divs && i < divs.length; i ++) { 
    55         if (spampattern.test(divs[i].className)) { 
    56                 divs[i].style.display = "none"; 
    57                 if (bumperpattern.test(divs[i].previousSibling.lastChild.className)) { 
    58                         divs[i].previousSibling.lastChild.style.display = "none"; 
     76        if (hide_news_feed_spam) { 
     77                if (spam.test(divs[i].className)) { 
     78                        divs[i].style.display = "none"; 
     79                        hiddenentries ++; 
     80                        if (bumper.test(divs[i].previousSibling.lastChild.className) && oneliners.test(divs[i].nextSibling.className)) { 
     81                                divs[i].previousSibling.lastChild.style.display = "none"; 
     82                                divs[i].nextSibling.style.padding = 0; 
     83                                divs[i].nextSibling.className="clearfix"; 
     84                        } 
     85                        if (show_hidden_news_feed_entries_count) { 
     86                                divs[i].parentNode.firstChild.firstChild.innerHTML = "News Feed (" + hiddenentries + " hidden)"; 
     87                        } 
    5988                } 
    60                 if (classpattern.test(divs[i].nextSibling.className)) { 
    61                         divs[i].nextSibling.style.padding = 0; 
    62                         divs[i].nextSibling.className="clearfix"; 
     89        } 
     90        if (hide_side_bar_spam) { 
     91                if (requests.test(divs[i].className)) { 
     92                        spans = divs[i].lastChild.childNodes; 
     93                        hidden = 0; 
     94                        keeprequests = keep_requests_when_all_hidden; 
     95                        for (s = 0; spans && s < spans.length; s ++) { 
     96                                if (!sidespam.test(spans[s].id)) { 
     97                                        keeprequests = true; 
     98                                } else { 
     99                                        spans[s].style.display = "none"; 
     100                                        hidden++; 
     101                                } 
     102                        } 
     103                        if (hidden > 0 && keeprequests) { 
     104                                if (hidden == 1) { 
     105                                        plural = "request"; 
     106                                } else { 
     107                                        plural = "requests"; 
     108                                } 
     109                                newspan = document.createElement('span'); 
     110                                newspan.innerHTML = '<a class="notifications" href="/reqs.php"><strong>' + hidden + '</strong> Hidden ' + plural + '</a>'; 
     111                                divs[i].lastChild.appendChild(newspan); 
     112                        } else if (!keeprequests) { 
     113                                divs[i].style.display = "none"; 
     114                        } 
    63115                } 
    64116        }