Skip to content

Instantly share code, notes, and snippets.

@nathanlogan
Created November 3, 2016 23:23
Show Gist options
  • Save nathanlogan/18e6c0068d826506df715552197b7f5b to your computer and use it in GitHub Desktop.
Save nathanlogan/18e6c0068d826506df715552197b7f5b to your computer and use it in GitHub Desktop.
Bookmarklet: populate and submit a known form
When you don't have access to the source code of a form, you may be stuck in a position where autofill doesn't work and you are doing a lot of repetitive entry. That's where this script comes in. Now you click a button and the form autofills with (static) values of your choice and immediately submits. Some forms may not work very well with this approach (like ones where the fields are dynamic, don't have distinguishable attribute identifiers, etc.), but it works well for my current use case. YMMV.
The code (without preview, due to good security restrictions):
<a href="javascript:!(function (doc) { doc.getElementById('HwPxTokenOneField').value = 'Doe'; doc.getElementById('HwPxDOBMonthField2').value = '01'; doc.getElementById('HwPxDOBDayField2').value = '17'; doc.getElementById('HwPxDOBYearField2').value = '1971'; doc.getElementById('HwPxLoginButton').click()})(window.document);">eSDP Login</a>
The example and demo (use this to actually add the bookmarklet):
https://jsfiddle.net/nathanlogan/b3znt9q2/
A similar pattern may work for your form, as well. Feel free to tweak it to your needs.
@nathanlogan
Copy link
Author

Click here for example and demo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment