There are 4 previous versions of this script.
// ==UserScript==
// @name DefineThat
// @namespace http://userscripts.org/users/42648
// @description Hold down the alt key and select a word (or double click it) to bring up the definition from Dictionary.com.
// @include *.*
// ==/UserScript==
document.getElementsByTagName('body')[0].addEventListener('mouseup', lookUpSelection, true); // add onMouseUp event to page.
function lookUpSelection(e) {
toDefine = document.getSelection().toString().trim();
toDefine = toDefine.charAt(0).toUpperCase()+toDefine.substring(1,toDefine.length);
if ( toDefine.length >= 1 && e.altKey && !e.ctrlKey ) { // if we're holding down the alt key.
defWindow = window.open('about:blank');
defWindow.document.write('<title>Definition of '+toDefine+' - DefineThat</title>');
defWindow.document.write('<body style="background-color:gray;">');1
defWindow.document.write(''+
'<div id="waitbox" style="'+
'position:absolute;'+
'top:50%;'+
'left:50%;'+
'margin-top:-150px;'+
'margin-left:-108px;'+
'height:70px;'+
'width:215px;'+
'-moz-border-radius:10px;'+
'text-align:center;'+
'font-family:impact;'+
'font-weight:normal;'+
'font-size:50px;'+
'color:white;'+
'background-color:black;'+
'padding:15px;'+
'">Defining...</div>');
GM_xmlhttpRequest({
method: 'GET',
url: 'http://dictionary.reference.com/browse/'+toDefine,
onload: function(response) {
siteScrape = response.responseText;
found = siteScrape.indexOf('No results found for') == -1 && siteScrape.indexOf('You are seeing ask web results') == -1;
wordLink = (!found) ? toDefine : '<a href="http://dictionary.reference.com/browse/'+toDefine+'" '+
'title="Go to the Dictionary.com page for '+toDefine+'.">'+toDefine+'</a>';
startPoint = (siteScrape.indexOf('<div class="dndata">') > -1) ? '<div class="dndata">' : '<div class="pbk">';
def = siteScrape.substring(siteScrape.indexOf(startPoint),siteScrape.indexOf('</div>',siteScrape.indexOf(startPoint))+6).replace('1.','');
content = (!found) ? 'Sorry, <strong>'+toDefine+'</strong> was not found at Dictionary.com' : def;
defWindow.document.write(''+
'<div id="defineThat_Ad" style="'+
'width:600px;'+
'position:absolute;'+
'top:50%;'+
'margin-top:-285px;'+
'left:50%;'+
'margin-left:-300px;'+
'padding:10px;'+
'font-size:50px;'+
'font-style:italic;'+
'text-decoration:underline;'+
'text-align:center;'+
'">DefineThat</div>'+
'<div id="defDiv" style="'+
'width:600px;'+
'height:200px;'+
'position:absolute;'+
'top:50%;'+
'left:50%;'+
'margin-left:-300px;'+
'margin-top:-200px;'+
'-moz-border-radius:5px;'+
'padding:10px;'+
'background-color:white;'+
'z-index:0;'+
'">'+wordLink+'<div>'+content+'</div></div>'+
'<div id="othersearches" style="'+
'position:absolute;'+
'top:50%;'+
'left:50%;'+
'margin-top:25px;'+
'margin-left:-300px;'+
'width:600px;'+
'padding:5px 10px 10px 10px;'+
'-moz-border-radius:5px;'+
'background-color:FAEEC5;'+
'text-align:center;'+
'z-index:1;'+
'">'+
'<a href="http://www.google.com/search?q='+toDefine+'">Google - "'+toDefine+'"</a> | '+
'<a href="http://www.urbandictionary.com/define.php?term='+toDefine+'">Urban Dictionary - "'+toDefine+'"</a> | '+
'<a href="http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search='+toDefine+'&go=Go">Wikipedia - "'+toDefine+'"</a>'+
'</div>');
defWindow.document.close();
}
});
}
else if ( toDefine.length >= 1 && e.ctrlKey && e.altKey ) {
defWindow = window.open('about:blank');
defWindow.location = 'http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search='+toDefine+'&go=Go';
}
}