Created
August 9, 2010 14:00
-
-
Save timwhitlock/515450 to your computer and use it in GitHub Desktop.
improved dictionary.com bookmarklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// source | |
void ( function(){ | |
try { | |
var s = window.getSelection(); | |
var q = s ? s.toString().replace(/(^\W+|\W+$)/g,'') : ''; | |
if( ! q ){ | |
q = prompt('Enter a word to look up'); | |
if( ! q ){ | |
return; | |
} | |
} | |
var u = 'http://dictionary.reference.com/search?r=1&q='+encodeURIComponent(q); | |
window.open(u); | |
} | |
catch( Er ){ | |
alert( 'Oops:\n'+Er.message ); | |
} | |
} )(); | |
// compressed and encoded for href/bookmarklet | |
javascript:void%20(function(){try{var%20b=window.getSelection(),a=b?b.toString().replace(/(^\W+|\W+$)/g,''):'';if(!a){a=prompt('Enter%20a%20word%20to%20look%20up');if(!a)return}var%20c='http://dictionary.reference.com/search?r=1&q='+encodeURIComponent(a);window.open(c)}catch(d){alert('Oops:\n'+d.message)}})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment