We’ve talked about how amazing custom browser searches can be, but Lifehacker reader mdegat01 took it to the next level and submitted five even more advanced searches that make your life easier. Here’s how they work.
These searches use JavaScript to allow for all sorts of other inputs. You can select text and use it in your custom search, use the current page as input and even use your current location.
Creating them works similarly to any other custom search, but you’ll be pasting code instead of a URL into Chrome or Firefox. First, copy and paste the following code as the search engine’s “URL:”
javascript:var url='MYURL';if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,'')}}(function(u,m,h,n){var WC={'e':m[1]||n,'h':h||n,'q':(m[1]||h)?(h+' '+m[1]).trim():n,'d':window.location.hostname,'u':window.location.href,'t':document.title,'l':n};var w='[';for(var key in WC){if(WC.hasOwnProperty(key)){w+=key}}w+=']';var re=new RegExp('%((?:\\('+w+'(?:\\|\\|'+w+')+\\))|'+w+')','g');var sU=function(p){if(p){WC.l=p.coords.latitude+'%20'+p.coords.longitude}u=u.replace(re,function(match,p1,off,str){return encodeURIComponent((eval(p1.replace(new RegExp(w,'g'),'WC.$&'))||''))});switch((m[2]||'c').toLowerCase()){case'w':window.open(u,'Omnibar Window','toolbar=0,status=0,resizable=1,width=1100,height=762');break;case't':window.open(u,'_blank');break;default:window.location.href=u;break}};var lTest=/%(?:\([^)]*)?\bl\b/.test(u);if(navigator.geolocation&&lTest){navigator.geolocation.getCurrentPosition(sU)}else{if(lTest){alert('Geolocation%20is%20not%20supported%20by%20this%20browser.')}sU()}})(url,(/^(.*?)([wtc])?$/i.exec('%s')),((window.getSelection?window.getSelection():(document.getSelection?document.getSelection():(document.selection?document.selection.createRange().text:document.selection)))));
However, replace the MYURL
at the beginning with one of the following URLs.
Visit Google’s Cache of the Current Page: If a site is down but you want to see what the page contains, you can paste this URL into the above code and add a keyword to do so from any page:
http://www.google.com/search?q=cache:%u
Search for Selected Text on Google Maps: Find the name of a cool restaurant? Instead of opening Maps and searching for it, just select the name of the restaurant, type in your keyword, and this search will map it out for you. Just paste this into the above code:
http://www.google.com/maps?q=%q%20near%20%l
Get Directions From Your Current Location: We’ve shown you how to get directions from your home location, but if you paste this into the above code, you can search for an address with your keyword to get directions from your current location:
http://www.google.com/maps?saddr=%l&daddr=%q
Add a New Event to Google Calendar Using Selected Text: Paste this into the code above, and you’ll be able to select text on a page and add a new event to your Google Calendar with that text as the title:
http://www.google.com/calendar/event?ctext=%q∾tion=TEMPLATE&pprop=HowCreated:QUICKADD
Mdegat01 had a few other searches too, but these were our favourites. You could probably do a ton of other great stuff using his code too, since it works basically the same as any other custom search but with other wildcards (like %h for currently highlighted text, %l for current location and so on).
Leave a Reply
You must be logged in to post a comment.