Google-chrome – disable Google Chrome Autofill ONLY for localhost

google-chrome

I'm a developer and it's VERY annoying having Chrome suggest all my personal address information in forms one web sites I'm developing on running on my local machine. Is disabling Autofill on localhost, or a domain, or an IP address possible? I'm not seeing anything in the advanced settings.

Best Answer

I recently answered another question with the same requirement of customizing features of Chrome (and also inspired from @Paul).

NOTE: This solution allows you to block a specific IP address or list of IPs, without having to load any additional library and no additional scripts in your project. Fact often you may have blocked all Javascript features, but the control "noautofill" follow operating, avoiding collisions with other libraries, allowing also you have a real recognition of the consumption charge and rendering time, and this can translate into savings of time debugging day to day, on different web projects.

Create a Chrome extension that uses the "match filter host" of the Chrome API, and filter your custom IP host or namehost. Then set the attribute autocomplete to off for all "input" and "form" tags.

We proceed with these steps:

  • Create a new folder named ex. noautofill

  • Create into our new folder, a new file named manifest.json and add this code inside:


{
  "name": "No Autofill",
  "version": "1.0",
  "manifest_version": 2,
  "description": "No Autofill.",  
  "content_scripts": [ {
      "all_frames": true,
      "exclude_globs": [  ],
      "include_globs": [ "*" ],  
      "js": [ "script.js" ],      
      "matches": [   
                   "http://192.168.1.100/",
                   "http://127.0.0.1/",
                   "http://10.0.1.100/",
                   "http://localhost/",
                   "http://wp.local/",
                   "http://192.168.1.100/*",
                   "http://127.0.0.1/*",
                   "http://10.0.1.100/*",
                   "http://localhost/*",
                   "http://wp.local/*"                   
                    ],
      "run_at": "document_start"
   } ],
  "permissions": [ "tabs", "http://*/", "https://*/", "https://*/*", "http://*/*", "contextMenus" ]

}
  • In our new folder, create a new file named script.js and add this code inside:


(function(){    
    chrome.extension.sendRequest({
        autofill:'off'
    },function(){       
        var inputnodes = document.getElementsByTagName('input');    
        for(var i=0;i<inputnodes.length;i++){       
            inputnodes[i].setAttribute('autocomplete','off');
        }       
        var formnodes = document.getElementsByTagName("form");    
        for(var i=0;i<formnodes.length;i++){                    
            formnodes[i].setAttribute('autocomplete','off');
        }       
  });
})();
  • We go to Chrome's menu » Settings » Extensions

  • Now we click the button "Load unpacked extensions"

  • Finally we mark our folder and click on the open button.

This is the result:

noautofill

This system is very simple, and you can customize the file script.js with your own control code. In the future you may add other scripts, CSS, configuration pages, etc. Remember that every time you will make changes in the file script.js you should reload the plugin with CtrlR.

Also you can get a more detiled guide about how to create Chrome extensions.

Related Question