Skip to content

Instantly share code, notes, and snippets.

@disrupted
Last active January 23, 2017 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save disrupted/dfdf4f51fb216c866ef82c0088ba15db to your computer and use it in GitHub Desktop.
Save disrupted/dfdf4f51fb216c866ef82c0088ba15db to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Force Autocomplete
// @description enable autocomplete for all HTML input fields
// @author disrupted
// @version 0.1
// @match http://*/*
// @grant none
// ==/UserScript==
var initialDelay = 2000; // adjust to make it work with all websites
// =================================================================
(function() {
'use strict';
var counter = 0;
window.addEventListener('load', function() {
setTimeout(function() {
var forms = document.getElementsByTagName('form');
for (var i = 0; i < forms.length; i++) {
forms[i].autocomplete = 'on';
}
var inputfields = document.getElementsByTagName('input');
for (var j = 0; j < inputfields.length; j++) {
if (inputfields[j].getAttribute('autocomplete') == 'off') {
inputfields[j].autocomplete = 'on';
var oldPlaceholder = inputfields[j].getAttribute('placeholder');
inputfields[j].placeholder = oldPlaceholder + ' + autocomplete';
counter++;
}
}
if (counter !== 0) {
console.log('[Userjs] forcing autocomplete for ' + counter + ' input fields.');
}
}, initialDelay);
}, false);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment