// Orkut Scrap All
// version 0.1
// 2006
// Copyright (c) 2006, Devadutta D Ghat
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
// --------------------------------------------------------------------
// ==UserScript==
// @name           OrkutScrapAll
// @namespace      http://devadutta.net/
// @description    Opens the scrapbooks of all your friends for whom you have not posted replies. Currently, it cannot check if you have posted a reply or not and simply opens the scrapbooks of all the people visible on the current window, but the next versions will be able to do that.
// @include        *orkut*
// ==/UserScript==

function ScrapAll() { //alert("Chappale.. Chappale.. "); 

var i=document.getElementsByTagName('a');
for (var j=i.length-1; j>1; j--) {
    var linkdata =  i[j].getAttribute("href");
    var linkparts = linkdata.split("?");
    if (linkdata.match("Profile.") == "Profile." ) {
	    var s = i[j].innerHTML;
	    var s1 = s.indexOf('<');
	    if( s1 < 0 ){
        var scrapviewlink = document.createElement("a");
        scrapviewlink.href="http://www.orkut.com/ScrapBook.aspx"+"?"+linkparts[1];
        scrapviewlink.appendChild(document.createTextNode(" [S] "));

	//alert(scrapviewlink.href);
	window.open(scrapviewlink.href);
        var albumlink = document.createElement("a");
        albumlink.href="http://www.orkut.com/AlbumView.aspx"+"?"+linkparts[1];
        albumlink.appendChild(document.createTextNode(" [A] "));

        i[j].parentNode.insertBefore( albumlink ,i[j].nextSibling);
        i[j].parentNode.insertBefore( scrapviewlink ,i[j].nextSibling);
    	}
        }
    }
}
GM_registerMenuCommand("ScrapAll",ScrapAll);


//window.open("http://devadutta.net");
