Awesome extension!!
Was actually planning on writing (or trying to) a similar extension myself (for Moz and Phx).
Glad someone beat me to it.
Only thing that would be nice is a bit more fuctionallity. JohnC has made a similar add-on for IE. I'll post it below (Thanks John C).
recognizes misspelss and other protocols.
Cheers
-------o-------o------
<SCRIPT LANGUAGE="JavaScript" defer>
// Remote Version of Open Selected URL application by JohnC
// Updated by Jason Duke details of this are at
//
http://villan.org/zor/ubb/ultimatebb.ph ... 1;t=004117
//
// Enjoy
// Copyright is owned by JohnC and is ammended with permission by Jason Duke (
http://www.strangelogic.com)
//
// OPEN SELECTED URL - a handy IE5+ Context Menu Extension thingy
// Version: 1.6 - 13 July 2001
// Script By: JohnC -
http://websolutions.n3.net -
batsite@beer.com
// Licence: Freeware, but I'd really appreciate your feedback and money
// For full info about this, see openselectedurl_readme.txt in the original zip file
///////////////////////////////////////////////////////////////////////////////////////
// THIS SECTION DETERMINES THE CONVERSIONS THAT WILL BE DONE TO THE SELECTED TEXT
// You may add additional conversion strings between the 1st / and Last /gi
// in following variables ConvertToHTTP, ConvertToFTP & ConvertToWWW
// - and they will be automatically converted to 'http' or 'ftp' or 'www' accordingly
// NOTE 1 : You must separate each one with a | character (pipe = uppercase backslash)
// NOTE 2 : Non-alphanumeric characters should have \ before them (be escaped)
// - eg: * should be \* -and- / should be \/ -etc-
var ConvertToHTTP = /h\*\*p:\/\/|hxxp:\/\//gi;
var ConvertToFTP = /f\*p\/\/|fxp\/\//gi;
var ConvertToWWW = /w\*w|\*\*\*/gi;
// After it does any conversions, it will open window immediately and exit if
// the following text strings are contained in the text :
var OpenCodes = /http:\/\/|ftp:\/\/|news:/i;
// This regex tests for valid Email syntax :
var EmailCodes = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
///////////////////////////////////////////////////////////////////////////////////////
// Determine what the User has selected, and process it as much as possible :
var E=external.menuArguments,SEL=new String(E.document.selection.createRange().text),
URL=SEL.replace(/\042|\047/g,''); // Strip any wierd space characters
URL=URL.replace(/\s+/g,''); // Strip any whitespace inside it
// URL=URL.replace(/^\s+|\s+$/g,''); // Strip any whitespace at start and end
URL=URL.replace(/^\.+|\.+$/g,''); // Strip any dots at start and end only
// URL=URL.replace(/^\s+|\s+$/g,''); // Strip any whitespace again to be sure
URL=URL.replace(/\\/g,'/'); // Change BackSlashes to ForwardSlashes
URL=URL.replace(ConvertToHTTP,'http://'); // Convert any HTTP Codes
URL=URL.replace(ConvertToFTP,'ftp://'); // Convert any FTP Codes
URL=URL.replace(ConvertToWWW,'www'); // Convert any WWW Codes
// whitespace routines changed v1.6 - old ones left in but commented out
///////////////////////////////////////////////////////////////////////////////////////
// Global Functions :
function CheckTypo(U){ var T,U2=false,
HT=new Array(/http:\//i,/http:/i,/htp:\/\//i,/htp:\//i,/htp:/i),
FT=new Array(/ftp:\//i,/ftp:/i);
for(i=0;i<HT.length;i++){T=HT[i];if(T.test(U)){U2=U.replace(T,'http://');break;}}if(U2){return U2;}
for(i=0;i<FT.length;i++){T=FT[i];if(T.test(U)){U2=U.replace(T,'ftp://'); break;}} return U2;
}
function Error(){ var W=250,H=100,Bcol="#FFFFCC",Tcol="#000066",CloseMS=2500,
SC=screen,aH=SC.availHeight,aW=SC.availWidth,Mx=E.event.screenX,My=E.event.screenY;
SEL.length>30?SEL=SEL.substring(0,28)+"...":"";(Mx+W)>aW?Mx=aW-W:'';(My+H)>aH?My=aH-H:'';
var MSG='<TITLE>Open Selected URL Error ....................</TITLE>'
+'<SCR'+'IPT>setTimeout(\'self.close()\','+CloseMS+');</SCR'+'IPT>'
+'<BODY TOPMARGIN="0" LEFTMARGIN="0" BGCOLOR="'+Bcol+'" TEXT="'+Tcol+'" LINK="'+Tcol+'">'
+'<TABLE HEIGHT="100%" WIDTH="100%"><TR><TD><FONT FACE="Arial" SIZE="2">'
+'<CENTER>Sorry, the text you just highlighted couldn\'t be resolved to a URL or Email'
+'<FONT SIZE="1"><BR><BR>©2001 Strange Logic <A HREF="http://www.strangelogic.com" TARGET="J">'
+'Strange Logic Ltd.</A></TD></TR></TABLE></CENTER></BODY></HTML>';
P=window.open('','','width='+W+',height='+H+',left='+Mx+',top='+My);
P.resizeTo(W,H);P.document.write(MSG);
}
function OpenIt(URL){location.href=URL;}
///////////////////////////////////////////////////////////////////////////////////////
// OK - now we can actually do something with that selection they made...
if (URL.indexOf('.')==-1) {Error();} // it could not be URL or email
else if(OpenCodes.test(URL)) {OpenIt(URL);} // URL seems OK, open it fast !
else if(EmailCodes.test(URL)) {OpenIt('mailto:'+URL);} // definitely an email addie
else if(CheckTypo(URL)) {OpenIt(CheckTypo(URL));} // check/fix any http/ftp typos
else if(URL.indexOf('://')!=-1){OpenIt('http://'+URL.split('://')[1]);} // a partial URL, use http://
else if(URL.charAt(0)=='@') {Error();} // partial email address ?
else {OpenIt('http://'+URL);} // oh well, open http:// anyway
</SCRIPT>