Nintendo Wii forums Forum for writers phpBB mods Essays on copyright Dating advice Narnia forums

GreaseMonkey script for Digg friends stuff

So almost immediately after posting my previous GreaseMonkey script, I was reading some Digg comments and noticed someone asking for some new user preferences on Digg – in particular, he wanted Digg to turn off all the alerts and boxes for the friends list.  I thought it was overkill to depend upon Digg for that, when a simple JavaScript would change it.  However, as with my previous script, it wasn't as easy as I expected.

The problem is that Digg doesn't put their friends list boxes into named DIV tags.  So I can't just easily getElementById and then set the display to none.  Instead, I needed something like getElementByClass, which doesn't exist.  So I went through the GreaseMonkey docs, found out how to use document.evaluate() in a way that hunts for attributes of a tag (thus, the equivalent of getElementByClass), and then finally I looped through the resulting objects, and found the one that had the text about the friends list.  Yay!

So here is what I came up with.  The first few lines are just copied & modified from Dive Into Greasemonkey.

var allDivs, thisDiv;
allDivs = document.evaluate(
"//div[@class='side-container']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null
);
for (var i = 0; i < allDivs.snapshotLength; i++) {
thisDiv = allDivs.snapshotItem(i);
if (thisDiv.innerHTML.match(/Activity in 48hr<\/h2>/) ||
thisDiv.innerHTML.match(/<h2>Add Your Friends/)) {
thisDiv.style.display = "none";
}
}

If you would like to stop the display of the friend box and the "so-and-so invited so-and-so" text, you can install this script into your GreaseMonkey-compatible browser.  Have fun.

Navigate

« GreaseMonkey script for Bioware forums | Main | Giving Movable Type WYSIWYG Editing »

Nav by tag: greasemonkey
« GreaseMonkey script for Bioware forums | Main | Fixing the City of Palo Alto site »
Nav by tag: tech
« GreaseMonkey script for Bioware forums | Main | Giving Movable Type WYSIWYG Editing »
Bookmark It! Technorati del.icio.us Netvouz DZone ThisNext Wists blinkbits BlinkList blogmarks blogtercimlap Blue Dot Bumpzee co.mments connotea DotNetKicks Fark feedmelinks Fleck Furl Gwar Haohao Hemidemi IndiaGram IndianPad Internetmedia kick.ie LinkaGoGo Linkter Ma.gnolia MyShare Netscape NewsVine PlugIM PopCurrent ppnow RawSugar Reddit Shadows Simpy Slashdot Smarking Spurl Webride YahooMyWeb
TrackBack

TrackBack URL for this entry:
http://www.outshine.com/cgi-bin/outshine/trackback.cgi/23

Comments (13)
Neko writes:

To : Abhi R u sure this happened beacuse of FAN FLOODER???Coz this kinda problem comes up when u use scrapbook flooder for long time, say for floodin 1000+ scraps in one session!Anyway by d time u r reading this, ur account wil be restored automatically as orkut disables account for some time when u use any such script for hours!But I recommend to download all ur contacts in CSV format from orkut's friends pages! This wil help u to come bak on orkut if ur account gets deleted in future!


Check that off the list of things I was confused about.


auto insurence writes:

As Charlie Sheen says, this article is "WINNING!"


Unparalleled accuracy, unequivocal clarity, and undeniable importance!


Great post with lots of important stuff.


This is a most useful contribution to the debate


unaprix.com writes:

I'm so glad that the internet allows free info like this!


Very valid, pithy, succinct, and on point. WD.


news writes:

That insight solves the problem. Thanks!


Back in school, I'm doing so much learning.


You are so awesome for helping me solve this mystery.


mobile writes:

Never seen a better post! ICOCBW


That insight's just what I've been looking for. Thanks!


Post a comment

Verification (needed to reduce spam):