// A very simple and rough script to pick out the largest element on a
// page.  It is useful for some news papers for example.

// ==UserScript==
// @name           ClassBody
// @namespace      http://kalvis.com
// @description    Tidy up a page
// @include        http://www.independent.co.uk/*/*
// ==/UserScript==

var body = document.getElementsByTagName("body")[0];
var corebody = document.getElementsByClassName("body")[0];

body.innerHTML = corebody.innerHTML;

body.style.backgroundColor = "white";
body.style.color = "black";          
body.style.font="12pt Helvetica";    
body.style.margin = "5%";            
body.align = "left";      

var articleTitle = document.createElement("H1");
var tweet = document.createElement("H2");       
var email = document.createElement("H2");       

articleTitle.innerHTML = document.title;        

tinySource = {};
tinySource.method = "GET";
tinySource.url = "http://tinyurl.com/api-create.php?url=" 
    + document.location;                                  
tinySource.onload = function(responseDetails){            
    tweet.innerHTML = '<a href="http://twitter.com?status=' 
    + escape(document.title + ' ' + responseDetails.responseText) 
    + '">tweet</a>';
    var info;
    info = document.getElementsByName('Description')
    if (info.length > 0)
	info = info[0].content;
    else
	info = "";
    email.innerHTML = '<a href="mailto:?subject='
    + escape(document.title) + '&body='
    + escape(responseDetails.responseText + " " + info)
    + '">email</a>';
}

GM_xmlhttpRequest(tinySource);

body.insertBefore(email, body.firstChild);
body.insertBefore(tweet, body.firstChild);
body.insertBefore(articleTitle, body.firstChild);  
