Skip to content

Instantly share code, notes, and snippets.

@lyoshenka
Created November 22, 2013 22:25
Show Gist options
  • Select an option

  • Save lyoshenka/7607911 to your computer and use it in GitHub Desktop.

Select an option

Save lyoshenka/7607911 to your computer and use it in GitHub Desktop.
Chrome Extension to stop Chrome from trying to search when going to a URL with .localhost domain.
chrome.tabs.onUpdated.addListener(function(tabId, e) {
if (e.url && e.url.match('google.com/search') && e.url.match('localhost')) {
var q = e.url.match(/q=[^&]+&/i);
if (q) {
var localUrl = decodeURIComponent(q[0].substring(2,q[0].length-1));
chrome.tabs.update(tabId, {url: 'http://' + localUrl });
}
}
});
{
"name": "Chrome Localhost Search Blocker",
"version": "1",
"description": "Stops Chrome from trying to search when going to a URL with .localhost domain.",
"permissions": ["webNavigation", "tabs", "http://*/*", "https://*/*"],
"background": {
"scripts": ["chromeSearchFix.js"]
},
"manifest_version": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment