There are 36 previous versions of this script.
Add Syntax Highlighting (this will take a few seconds, probably freezing your browser while it works)
// ==UserScript==
// @name Facebook | Remove Items From Highlight Bar
// @namespace http://userscripts.org/scripts/source/46681.user.js
// @description Remove items from Highlights sidebar
// @version 3.30
// @author Ron Troyer
// @authorWebsite http://www.ronaldtroyer.com/
// @include http*://*facebook.com/*
// ==/UserScript==
/****************************Get Settings****************************/
window.getSettings = function () {
if (GM_getValue('removeApplications') == undefined) {removeApplications = 'true'; GM_setValue('removeApplications', 'true');} else {removeApplications = GM_getValue('removeApplications');}
if (GM_getValue('removeGifts') == undefined) {removeGifts = 'true'; GM_setValue('removeGifts', 'true');} else {removeGifts = GM_getValue('removeGifts');}
if (GM_getValue('removeGroups') == undefined) {removeGroups = 'true'; GM_setValue('removeGroups', 'true');} else {removeGroups = GM_getValue('removeGroups');}
if (GM_getValue('removePages') == undefined) {removePages = 'true'; GM_setValue('removePages', 'true');} else {removePages = GM_getValue('removePages');}
if (GM_getValue('removeEvents') == undefined) {removeEvents = 'false'; GM_setValue('removeEvents', 'false');} else {removeEvents = GM_getValue('removeEvents');}
if (GM_getValue('removeLinks') == undefined) {removeLinks = 'false'; GM_setValue('removeLinks', 'false');} else {removeLinks = GM_getValue('removeLinks');}
if (GM_getValue('removeNotes') == undefined) {removeNotes = 'false'; GM_setValue('removeNotes', 'false');} else {removeNotes = GM_getValue('removeNotes');}
if (GM_getValue('removePhotos') == undefined) {removePhotos = 'false'; GM_setValue('removePhotos', 'false');} else {removePhotos = GM_getValue('removePhotos');}
if (GM_getValue('removePolls') == undefined) {removePolls = 'false'; GM_setValue('removePolls', 'false');} else {removePolls = GM_getValue('removePolls');}
if (GM_getValue('removeVideos') == undefined) {removeVideos = 'false'; GM_setValue('removeVideos', 'false');} else {removeVideos = GM_getValue('removeVideos');}
if (GM_getValue('removeRelationship') == undefined) {removeRelationship = 'false'; GM_setValue('removeRelationship', 'false');} else {removeRelationship = GM_getValue('removeRelationship');}
if (GM_getValue('removeBreakup') == undefined) {removeBreakup = 'false'; GM_setValue('removeBreakup', 'false');} else {removeBreakup = GM_getValue('removeBreakup');}
if (GM_getValue('removeCommentedOn') == undefined) {removeCommentedOn = 'true'; GM_setValue('removeCommentedOn', 'true');} else {removeCommentedOn = GM_getValue('removeCommentedOn');}
if (GM_getValue('removeLiked') == undefined) {removeLiked = 'true'; GM_setValue('removeLiked', 'true');} else {removeLiked = GM_getValue('removeLiked');}
if (GM_getValue('removeTagged') == undefined) {removeTagged = 'false'; GM_setValue('removeTagged', 'false');} else {removeTagged = GM_getValue('removeTagged');}
if (GM_getValue('removeNames') == undefined) {removeNames = ''; GM_setValue('removeNames', '');} else {removeNames = GM_getValue('removeNames');}
if (GM_getValue('removeLists') == undefined) {removeLists = ''; GM_setValue('removeLists', '');} else {removeLists = GM_getValue('removeLists');}
if (GM_getValue('cacheListNames') == undefined) {cacheListNames = ''; GM_setValue('cacheListNames', '');} else {cacheListNames = GM_getValue('cacheListNames');}
if (GM_getValue('toggleHighlights') == undefined) {toggleHighlights = 'inherit'; GM_setValue('toggleHighlights', 'inherit');} else {toggleHighlights = GM_getValue('toggleHighlights');}
}
window.getSettings();
window.getTime = function () {
currentTime = new Date();
myMinutes = ':' + currentTime.getMinutes();
if (myMinutes.length == 2) {
myMinutes = ':0' + myMinutes.substring(1,2);
}
todayVar = (currentTime.getMonth() + 1) + '/' + currentTime.getDate() + '/' + currentTime.getFullYear() + ' ' + currentTime.getHours() + myMinutes;
return(todayVar);
}
//THESE ARE NEEDED FOR THE REST OF THE SCRIPT TO RUN
window.destroyClass = function (removeItem) {remove = document.getElementsByClassName('UIHotStory');for (i=0; i<remove.length; i++) {if (remove[i].innerHTML.match(removeItem)) {remove[i].style.display = "none";}}}
window.destroyContent = function (compareItem,removeItem) {if (compareItem.innerHTML.match(removeItem)) {compareItem.parentNode.style.display = "none";} else {return(false);}}
window.restoreAll = function () {restore = document.getElementsByClassName('UIHotStory');for (i=0; i<restore.length; i++) {restore[i].style.display = "inherit";}}
window.removeClassFunc = function () {
//EDITS BASED ON CLASS
if (removeEvents == 'true') {
destroyClass('sx_icons_event');
}
if (removeGifts == 'true') {
destroyClass('sx_icons_gift');
}
if (removeGroups == 'true') {
destroyClass('sx_icons_group');
}
if (removeLinks == 'true') {
destroyClass('sx_icons_post');
}
if (removeNotes == 'true'){
destroyClass('sx_icons_mobile_note');
destroyClass('sx_icons_note');
}
if (removePages == 'true'){
destroyClass('sx_icons_fbpage');
}
if (removePhotos == 'true'){
destroyClass('sx_icons_photo');
}
if (removePolls == 'true'){
destroyClass('sx_icons_polls');
}
if (removeRelationship == 'true'){
destroyClass('sx_icons_relationship'); //got into a relationship
}
if (removeBreakup == 'true'){
destroyClass('sx_icons_relationship_remove'); //broke up
}
if (removeVideos == 'true'){
destroyClass('sx_icons_motion');
}
}
var nameArray = new Array();
var cacheArray = new Array();
window.getNames = function () {
//SEPARATE THE NAMES INTO AN ARRAY
nameArray = removeNames.split(",");
cacheArray = cacheListNames.split(",");
if (nameArray[0] == "") {
nameArray = cacheArray;
} else {
nameArray = nameArray.concat(cacheArray);
}
}
window.processLists = function () {
GM_setValue('cacheDate', window.getTime());
if (removeLists != "") {
getList(removeLists);
} else {
GM_setValue('cacheListNames', '');
}
}
/******************GET THE LISTS AND COMBINE ARRAYS**********************/
// GET THE LIST URL
function getList(lists) {
GM_xmlhttpRequest({
method: 'GET',
url: 'http://www.facebook.com/friends/ajax/superfriends.php?all_lists=true',
headers: {'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey','Accept': 'text/plain',},
onload: function(responseDetails) {
if (responseDetails.status == 200) {
var info = responseDetails.responseText;
listsArr = lists.split(",");
memberIDs = '';
for(i=0; i<listsArr.length; i++) {
listName = listsArr[i];
listIndex = info.indexOf(listName);
listIndex = info.indexOf('"members"', listIndex) + 11;
listIndexE = info.indexOf(']', listIndex);
memberIDs += ',' + info.substring(listIndex, listIndexE);
}
processIDs(memberIDs.substring(1,memberIDs.length));
}
}
});
}
function processIDs (list) {
GM_setValue('cacheListNames', '');
processingArr = list.split(',');
if (processingArr[0] != "") {
for (i=0; i<processingArr.length; i++) {
//GET DATA
greaseVar = 'greasedRHB' + processingArr[i];
if (GM_getValue(greaseVar) == undefined) {
myURL = "http://www.facebook.com/profile.php?id=" + processingArr[i];
GM_xmlhttpRequest({
method: 'GET',
url: myURL,
headers: {'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey','Accept': 'text/plain',},
onload: function(responseDetails) {
if (responseDetails.status == 200) {
var info = responseDetails.responseText;
listIndex = info.indexOf('<title>') + 7 + 11;
listIndexE = info.indexOf('</title>', listIndex);
name = info.substring(listIndex, listIndexE);
GM_setValue(greaseVar, name);
setCache(name,processingArr.length);
}
}
});
} else {
name = GM_getValue(greaseVar);
setCache(name,processingArr.length);
}
}
}
}
window.setCache = function (name,myLength) {
GM_setValue('cacheListNames', GM_getValue('cacheListNames') + ',' + name);
if (GM_getValue('cacheListNames').substring(0,1) == ',') {
GM_setValue('cacheListNames', GM_getValue('cacheListNames').substring(1,GM_getValue('cacheListNames').length));
}
if (GM_getValue('cacheListNames').split(",").length == myLength) {
//COMPLETE
document.getElementsByClassName('feed_auto_update_settings')[0].innerHTML = 'Choose a friends list to be hidden from the Highlight bar. <br/><small style="color: #888;">last cached: ' + window.getTime() + '</small>';
window.getNames();
window.refreshContent();
} else {
totals = (GM_getValue('cacheListNames').split(",").length + '/' + myLength);
percent = Math.round(100 * GM_getValue('cacheListNames').split(",").length / myLength) + '%';
document.getElementsByClassName('feed_auto_update_settings')[0].innerHTML = 'Choose a friends list to be hidden from the Highlight bar. <br/><small style="color: #888;">cache processing: ' + totals + '</small>';
}
}
/***********************************************************************/
window.removeContentFunc = function () {
window.getNames();
//EDITS BASED ON CONTENT (class not set)
remove = document.getElementsByClassName('UIHotStory_Body');
var subI = false;
for (i=0; i<remove.length; i++) {
if (removeApplications == 'true') {
if (destroyContent(remove[i],'this application')) {subI = true;}
}
if (removeCommentedOn == 'true') {
if (destroyContent(remove[i],'commented on this')) {subI = true;}
}
if (removeLiked == 'true') {
if (destroyContent(remove[i],'likes this')) {subI = true;}
if (destroyContent(remove[i],'like this')) {subI = true;}
}
if (removeTagged == 'true') {
if (destroyContent(remove[i],'is tagged')) {subI = true;}
if (destroyContent(remove[i],'are tagged')) {subI = true;}
}
if (nameArray[0] != "") {
for (nameI=0; nameI<nameArray.length; nameI++) {
if (destroyContent(remove[i],nameArray[nameI])) {subI = true;}
}
}
if (subI) {
i --;
subI = false;
}
}
}
/***************************GET BASIC CONTENT*****************************/
window.changeContentLoad = function () {
iconB = '<img class="spritemap_icons ';
iconE = '" src="http://static.ak.fbcdn.net/images/spacer.gif?8:11" style="vertical-align: middle"/> ';
myVisible = '<span style="color:#888888;">Visible <img src="http://b.static.ak.fbcdn.net/images/chat/friend_list_header.gif" style="width:300px; height:1px; vertical-align: middle;"></span><br/><div style="margin-left: 10px;">';
myHidden = '<br><span style="color:#888888;">Hidden <img src="http://b.static.ak.fbcdn.net/images/chat/friend_list_header.gif" style="width:300px; height:1px; vertical-align: middle;"></span><br/><div style="margin-left: 10px;">';
myTemp = iconB + 'sx_icons_favicon' + iconE + '<a class="greasedContentSettings" '; if (GM_getValue('removeApplications') == 'true') {myHidden += myTemp + 'id="false,removeApplications" />Show Applications</a><br/>';} else {myVisible += myTemp + 'id="true,removeApplications" />Hide Applications</a><br/>';}
myTemp = iconB + 'sx_icons_event' + iconE + '<a class="greasedContentSettings" '; if (GM_getValue('removeEvents') == 'true') {myHidden += myTemp + 'id="false,removeEvents" />Show Events</a><br/>';} else {myVisible += myTemp + 'id="true,removeEvents" />Hide Events</a><br/>';}
myTemp = iconB + 'sx_icons_gift' + iconE + '<a class="greasedContentSettings" '; if (GM_getValue('removeGifts') == 'true') {myHidden += myTemp + 'id="false,removeGifts" />Show Gifts</a><br/>';} else {myVisible += myTemp + 'id="true,removeGifts" />Hide Gifts</a><br/>';}
myTemp = iconB + 'sx_icons_group' + iconE + '<a class="greasedContentSettings" '; if (GM_getValue('removeGroups') == 'true') {myHidden += myTemp + 'id="false,removeGroups" />Show Groups</a><br/>';} else {myVisible += myTemp + 'id="true,removeGroups" />Hide Groups</a><br/>';}
myTemp = iconB + 'sx_icons_post' + iconE + '<a class="greasedContentSettings" '; if (GM_getValue('removeLinks') == 'true') {myHidden += myTemp + 'id="false,removeLinks" />Show Links</a><br/>';} else {myVisible += myTemp + 'id="true,removeLinks" />Hide Links</a><br/>';}
myTemp = iconB + 'sx_icons_note' + iconE + '<a class="greasedContentSettings" '; if (GM_getValue('removeNotes') == 'true') {myHidden += myTemp + 'id="false,removeNotes" />Show Notes</a><br/>';} else {myVisible += myTemp + 'id="true,removeNotes" />Hide Notes</a><br/>';}
myTemp = iconB + 'sx_icons_fbpage' + iconE + '<a class="greasedContentSettings" '; if (GM_getValue('removePages') == 'true') {myHidden += myTemp + 'id="false,removePages" />Show Pages</a><br/>';} else {myVisible += myTemp + 'id="true,removePages" />Hide Pages</a><br/>';}
myTemp = iconB + 'sx_icons_photo' + iconE + '<a class="greasedContentSettings" '; if (GM_getValue('removePhotos') == 'true') {myHidden += myTemp + 'id="false,removePhotos" />Show Photos</a><br/>';} else {myVisible += myTemp + 'id="true,removePhotos" />Hide Photos</a><br/>';}
myTemp = iconB + 'sx_icons_polls' + iconE + '<a class="greasedContentSettings" '; if (GM_getValue('removePolls') == 'true') {myHidden += myTemp + 'id="false,removePolls" />Show Polls</a><br/>';} else {myVisible += myTemp + 'id="true,removePolls" />Hide Polls</a><br/>';}
myTemp = iconB + 'sx_icons_motion' + iconE + '<a class="greasedContentSettings" '; if (GM_getValue('removeVideos') == 'true') {myHidden += myTemp + 'id="false,removeVideos" />Show Videos</a><br/>';} else {myVisible += myTemp + 'id="true,removeVideos" />Hide Videos</a><br/>';}
myTemp = iconB + 'sx_icons_relationship' + iconE + '<a class="greasedContentSettings" '; if (GM_getValue('removeRelationship') == 'true') {myHidden += myTemp + 'id="false,removeRelationship" />Show Relationships</a><br/>';} else {myVisible += myTemp + 'id="true,removeRelationship" />Hide Relationships</a><br/>';}
myTemp = iconB + 'sx_icons_relationship_remove' + iconE + '<a class="greasedContentSettings" '; if (GM_getValue('removeBreakup') == 'true') {myHidden += myTemp + 'id="false,removeBreakup" />Show Breakups</a><br/>';} else {myVisible += myTemp + 'id="true,removeBreakup" />Hide Breakups</a><br/>';}
thisTitle = 'For when you don\'t know the original poster, but see a friend has commented on their item.';
myTemp = iconB + 'sx_icons_comments' + iconE + '<a class="greasedContentSettings" title="' + thisTitle + '" '; if (GM_getValue('removeCommentedOn') == 'true') {myHidden += myTemp + 'id="false,removeCommentedOn" />Show Commented On</a><br/>';} else {myVisible += myTemp + 'id="true,removeCommentedOn" />Hide Commented On</a><br/>';}
thisTitle = 'For when you don\'t know the original poster, but see a friend likes their item.';
myTemp = iconB + 'sx_icons_like_on' + iconE + '<a class="greasedContentSettings" title="' + thisTitle + '" '; if (GM_getValue('removeLiked') == 'true') {myHidden += myTemp + 'id="false,removeLiked" />Show Liked</a><br/>';} else {myVisible += myTemp + 'id="true,removeLiked" />Hide Liked</a><br/>';}
thisTitle = 'For when you don\'t know the original poster, but have a friend tagged in their content.';
myTemp = iconB + 'sx_icons_photos_notes' + iconE + '<a class="greasedContentSettings" title="' + thisTitle + '" '; if (GM_getValue('removeTagged') == 'true') {myHidden += myTemp + 'id="false,removeTagged" />Show Tagged</a><br/>';} else {myVisible += myTemp + 'id="true,removeTagged" />Hide Tagged</a><br/>';}
myContent = '<span style="line-height: 15pt;">';
myContent += myVisible + '</div>' + myHidden + '</div>';
myContent +='<br/></span>';
}
/***************************DIALOG CREATION*******************************/
function aGS(css) {var head, style;head = document.getElementsByTagName('head')[0];if (!head) { return; }style = document.createElement('style');style.type = 'text/css';style.innerHTML = css;head.appendChild(style);}
aGS('#greasedTitle, #greasedDescription, #greasedContent, #pb_filter_tabs {padding:5px;}');
aGS('#greasedDescription {background-color: #F2F2F2; font-size: 1em; font-weight: normal;}');
myDialog = '<div class="generic_dialog_popup" style="top: 150px; width: 400px;"><div id="pop_content" class="pop_content popcontent_advanced"><h2 id="greasedTitle" class="dialog_title"></h2><div class="dialog_content"><div class="dialog_body"><h2 id="greasedDescription"></h2><div class="object_browser_tab_container" id="pb_object_browser_tab_container" style="border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; background-color: #f2f2f2; padding-bottom: 5px; height: 26px;"><div class="Tabset_tabset" id="pb_filter_tabs"></div></div><div class="object_browser_container" id="pb"><div id="pb_object_browser_content_area"><div id="greasedContent" class="object_browser_segment_div clearfix" style="height: 250px; overflow-x: hidden;"/></div></div></div></div><div class="dialog_buttons"><input type="button" class="inputsubmit" name="close" value="Close" onclick="myID=\'greasedItemSettings\';document.getElementById(myID).parentNode.removeChild(document.getElementById(myID));" /></div></div></div>';
selectedFilter = '<li class="PillFilter_filter Tabset_selected">'; unselectedFilter = '<li class="PillFilter_filter">'; filterMid = '<div class="tl"><div class="tr"><div class="br"><div class="bl">'; filterEnd = '</div></div></div></div></a></li>';
function createDialog() {newDialog = document.createElement("div");newDialog.innerHTML = myDialog;newDialog.id = "greasedItemSettings";newDialog.style.zIndex = 200;newDialog.className = "generic_dialog pop_dialog full_bleed";myItem = document.getElementById('content');myItem.parentNode.insertBefore(newDialog,myItem);}
function setContent(myTitle, myDescription, myContent, myFilters) {
document.getElementById('greasedTitle').innerHTML = myTitle;
document.getElementById('greasedDescription').innerHTML = myDescription;
document.getElementById('greasedContent').innerHTML = myContent;
filterArr = myFilters.split(",");
filterContent = '<ul class="PillFilter_pillfilter Tabset_tabset">';
for (i=0; i<filterArr.length; i++) {
if (filterArr[i].match("~")) {
filterArr[i] = filterArr[i].replace('~', '');
filterContent += selectedFilter + '<a class="greaseFilter highlighted" id="' + filterArr[i] + '">' + filterMid + filterArr[i] + filterEnd;
} else {
filterContent += unselectedFilter + '<a class="greaseFilter unselected" id="' + filterArr[i] + '">' + filterMid + filterArr[i] + filterEnd;
}
}
filterContent += '</ul>';
document.getElementById('pb_filter_tabs').innerHTML = filterContent;
window.checkHeight(); window.attachLinks();
}
window.checkHeight = function () {if (document.getElementById('greasedContent').offsetHeight > 250) {aGS('.object_browser_body {height:250px;overflow:auto;padding:3px 0 0;position:relative;}');} else {aGS('.object_browser_body {height:inherit;overflow:auto;padding:3px 0 0;position:relative;}');}}
loadingImage = '<span style="width:360px; display:block; text-align:center;"><img src="http://static.ak.fbcdn.net/images/loaders/indicator_blue_large.gif" alt="loading..." /></span>';
/*************************************************************************/
aGS('div.UIHomeBox {margin-top: 20px; margin-bottom: 20px;}');
aGS('.noLinkCol {color: #000;}');
myTitle = 'Highlight Bar Settings';
myDescription = 'Use this menu to hide specific elements based on the content.';
editSettingsLink = document.createElement("div");
editSettingsLink.className = "UIHomeBox_More";
editSettingsLink.id = "greasedSettingsLink";
editSettingsLink.innerHTML = '<small><a >Edit Settings</a></small>';
myItem = document.getElementsByClassName('UITitledBox');
for (i=0; i<myItem.length; i++) {
if (myItem[i].innerHTML.match('UIHotStory')) {
//ADD THE TOGGLE LINK
if (toggleHighlights == 'inherit') {
myItem[i].firstChild.firstChild.firstChild.innerHTML = '<a class="noLinkCol" id="greasedToggle">' + myItem[i].firstChild.firstChild.firstChild.innerHTML + ' <img src="http://www.ronaldtroyer.com/misc/grease/up_arrow.gif" id="highlightToggleArr" style="width: 10px; vertical-align: middle;"></a>';
} else {
myItem[i].firstChild.firstChild.firstChild.innerHTML = '<a class="noLinkCol" id="greasedToggle">' + myItem[i].firstChild.firstChild.firstChild.innerHTML + ' <img src="http://www.ronaldtroyer.com/misc/grease/down_arrow.gif" id="highlightToggleArr" style="width: 10px; vertical-align: middle;"></a>';
}
document.getElementById('greasedToggle').addEventListener('click',function () {
window.toggleVisible();
},false);
//ADD THE EDIT SETTINGS BUTTON
myItem[i].firstChild.insertBefore(editSettingsLink,myItem[i].firstChild.firstChild);
document.getElementById('greasedSettingsLink').addEventListener('click',function () {
if (document.getElementById('greasedItemSettings')) {document.getElementById('greasedItemSettings').parentNode.removeChild(document.getElementById('greasedItemSettings'));}
window.changeContentLoad();
createDialog();
setContent(myTitle, myDescription, myContent, '~Content,Friends,Friends List');
window.SettingsContentFunc();
},false);
}
}
window.toggleVisible = function (refresh) {
if (document.getElementsByClassName('UIHotStream')[0]) {
if (refresh != 'true') {
if (document.getElementsByClassName('UIHotStream')[0].style.display == 'none') {
document.getElementsByClassName('UIHotStream')[0].style.display = 'inherit';
document.getElementById('greasedHighlightBarHidden').style.display = 'inherit';
document.getElementById('highlightToggleArr').src = 'http://www.ronaldtroyer.com/misc/grease/up_arrow.gif';
GM_setValue('toggleHighlights','inherit');
} else {
document.getElementsByClassName('UIHotStream')[0].style.display = 'none';
document.getElementById('greasedHighlightBarHidden').style.display = 'none';
document.getElementById('highlightToggleArr').src = 'http://www.ronaldtroyer.com/misc/grease/down_arrow.gif';
GM_setValue('toggleHighlights','none');
}
} else {
if (document.getElementsByClassName('UIHotStream')[0].style.display == 'none') {
document.getElementsByClassName('UIHotStream')[0].style.display = 'none';
document.getElementById('greasedHighlightBarHidden').style.display = 'none';
document.getElementById('highlightToggleArr').src = 'http://www.ronaldtroyer.com/misc/grease/down_arrow.gif';
} else {
document.getElementsByClassName('UIHotStream')[0].style.display = 'inherit';
document.getElementById('greasedHighlightBarHidden').style.display = 'inherit';
document.getElementById('highlightToggleArr').src = 'http://www.ronaldtroyer.com/misc/grease/up_arrow.gif';
}
}
}
}
window.SettingsContentFunc = function () {
settingsLinks = document.getElementsByClassName('greasedContentSettings');
for(i=0;i<settingsLinks.length;i++){
settingsLinks[i].addEventListener('click',function () {
window.changeContent(this.id);
},false);
}
}
window.attachLinks = function () {
mylinks = document.getElementsByClassName('greaseFilter');
for (i=0; i<mylinks.length; i++) {
if(mylinks[i].className.match('unselected')) {
mylinks[i].addEventListener('click',function () {
myFilters = 'Content,Friends,Friends List';
myFilters = myFilters.replace(this.id,"~" + this.id);
setContent(myTitle, "Loading...", loadingImage, myFilters);
getContent(this.id);
},false);
}
}
}
window.getContent = function (myID) {
if (myID == 'Content') {
setContent(myTitle, myDescription, myContent, '~Content,Friends,Friends List');
window.SettingsContentFunc();
} else if (myID == 'Friends List') {
window.loadLists();
} else if (myID == 'Friends') {
window.loadFriends();
}
}
window.changeContent = function (myString) {
myValue = myString.split(",")[0];
myVariable = myString.split(",")[1];
GM_setValue(myVariable, myValue);
window.changeContentLoad();
setContent(myTitle, myDescription, myContent, '~Content,Friends,Friends List');
window.SettingsContentFunc();
window.refreshContent();
}
window.loadLists = function () {
GM_xmlhttpRequest({
method: 'GET',
url: 'http://www.facebook.com/friends/ajax/superfriends.php?all_lists=true',
headers: {'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey','Accept': 'text/plain',},
onload: function(responseDetails) {
if (responseDetails.status == 200) {
var info = responseDetails.responseText;
listIndex = 0;
myList = '';
while (listIndex != -1) {
listIndex = info.indexOf('"name":"', listIndex);
if (listIndex != -1) {
listIndex += 8;
listIndexE = info.indexOf('","', listIndex);
myList += info.substring(listIndex,listIndexE) + ',';
}
}
myList = myList.substring(0, myList.length - 1);
window.setLists(myList);
}
}
});
}
window.setLists = function (returnedLists) {
myDisplayLists = '';
myLists = returnedLists.split(",");
greaseLists = removeLists.split(",");
myVisible = '<span style="color:#888888;">Visible <img src="http://b.static.ak.fbcdn.net/images/chat/friend_list_header.gif" style="width:300px; height:1px; vertical-align: middle;"></span><br/><div style="margin-left: 10px;">';
myHidden = '<br><span style="color:#888888;">Hidden <img src="http://b.static.ak.fbcdn.net/images/chat/friend_list_header.gif" style="width:300px; height:1px; vertical-align: middle;"></span><br/><div style="margin-left: 10px;">';
myFunctions = '<br><span style="color:#888888;">Functions <img src="http://b.static.ak.fbcdn.net/images/chat/friend_list_header.gif" style="width:290px; height:1px; vertical-align: middle;"></span><br/><div style="margin-left: 10px;">';
if (myLists[0] != "") {
for(i=0;i<myLists.length;i++) {
greaseListMatch = false;
for (greaseI=0;greaseI<greaseLists.length;greaseI++) {
if (myLists[i] == greaseLists[greaseI]) {
greaseListMatch = true;
}
}
if (greaseListMatch == true) {
myHidden += '<img class="UIFilterList_SpriteIcon spritemap_app_icons sx_app_icons_friend_list" style="vertical-align: middle" src="http://static.ak.fbcdn.net/images/spacer.gif?8:11"> <a class="greaseList" id="del,' + myLists[i] + '" >Show ' + myLists[i] + '</a><br/>';
} else {
myVisible += '<img class="UIFilterList_SpriteIcon spritemap_app_icons sx_app_icons_friend_list" style="vertical-align: middle" src="http://static.ak.fbcdn.net/images/spacer.gif?8:11"> <a class="greaseList" id="add,' + myLists[i] + '" >Hide ' + myLists[i] + '</a><br/>';
}
}
myDisplayLists = '<span style="line-height: 15pt;">';
myDisplayLists += myVisible + '</div>';
myDisplayLists += myHidden + '</div>';
myDisplayLists += myFunctions;
myDisplayLists += '<img src="http://www.honoluluadvertiser.com/graphics/specials/beijing2008/icon_refresh.gif" style="vertical-align: middle"/> <a class="greaseList" id="refresh,refresh" >Refresh Cache</a><br/>';
myDisplayLists += '<img src="http://fc06.deviantart.com/fs49/f/2009/180/a/8/view_icon_by_user002.png" style="vertical-align: middle"/> <a class="greaseList" id="view,view" >View Cache</a><br/><br/>';
myDisplayLists += '</div></span>';
} else {
myDisplayLists = '<span style="line-height: 15pt;"><span style="color:#888888;">You have no lists</span></span><br/><br/>';
}
myListsDescription = 'Choose a friends list to be hidden from the Highlight bar. <br/><small style=\"color: #888;\">last cached: ';
myListsDescription += GM_getValue('cacheDate');
myListsDescription += '</small>';
setContent(myTitle, myListsDescription, myDisplayLists, 'Content,Friends,~Friends List');
window.SettingsListFunc();
}
window.SettingsListFunc = function () {
settingsLinks = document.getElementsByClassName('greaseList');
for(i=0;i<settingsLinks.length;i++){
settingsLinks[i].addEventListener('click',function () {
window.changeLists(this.id);
},false);
}
}
window.changeLists = function (myString) {
myAction = myString.split(",")[0];
myList = myString.split(",")[1];
removeLists = GM_getValue('removeLists');
if (myAction == "add") {
removeLists += ',' + myList;
if (removeLists.substring(0,1) == ",") {
removeLists = removeLists.substring(1,removeLists.length);
}
GM_setValue('removeLists', removeLists);
window.processLists();
window.loadLists();
window.SettingsListFunc();
window.refreshContent();
} else if (myAction == "del"){
removeLists = removeLists.replace(myList, '');
removeLists = removeLists.replace(',,', ',');
if (removeLists.substring(removeLists.length - 1, removeLists.length) == ",") {
removeLists = removeLists.substring(0,removeLists.length-1);
}
GM_setValue('removeLists', removeLists);
window.processLists();
window.loadLists();
window.SettingsListFunc();
window.refreshContent();
} else if (myAction == "refresh") {
window.processLists();
window.loadLists();
window.SettingsListFunc();
window.refreshContent();
} else if (myAction == "view"){
alert(GM_getValue('cacheListNames'));
}
}
window.loadFriends = function () {
myFDescription = 'Use this screen to add custom friend filters to the Highlights Bar.<br/><br/><b><small>This screen may be broken for some people. I have not been able to recreate the situation on my pc, but have observed it on a friends. Looking into the solution.</small></b>';
myFContent = '<span style="line-height: 15pt;">';
myFContent += '<span style="color:#888888;">Hidden Friends <img src="http://b.static.ak.fbcdn.net/images/chat/friend_list_header.gif" style="width:280px; height:1px; vertical-align: middle;"></span><br/><div style="margin-left: 10px;">';
if (removeNames == '') {
myFContent += ' No friends have been filtered.<br/>';
} else {
displayRemoveNames = removeNames.split(",");
for (i=0; i<displayRemoveNames.length; i++) {
myFContent += '<img class="friendDel" id="' + displayRemoveNames[i] + '" src="http://fc07.deviantart.com/fs49/f/2009/183/3/a/Delete_Icon_by_user002.png" style="width: 10px; height: 10px; margin-right: 3px; vertical-align: middle;">' + displayRemoveNames[i] + '<br/>';
}
}
myFContent += '</div><br/><input id="greasedFriendInput" class="inputtext" type="text"/><img id="friendSubmit" src="http://static.ak.fbcdn.net/images/streams/videos/video_badge.png" style="height: 24px; vertical-align: middle;"/><br/><br/>';
myFContent += '</span>';
setContent(myTitle, myFDescription, myFContent, 'Content,~Friends,Friends List');
listDel = document.getElementsByClassName('friendDel');
for (i=0; i<listDel.length; i++) {
listDel[i].addEventListener('click',function () {
removeFriendFromList(this.id);
},false);
}
document.getElementById('greasedFriendInput').addEventListener('keydown',function (e) {
checkEnter(e.keyCode);
},false);
document.getElementById('friendSubmit').addEventListener('click',function () {
processFriendInput();
},false);
}
function checkEnter(characterCode){
if(characterCode == 13){
processFriendInput();
return false;
} else {
return true;
}
}
window.processFriendInput = function () {
if (removeNames == '') {
GM_setValue('removeNames', document.getElementById('greasedFriendInput').value);
removeNames = document.getElementById('greasedFriendInput').value;
} else {
currNames = GM_getValue('removeNames');
currNames += ',' + document.getElementById('greasedFriendInput').value;
GM_setValue('removeNames', currNames);
removeNames = currNames;
}
document.getElementById('greasedFriendInput').value = '';
window.refreshContent();
window.loadFriends();
}
window.removeFriendFromList = function (myName) {
removeNames = removeNames.replace(myName, '');
removeNames = removeNames.replace(',,', ',');
if (removeNames.substring(removeNames.length-1, removeNames.length) == ',') {
removeNames = removeNames.substring(0, removeNames.length-1);
}
GM_setValue('removeNames', removeNames);
window.refreshContent();
window.loadFriends();
}
window.removeHR = function () {
myRemoves = document.getElementsByClassName('UIHotStory');
var stillLooking = true;
for (i=0; i<myRemoves.length; i++) {
if ((stillLooking) && (myRemoves[i].style.display != 'none')) {
stillLooking = false;
myRemoves[i].style.borderTop = '0 none';
} else {
myRemoves[i].style.borderTop = '1px solid #E6E6E6';
}
}
}
window.getHidden = function () {
if (document.getElementById('greasedHighlightBarHidden') != null) {
document.getElementById('greasedHighlightBarHidden').parentNode.removeChild(document.getElementById('greasedHighlightBarHidden'));
}
var myHiddenString = '';
myRemoves = document.getElementsByClassName('UIHotStory');
for (i=0; i<myRemoves.length; i++) {
if (myRemoves[i].style.display == 'none') {
myHiddenString += '<div class="UIHotStory UIHotStory_Small" style="border-top: 1px solid rgb(230, 230, 230); display: inherit; margin-top: 6px;">';
myHiddenString += myRemoves[i].innerHTML;
myHiddenString += '</div>';
}
}
if (myHiddenString != '') {
var boxTitles = document.getElementsByClassName('UITitledBox_Title');
var HighlightBar = '';
for (i=0; i<boxTitles.length; i++) {
if (boxTitles[i].innerHTML.match('Highlights')) {
HighlightBar = boxTitles[i].parentNode.parentNode.parentNode;
}
}
if (HighlightBar != '') {
newDialog = document.createElement("div");
newDialog.innerHTML = '<a style="margin-left: 5px;" id="greasedShowLink"><small>Show Removed </small><img src="http://www.ronaldtroyer.com/misc/grease/down_arrow.gif" border="0"></a>';
newDialog.innerHTML += '<a style="margin-left: 5px; display: none;" id="greasedHideLink"><small>Hide Removed </small><img src="http://www.ronaldtroyer.com/misc/grease/up_arrow.gif" border="0"></a>';
newDialog.innerHTML += '<div style="display:none;" id="myHidden">' + myHiddenString + '</div>';
newDialog.id = "greasedHighlightBarHidden";
newDialog.className = "UITitledBox_Content";
newDialog.style.marginTop = "6px";
newDialog.style.textAlign = "right";
newDialog.style.borderTop = '1px solid #E6E6E6';
HighlightBar.insertBefore(newDialog,HighlightBar.childNodes[HighlightBar.childNodes.length + 1]);
document.getElementById('greasedShowLink').addEventListener('click',function () {
document.getElementById('greasedShowLink').style.display = 'none';
document.getElementById('greasedHideLink').style.display = 'inherit';
document.getElementById('myHidden').style.display = 'inherit';
},false);
document.getElementById('greasedHideLink').addEventListener('click',function () {
document.getElementById('greasedShowLink').style.display = 'inherit';
document.getElementById('greasedHideLink').style.display = 'none';
document.getElementById('myHidden').style.display = 'none';
},false);
}
}
window.toggleVisible('true');
}
window.refreshContent = function () {
window.restoreAll();
window.getSettings();
window.removeClassFunc();
window.removeContentFunc();
window.removeHR();
window.getHidden();
}
window.refreshContent();
