Skip to content

Instantly share code, notes, and snippets.

@irisli
Created July 2, 2016 01:03
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 irisli/b767dab7cdf1bfde70e124e4145a97b5 to your computer and use it in GitHub Desktop.
Save irisli/b767dab7cdf1bfde70e124e4145a97b5 to your computer and use it in GitHub Desktop.
Batch form filler
// Batch form filler to be used in the console
formValues = [
['foo','bar'],
['bar','baz'],
['baz','blah'],
['blah','blahblah'],
['wibble','wobble'],
['flob','wubble'],
]
// Luckily for this case, the form I wanted to fill used id's to mark the form elements
$zero = document.querySelector('#old');
$one = document.querySelector('#target input');
$submit = document.querySelector('#submit');
var i = 0;
var submitChange = function() {
if (i >= formValues.length) {
return;
}
var currentValue = formValues[i];
$zero.value = currentValue[0];
$one.value = currentValue[1];
$submit.click();
i++;
setTimeout(submitChange, 1000);
};
submitChange();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment