Bypassing Paste Restrictions

2025/02/21

I recently had to pay a tax bill online, but it turned out that my town’s bill payment website has one of those incredibly annoying JavaScript forms that blocks pasting into the bank account number field. This is so, so stupid. I genuinely don’t understand what benefit they think this could possibly offer. They force me to type it in manually, and then, because typing things in manually is an error-prone process, the next field forces me to type in the whole number manually again! You know what’s not an error-prone process? Copying and pasting the account number.

The first thing I tried to get around this was installing an extension called “Don’t Fuck with Paste.” Charmingly, the name of the extension is starred out (“Don’t F*** with Paste”) in the Chrome web store, but not in the Firefox web store. I prefer Firefox in any event, and in this case the name of the Firefox extension better reflected my level of frustration with the website. Anyway, I got the extension, which promptly… broke paste everywhere in the browser. Uninstall.

Fortunately, Linux lets you do things yourself! I usually run Wayland, so I installed wl-clipboard, which lets you manipulate the Wayland clipboard, and wtype, which lets you emulate keystrokes. Then I added a line to my Sway config:

bindsym $mod+Shift+v exec wl-paste --no-newline | wtype -

(The --no-newline suppresses wl-paste’s puzzling default behavior of adding a newline to strings that didn’t have them).

And that was it! Now I can bypass paste restrictions anywhere, more or less regardless of how they’re implemented.