How to stop a form from blocking paste in Safari

This is a quick blog post, mostly for my own reference.

I finally got sick of a certain government website thinking that preventing pasting passwords into certain forms was some sort of security feature, so I am documenting my workaround in Safari for stupid forms written by compliance-minded folks (the same who think that expiring passwords every 30 days leads to any kind of better security).

In Safari, select Develop > Show Javascript Console (or press ⌥⌘C, that's Option + Command + 'C')1.

Paste the following into the console and press 'Enter':

var allowPaste = function(e){
  return true;
document.addEventListener('paste', allowPaste, true);

Now you can paste to your heart's content.

1 If you don’t see the Develop menu in the menu bar, choose Safari > Preferences, click Advanced, then select “Show Develop menu in menu bar.”


I would recommend getting StopTheMadness.

It does this for you much easier!

True, but it's a pretty heavyweight extension that does a lot more than just fix dumb paste-handling javascript.

The track record for 'popular extensions that get bought out then malwarified over time' is not great, so I'm extremely picky about any browser extension I install (right now just AdGuard and 1Password).

lol they don't understand that it's difficult to secure anything client side.

Thanks so much for this. Is there a workaround to override right click prevention? My bank prevents right click and pasting.