I needed an easy way to go to a hostname of the domain my computer is on in my web browser. Things like wp.domain.lan or something. When I type domains ending with .lan into Google Chrome, it takes me to the search page. What I want it to do is take me to the url I typed in and I usually want it to use https as well. To solve this, I created an extension following this Google Chrome developer guide.

I used most of the code from that guide, but I didn’t want it to open a new tab. For that, in the background.js file, I made it look like this:

  function(text) {

    // Use https by default
    var proto = 'https';

    // Check for unsecured or unsecure
    if (text == 'unsecured' || text == 'unsecure') {

      // goto http instead of https
      proto = 'http';

      // make sure it is unsecured in case we typed unsecure
      text = 'unsecured';

    // Build the URL
    var url = proto + '://' + text + '.domain.lan';

    // Open the url in the current tab
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
      chrome.tabs.update(tabs[0].id, {url: url});

The above code also adds in an exception for one site named unsecured.domain.lan to go to http instead of https. It also allows using unsecure instead of unsecured (notice the d). The possibilities are endless really.

A couple of other things to change for further customization is the name and keyword to use in the manifest.js file. Notice the “name” line and the line with “keyword”. This makes it so when we type the letter d and then a space in the omnibox, it precedes what we type next with “HTTPS domain.lan”.

  "name": "HTTPS domain.lan",
  "description": "Type 'w' plus a search term into the Omnibox to open search.",
  "version": "1.0",
  "background": {
    "scripts": ["background.js"],
    "persistent": false
  "omnibox": { "keyword" : "d" },
  "manifest_version": 2,
  "browser_action": {
    "default_icon": {
      "16": "newtab_search16.png",
      "32": "newtab_search32.png"
  "icons": {
    "16": "newtab_search16.png",
    "32": "newtab_search32.png",
    "48": "newtab_search48.png",
    "128": "newtab_search128.png"

Some more ideas for future improvements might be to create some sort of web service where I could register some keywords on it and the code in the background.js file would do some sort of quick lookup from it to determine where to go next.


  1. https://developer.chrome.com/extensions/getstarted
  2. https://developer.chrome.com/extensions/samples#search:omnibox