Status Bar Replacement

By Tyler Charlesworth Last update Mar 19, 2006 — Installed 85,473 times. Daily Installs: 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
// ==UserScript==
// @name		Status Bar Replacement
// @namespace	http://www.tyworks.net
// @description	adds mouseover info panel to every link
// @include         *
// ==/UserScript==

//TODO change relative links to absolute links
//i.e. /address => http://www.google.com/address

(function() {

if(document.getElementsByTagName('body')[0] && document.getElementsByTagName('body')[0].firstChild){ //only do this stuff if there is a body with stuff in it
/* head
	insert script */
theSBRScript=document.createElement('script');
theSBRScript.setAttribute('type','text/javascript');
theSBRScript.setAttribute('id','theSBRScript');
theSBRScript.innerHTML=unescape("var%20theShowDelayerSBR%3B%0Avar%20globalXSBR%3D0%3B%0Avar%20globalYSBR%3D0%3B%0Afunction%20doPopSBR%28popObject%29%20%7B%0A%09setContentSBR%28popObject%29%3B%0A%09theShowDelayerSBR%20%3D%20window.setTimeout%28%22setLocationSBR%28%29%22%2C600%29%3B%0A%7D%0Afunction%20setLocationSBR%28%29%20%7B%0A%09//reset%20this%20from%20if%20it%20was%20too%20wide%20before%0A%09document.getElementById%28%27tipBoxBg%27%29.style.width%3D%22%22%3B%0A%09document.getElementById%28%27tipBox%27%29.style.width%3D%22%22%3B%0A%09document.getElementById%28%27tipBoxBg%27%29.style.overflow%3D%22%22%3B%0A%09document.getElementById%28%27tipBox%27%29.style.overflow%3D%22%22%3B%0A%09%0A%09var%20tempLeft%3DglobalXSBR+10+window.pageXOffset%3B%0A%09var%20tempTop%3DglobalYSBR+15+window.pageYOffset%3B%0A%09%0A%09//make%20it%20so%20we%20can%20see%20calculated%20width/height%0A%09document.getElementById%28%27tipBoxBg%27%29.style.visibility%3D%22hidden%22%3B%0A%09document.getElementById%28%27tipBox%27%29.style.visibility%3D%22hidden%22%3B%0A%09document.getElementById%28%27tipBoxBg%27%29.style.display%3D%22block%22%3B%0A%09document.getElementById%28%27tipBox%27%29.style.display%3D%22block%22%3B%0A%09%0A%09if%28%20%28tempLeft+document.getElementById%28%27tipBox%27%29.offsetWidth%29%20%3E%20%28window.innerWidth+window.pageXOffset-18%29%20%29%20%7B%20//if%20its%20too%20far%20right%20//IN%20THE%20GM%20SCRIPT%2C%20the%20subtracted%20number%20is%20based%20on%20the%20constant+2%28shadow%20offset%29%0A%09%09tempLeft-%3D%28document.getElementById%28%27tipBox%27%29.offsetWidth+12%29%3B%0A%09%7D%0A%09%0A%09if%28%20%28tempTop+document.getElementById%28%27tipBox%27%29.offsetHeight%29%20%3E%20%28window.innerHeight+window.pageYOffset-18%29%20%29%20%7B%20//if%20its%20too%20far%20down%20//IN%20THE%20GM%20SCRIPT%2C%20the%20subtracted%20number%20is%20based%20on%20the%20constant%0A%09%09tempTop-%3D%28document.getElementById%28%27tipBox%27%29.offsetHeight+18%29%3B%0A%09%7D%0A%09%0A%09if%28tempLeft%20%3C%20window.pageXOffset%29%20%7B%20//if%20it%20is%20too%20far%20left%2C%20i.e.%20it%20is%20a%20super-wide%20box%0A%09%09tempLeft%3Dwindow.pageXOffset+1%3B%20//set%20it%20all%20the%20way%20to%20the%20left%0A%09%09if%28%20%28document.getElementById%28%27tipBox%27%29.offsetWidth+2%29%20%3E%20%28document.documentElement.clientWidth-11%29%20%29%7B%20//if%20in%20needs%20to%20be%20given%20a%20max%20width%0A%09%09%09document.getElementById%28%27tipBoxBg%27%29.style.width%3Ddocument.documentElement.clientWidth-12%3B%20//IN%20THE%20GM%20SCRIPT%2C%20this%20is%20-%283%20+%20user%20specified%20scrollbar%20width%20constant%29%0A%09%09%09document.getElementById%28%27tipBox%27%29.style.width%3Ddocument.documentElement.clientWidth-12%3B%0A%09%09%09document.getElementById%28%27tipBoxBg%27%29.style.overflow%3D%22hidden%22%3B%0A%09%09%09document.getElementById%28%27tipBox%27%29.style.overflow%3D%22hidden%22%3B%0A%09%09%7D%20else%20%7B%0A%09%09%09tempLeft%3Dwindow.pageXOffset+%28%28document.documentElement.clientWidth-document.getElementById%28%27tipBox%27%29.offsetWidth%29/2%29-1%3B%20//center%20the%20box%0A%09%09%7D%0A%09%7D%0A%09%0A%09document.getElementById%28%27tipBoxBg%27%29.style.left%3DtempLeft+2+%22px%22%3B%0A%09document.getElementById%28%27tipBox%27%29.style.left%3DtempLeft+%22px%22%3B%0A%09document.getElementById%28%27tipBoxBg%27%29.style.top%3DtempTop+2+%22px%22%3B%0A%09document.getElementById%28%27tipBox%27%29.style.top%3DtempTop+%22px%22%3B%0A%09document.getElementById%28%27tipBoxBg%27%29.style.visibility%3D%22visible%22%3B%0A%09document.getElementById%28%27tipBox%27%29.style.visibility%3D%22visible%22%3B%0A%7D%0Afunction%20setContentSBR%28theObject%29%20%7B%0A%09var%20theTitle%3DtheObject.getAttribute%28%27title%27%29%3B%0A%09if%28theTitle%3D%3Dnull%29%20theTitle%3D%22%22%3B%0A%09var%20theAlt%3DtheObject.getAttribute%28%27childalts%27%29%3B%0A%09if%28theAlt%3D%3Dnull%29%20theAlt%3D%22%22%3B%0A%09var%20theHref%3DtheObject.getAttribute%28%27href%27%29%3B%0A%09if%28theHref%3D%3Dnull%29%7B%0A%09%09theHref%3D%22%22%3B%0A%09%7D%20else%20if%28theHref.charAt%28theHref.length-1%29%3D%3D%22/%22.charAt%280%29%29%20%7B%0A%09%09theHref%3DtheHref.substring%280%2CtheHref.length-1%29%3B%0A%09%7D%0A%09var%20theClick%3DtheObject.getAttribute%28%27onclick%27%29%3B%0A%09if%28theClick%3D%3Dnull%29%20theClick%3D%22%22%3B%0A%09document.getElementById%28%27titleValueA%27%29.innerHTML%3DtheTitle%3B%0A%09document.getElementById%28%27titleValueB%27%29.innerHTML%3DtheTitle%3B%0A%09document.getElementById%28%27altValueA%27%29.innerHTML%3DtheAlt%3B%0A%09document.getElementById%28%27altValueB%27%29.innerHTML%3DtheAlt%3B%0A%09document.getElementById%28%27hrefValueA%27%29.innerHTML%3DtheHref%3B%0A%09document.getElementById%28%27hrefValueB%27%29.innerHTML%3DtheHref%3B%0A%09document.getElementById%28%27clickValueA%27%29.innerHTML%3DtheClick%3B%0A%09document.getElementById%28%27clickValueB%27%29.innerHTML%3DtheClick%3B%0A%09if%28theTitle%3D%3D%22%22%29%7B%0A%09%09document.getElementById%28%27titleSectionA%27%29.style.display%3D%22none%22%3B%0A%09%09document.getElementById%28%27titleSectionB%27%29.style.display%3D%22none%22%3B%0A%09%7D%0A%09if%28theAlt%3D%3D%22%22%29%7B%0A%09%09document.getElementById%28%27altSectionA%27%29.style.display%3D%22none%22%3B%0A%09%09document.getElementById%28%27altSectionB%27%29.style.display%3D%22none%22%3B%0A%09%7D%0A%09if%28theHref%3D%3D%22%22%29%7B%0A%09%09document.getElementById%28%27hrefSectionA%27%29.style.display%3D%22none%22%3B%0A%09%09document.getElementById%28%27hrefSectionB%27%29.style.display%3D%22none%22%3B%0A%09%7D%0A%09if%28theClick%3D%3D%22%22%29%7B%0A%09%09document.getElementById%28%27clickSectionA%27%29.style.display%3D%22none%22%3B%0A%09%09document.getElementById%28%27clickSectionB%27%29.style.display%3D%22none%22%3B%0A%09%7D%0A%09theObject.setAttribute%28%27title%27%2Cnull%29%3B%0A%7D%0Afunction%20unPopSBR%28theObject%29%20%7B%0A%09window.clearTimeout%28theShowDelayerSBR%29%3B%0A%09document.getElementById%28%27tipBoxBg%27%29.style.display%3D%22none%22%3B%0A%09document.getElementById%28%27tipBox%27%29.style.display%3D%22none%22%3B%0A%09document.getElementById%28%27titleSectionA%27%29.style.display%3D%22block%22%3B%0A%09document.getElementById%28%27altSectionA%27%29.style.display%3D%22block%22%3B%0A%09document.getElementById%28%27hrefSectionA%27%29.style.display%3D%22block%22%3B%0A%09document.getElementById%28%27clickSectionA%27%29.style.display%3D%22block%22%3B%0A%09document.getElementById%28%27titleSectionB%27%29.style.display%3D%22block%22%3B%0A%09document.getElementById%28%27altSectionB%27%29.style.display%3D%22block%22%3B%0A%09document.getElementById%28%27hrefSectionB%27%29.style.display%3D%22block%22%3B%0A%09document.getElementById%28%27clickSectionB%27%29.style.display%3D%22block%22%3B%0A%09if%28theObject%29%20theObject.setAttribute%28%27title%27%2Cdocument.getElementById%28%27titleValueA%27%29.innerHTML%29%3B%0A%7D");
document.getElementsByTagName('head')[0].appendChild(theSBRScript);
/* body
	append onmousemove */
var tempMouseAttrib=document.getElementsByTagName('body')[0].getAttribute('onmousemove');
if(!tempMouseAttrib) tempMouseAttrib="";
if(tempMouseAttrib!="") tempMouseAttrib=tempMouseAttrib+"; ";
document.getElementsByTagName('body')[0].setAttribute('onmousemove', (tempMouseAttrib+'globalXSBR=event.clientX;globalYSBR=event.clientY;') );
/* body
	insert 2 divs inside */
theSBRDivA=document.createElement('div');
theSBRDivB=document.createElement('div');
theSBRDivA.setAttribute('id','tipBoxBg');
theSBRDivB.setAttribute('id','tipBox');
theSBRDivB.setAttribute('onmouseover',"document.getElementById('tipBoxBg').style.display='none'; document.getElementById('tipBox').style.display='none';"); //in the offchance it gets displayed when it shouldnt
theSBRDivA.setAttribute('style',"position:absolute; left:13px; top:13px; padding:3px; font-size:10px; text-align:left; line-height:13px; white-space:nowrap; display:none; border:1px solid black; font-family:Verdana,sans-serif; z-index:9998; background:black; color:black; opacity:.3;");
theSBRDivB.setAttribute('style',"position:absolute; left:10px; top:10px; padding:3px; font-size:10px; text-align:left; line-height:13px; white-space:nowrap; display:none; border:1px solid black; font-family:Verdana,sans-serif; z-index:9999; background:rgb(255,255,247); color:black;");
theSBRDivA.innerHTML=unescape("%09%3Cdiv%20id%3D%22titleSectionA%22%3E%3Cspan%20id%3D%22titleLabelA%22%20style%3D%22%22%3ETitle%3A%20%3C/span%3E%0A%09%09%3Cspan%20id%3D%22titleValueA%22%3E%3C/span%3E%3C/div%3E%0A%09%3Cdiv%20id%3D%22altSectionA%22%3E%3Cspan%20id%3D%22altLabelA%22%20style%3D%22%22%3EImg%3A%20%3C/span%3E%0A%09%09%3Cspan%20id%3D%22altValueA%22%3E%3C/span%3E%3C/div%3E%0A%09%3Cdiv%20id%3D%22hrefSectionA%22%3E%3Cspan%20id%3D%22hrefLabelA%22%20style%3D%22%22%3ELink%3A%20%3C/span%3E%0A%09%09%3Cspan%20id%3D%22hrefValueA%22%3E%3C/span%3E%3C/div%3E%0A%09%3Cdiv%20id%3D%22clickSectionA%22%3E%3Cspan%20id%3D%22clickLabelA%22%20style%3D%22%22%3EonClick%3A%20%3C/span%3E%0A%09%09%3Cspan%20id%3D%22clickValueA%22%3E%3C/span%3E%3C/div%3E");
theSBRDivB.innerHTML=unescape("%09%3Cdiv%20id%3D%22titleSectionB%22%3E%3Cspan%20id%3D%22titleLabelB%22%20style%3D%22%22%3ETitle%3A%20%3C/span%3E%0A%09%09%3Cspan%20id%3D%22titleValueB%22%20style%3D%22%22%3E%3C/span%3E%3C/div%3E%0A%09%3Cdiv%20id%3D%22altSectionB%22%3E%3Cspan%20id%3D%22altLabelB%22%20style%3D%22%22%3EImg%3A%20%3C/span%3E%0A%09%09%3Cspan%20id%3D%22altValueB%22%3E%3C/span%3E%3C/div%3E%0A%09%3Cdiv%20id%3D%22hrefSectionB%22%3E%3Cspan%20id%3D%22hrefLabelB%22%20style%3D%22%22%3ELink%3A%20%3C/span%3E%0A%09%09%3Cspan%20id%3D%22hrefValueB%22%20style%3D%22%22%3E%3C/span%3E%3C/div%3E%0A%09%3Cdiv%20id%3D%22clickSectionB%22%3E%3Cspan%20id%3D%22clickLabelB%22%20style%3D%22%22%3EonClick%3A%20%3C/span%3E%0A%09%09%3Cspan%20id%3D%22clickValueB%22%20style%3D%22%22%3E%3C/span%3E%3C/div%3E");
document.getElementsByTagName('body')[0].insertBefore(theSBRDivB,document.getElementsByTagName('body')[0].firstChild);
document.getElementsByTagName('body')[0].insertBefore(theSBRDivA,document.getElementsByTagName('body')[0].firstChild);
/* every a
	append onmouseover,onmouseout
	check inside for images with alt tags */
var allAs = document.getElementsByTagName('a');
for(var i=0; i<allAs.length; i++) {
//onmouseover
	//get link attributes
	var currentOver = allAs[i].getAttribute("onmouseover") + "";
	//removes spaces
	while(currentOver.charAt(currentOver.length-1)==" ") {
		currentOver=currentOver.substring(0,currentOver.length-1);
	}
	//adds code to whatever is already there
	if(currentOver=="") {
		allAs[i].setAttribute("onmouseover","doPopSBR(this);");
	} else if(currentOver.lastIndexOf(";")==currentOver.length-1) {
		allAs[i].setAttribute("onmouseover",currentOver+" doPopSBR(this);");
	} else {
		allAs[i].setAttribute("onmouseover",currentOver+"; doPopSBR(this);");
	}
//onmouseout
	//get link attributes
	var currentOver = allAs[i].getAttribute("onmouseout") + "";
	//removes spaces
	while(currentOver.charAt(currentOver.length-1)==" ") {
		currentOver=currentOver.substring(0,currentOver.length-1);
	}
	//adds code to whatever is already there
	if(currentOver=="") {
		allAs[i].setAttribute("onmouseout","unPopSBR(this);");
	} else if(currentOver.lastIndexOf(";")==currentOver.length-1) {
		allAs[i].setAttribute("onmouseout",currentOver+" unPopSBR(this);");
	} else {
		allAs[i].setAttribute("onmouseout",currentOver+"; unPopSBR(this);");
	}
//image alts
	var theInnerImages=allAs[i].getElementsByTagName('img');
	if(theInnerImages!=null) { //there are images inside
		var allTheAlts="";
		for(var j=0; j<theInnerImages.length; j++) { //run through all of the images
			var newAlt=theInnerImages[j].getAttribute('alt');
			if(newAlt!=null){ //there is an alt
				theInnerImages[j].setAttribute('alt','');
				if(allTheAlts!="") {
					allTheAlts+="&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;"+newAlt;
				} else {
					allTheAlts=newAlt;
				}
			}
			theInnerImages[j].setAttribute('title','');
		}
		allAs[i].setAttribute('childalts',allTheAlts);
	}
}
//fix embedded flash existing above the popup
//as instructed at http://forum.stylegala.com/about2623.html
//DOESN'T WORK, if anybody has a fix for this, please contact me
/* 
var allEmbeds = document.getElementsByTagName('embed');
for(var i=0; i<allEmbeds.length; i++) {
	if(allEmbeds[i].getAttribute('src').indexOf('.swf')>0) allEmbeds[i].setAttribute('wmode','transparent');
}
*/

} // END make sure there is a body

})();