Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Google Chrome, if I select a piece of text and right click on it, I get the option to:

'Search Google for [text]'

I find this extremely useful but I'd also like to be able to add my own options.

For example, I'd like to add the ability to search amazon.co.uk using the selected text or go straight to Google maps using the selected text (i.e. an address or postcode) and so on.

I can sort of add this functionality using PhraseExpress but would rather be able to do it straight from Chrome - is it possible?

share|improve this question

5 Answers 5

up vote 5 down vote accepted

Here's an extension that uses the Context Menus API to add options to the right click menu for selected text and lets you define your own custom searches.

Try http://maps.google.com/maps?q=TESTSEARCH for Google Maps and http://www.amazon.co.uk/s/?url=search-alias%3Daps&field-keywords=TESTSEARCH for Amazon.co.uk.

share|improve this answer
    
Yes, I think this does exactly what I want - thanks. By the way, need to add the term TESTSEARCH in your strings to use the selected word or phrase and it works great. –  andygrunt Sep 13 '10 at 20:07
    
I've edited my answer to reflect that. –  gdejohn Sep 19 '10 at 8:09

There's a Context Menus API available in the developer and beta channels as of recently. You can use it to write your own extensions which add options to the right click menu. Note that this will only work for Google Chrome version 6 and higher.

Here's an example from the official extensions gallery:

I also wrote three of my own, based on that code:

You can install those at your own risk by right clicking the links, clicking Save Link As…, finding the files on your computer, and dragging them into a Google Chrome window.

Read about the API here:

To write your own, you need a manifest.json file, which should look something like this:

{
   "background_page": "background.html",
   "description": "Add a context menu item to search for selected text at Google Maps.",
   "icons": {
      "16": "icon16.png",
      "48": "icon48.png"
   },
   "minimum_chrome_version": "6",
   "name": "Google Maps Right Click",
   "permissions": [ "contextMenus", "tabs" ],
   "version": "1.0"
}

You also need a background.html file, which should look something like this:

<script>

function searchgooglemaps(info)
{
 var searchstring = info.selectionText;
 chrome.tabs.create({url: "http://maps.google.com/maps?q=" + searchstring})
}

chrome.contextMenus.create({title: "Search Google Maps", contexts:["selection"], onclick: searchgooglemaps});

</script>

Lastly, you should have at least a 16 × 16 pixel icon for the context menu and a 48 × 48 pixel icon for the extensions management page. You can also specify a 128 × 128 pixel icon, which is shown during installation, and a 32 × 32 pixel icon if you want to submit your extension to the official gallery. All of your icons need to be listed in manifest.json. Make sure file types and names match up.

Put the icons, background.html, and manifest.json in a folder together, then go to the extensions management page at chrome://extensions, look under Developer mode (I think you need to be running the beta channel or higher for this to show up), click on Pack extension…, next to Extension root directory click Browse…, locate and select the folder you made, click OK, and drag the resulting .crx file into your Google Chrome window.

share|improve this answer
    
Thanks for this Charlatan. I had heard about the new API but was waiting until I found the extension that fulfillled my wishes before posting it here as the final answer. I very much doubt I'll try making my own as there are far better people to do that than me. Perhaps the Author of the 'Context Search' extension will rewrite it to make use of the new API. –  andygrunt Sep 6 '10 at 10:10
    
You're welcome. It's really very easy to adapt the above examples for other sites. All you have to do to get it working is change the URL. Everything else is just making it pretty. I've edited the code in my answer to work for searching Google Maps. Only had to change five things. –  gdejohn Sep 7 '10 at 5:47
    
Note that there are some changes to chrome extensions, namely that the manifest.json is now version 2 and a lot of this stuff has changed. –  Jason Aug 27 '12 at 0:33

There is a Context Search extension which does what you want with an exception that it does not add anything to the right click menu; instead, after you select a chunk of text on page, it will show a small button with blue triangle next to it, and clicking on it will pop up menu. alt text

share|improve this answer
    
Excellent. This does 99% of what I want. As you say, it doesn't add the options to the right click menu but, more importantly, it doesn't work everywhere e.g. write something in the Google search box, select it and the button doesn't appear. I'd still like to hear if it's possible to add the options to the right click menu but this will do to be getting on with. Thanks. –  andygrunt Aug 23 '10 at 10:38
    
AFAIK there are no way to add options to Chrome native menus (like the "Options" menu in top-right) because extensions can only tweak DOM and display pop-ups. Probably that was an intentional choice to achieve better cross-platform compatibility. –  whitequark Aug 23 '10 at 10:42
1  
This is one reason I'm sticking to Firefox. –  CGA Aug 23 '10 at 10:46
    
@CGA: Firefox is nice, and I used it for years, but it is waay too sloow on Atom 2x1600 netbook. –  whitequark Aug 23 '10 at 13:48
    
Can't disagree with you there. –  CGA Aug 23 '10 at 15:21

Maybe this is what you are looking for... Send to Google Maps

share|improve this answer
    
Thanks for the suggestion but it seems a bit too specialised. The 'Context Menu Search' extension allows me to add whatever links I like: Maps, images, Amazon, IMDB etc. –  andygrunt Sep 14 '10 at 8:40

There is an extension called "Context Menu Search". It lets you add URLs to it, and then when you select a text, and click one of the URLs, it passes that text to the URL you clicked.

For example, the search URL for YouTube is:

http://www.youtube.com/results?search_query=TESTSEARCH

where TESTSEARCH is the text you want to search for. In the extension, you add this line and it'll automatically replace TESTSEARCH with the selected text when you press it. You can ofcourse add a label for each URL.

Here is the link to the extension.

https://chrome.google.com/webstore/detail/ocpcmghnefmdhljkoiapafejjohldoga

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.