Re-enabling Password Pasting

As a 1password user, I usually have very long, unique, and random passwords for every site that requires one. I use the 1Password browser extensions to fill password forms for me, but on iOS I copy and paste the values manually. Some misguided web developers have decided pasting passwords should be prohibited and have added onpaste events to prevent it. The latest culprit I have encountered is Apple.

While this is an infrequent annoyance it can be crippling. To combat it, I whipped up a bookmarklet that will run some JavaScript on the page to remove onpaste events from all password fields.

To use the bookmarklet, drag the allow pwpaste bookmarklet link to your bookmark toolbar. When you encounter one of these annoying forms, simply click the bookmark to re-enable pasting. The bookmarklet source is available in a more readable format below.

Adding bookmarklets to mobile safari is a giant pain, so I would suggest adding the bookmarklet in desktop Safari and using iCloud to sync it.

var inputs = document.getElementsByTagName('input');
for (var i=0; i < inputs.length; i++) {
  if (inputs[i].getAttribute('type').toLowerCase() === 'password') {
    inputs[i].setAttribute('onpaste', '');