DEV Community

How to create and use custom search engines in Chrome for more efficient searching and increased productivity

If you like this article, chances are you will like my tweets too. If you are curious, have a look at my Twitter profile. πŸš€

Chrome's Search Engines

In the picture above you see a list of pre-defined search engines of Google Chrome. They can save time when looking up a question on Google or finding a product on Amazon. Did you know that you can customize them to increase your productivity? No? Then I have got an interesting and helpful tip for you today - use and customize Google Chrome's search engines to make your life easier.


When you are looking up a topic on Google, do you open google.com or do you use the browser's built-in search feature?

Most of you probably write "google" into the address bar, press tab, enter the query, and hit enter, right? This works with other websites too, like dict.cc, YouTube, and Amazon for instance. This is the search engine feature.

You enter a keyword, hit tab, provide a query, and finally execute the search.

These are the individual parts of the feature. What can we do with this feature and how can we create our own search engine? I have prepared some examples for you.

We can use search engines for

  • custom search engines
  • bookmarklets
  • bookmark shortcuts

Let's take a look at each example.

Set up custom search engines

Did you know that Google has multiple search operators? That is quite a lot. You can use them to customize your search query. That is very helpful. These are the ones I use pretty often:

  • filetype:
  • site:
  • inurl:
  • intext:
  • intitle: ""
  • define:
  • and the - (minus) operator

They all support you in finding what is relevant for you faster. For the first custom search engine, I have chosen the define operator. Here is how it looks like in action:

Google Search Engine - Define

Instead of visiting google.com and remembering the search operator, I have created a search engine. This is way faster and I remember this search operator exists. πŸš€

Setting up a custom search engine is easy. Here is a step-by-step manual for my define example:

  1. Open Chrome's settings page ("CMD+," on macOS, or enter chrome://settings in the address bar)
  2. Click on "Search Engines" in the side menu (or enter chrome://settings/searchEngines in the address bar)
  3. Press the "Add" button above "Other search engines"

You should now see a screen like to this:

Add custom search engine

My "define" search engine has the following values:

  • Search engine: "AA Define a Word"

You probably add more custom search engines once you see their value. Adding a prefix (e.g. "AA") will ensure you can differentiate custom and automatically created search engines quickly.

  • Keyword: "define"

This is the keyword you need to enter to select a search engine.

  • URL with %s in place of query: {google:baseURL}search?q=define%3A%20%s&hl=en

The magic happens in the last field, the URL. This URL will be opened when you hit enter in the address bar. %s resolves to the entered text. Add it at the proper position in the URL and save the search engine.

The final result should look like this:

Custom Search Engine - Define

Congratulations, you created your first custom search engine shortcut! πŸš€ Now you can enter define and execute it. Cool, isn't it?

Let's take a look at a few other use cases.

Filetype search operator

  • pdf, docx and pptx: enable quick file type lookups on Google
Search engine: AA Find PDF
Keyword: pdf
URL: {google:baseURL}search?q=%s+filetype%3Apdf&hl=en

Search engine: AA Find DOCX
Keyword: docx
URL: {google:baseURL}search?q=%s+filetype%3Adocx&hl=en

Search engine: AA Find PPTX
Keyword: pptx
URL: {google:baseURL}search?q=%s+filetype%3Apptx&hl=en
Enter fullscreen mode Exit fullscreen mode

Bookmarklets

  • sons (search on site): It takes the current site that I’m on and performs a site:domain.com search on Google.
Search Engine: AA Find on Current Site
keyword: sons
URL: javascript:!function(){var s=prompt("Search current site for what?","");window.open("https://www.google.com/search?q="+encodeURIComponent(s)+"+site:"+window.location.hostname)}();
Enter fullscreen mode Exit fullscreen mode
  • setcookie and deletecookie: You need to set and delete cookies on a page pretty often (we do this in our dev setup for instance)? Then this bookmarklet and search engine is for you:
// setCookie
javascript: void (function () {
  var d = new Date();
  d.setDate(new Date().getDate() + 365);
  document.cookie = "nocache=1;expires=" + d.toGMTString() + ";path=/;";
  window.location.reload(true);
})();

// deleteCookie
javascript: void (function () {
  var d = new Date();
  d.setSeconds(new Date().getSeconds() + 1);
  document.cookie = "nocache=;expires=" + d.toGMTString() + ";path=/;";
  window.location.reload(true);
})();
Enter fullscreen mode Exit fullscreen mode

In this example, the cookie is set to nocache=1. But you can also make it more dynamic:

// setCookie
javascript: void (function () {
  var cookieToSet = prompt("Cookie (e.g. 'test=1'):", "");

  if (cookieToSet) {
    var d = new Date();
    d.setDate(new Date().getDate() + 365);
    document.cookie = cookieToSet + ";expires=" + d.toGMTString() + ";path=/;";
    window.location.reload(true);
  }
})();

// deleteCookie
javascript: void (function () {
  var cookieToSet = prompt("Cookie (e.g. 'test'):", "");

  if (cookieToSet) {
    var d = new Date();
    d.setSeconds(new Date().getSeconds() + 1);
    document.cookie = cookieToSet + "=;expires=" + d.toGMTString() + ";path=/;";
    window.location.reload(true);
  }
})();
Enter fullscreen mode Exit fullscreen mode

These bookmarklets can delete and set a cookie which expires in 365 days from now. You can create cookie bookmarklets with cookie-bookmarklet-generator in seconds.

Set Cookie Bookmarklet

Bookmarks

You can use search engines as shortcuts for bookmarks too.

  • dev: opens https://dev.to/.
  • ga: opens https://analytics.google.com/analytics/web/
  • lorem: opens https://www.loremipsum.de.

dev.to

Summary

Custom search engines come in very handy. Quickly find what you are looking for, create bookmarks, or utilize bookmarklets.

I am always curious to find new ones, so let me know below in the comments what you have set up.


References


>> Let's connect on Twitter 🐦: https://twitter.com/natterstefan
>> Subscribe to my newsletter πŸ‘¨πŸ»β€πŸ’»: https://newsletter.natterstefan.me

Top comments (0)