Wandering Thoughts archives


Javascript modifying cut and paste can sometimes be a good thing in browsers

One of the famous problems of the Javascript enabled web is that people can use Javascript to tamper with the behavior of cut and paste (which is most commonly copy and paste). Even when people have relatively good intentions, Javascript can mess this up in environments like 'smart' text editing (and you can shoot yourself in the foot with browser settings). However, every so often people use this power to good effect. Recently, I had an illustration of this in Mastodon (the specific software that my Fediverse instance uses).

When I wrote about the evaporation of lots of .ga domains, I quoted one of my Fediverse posts and did this by copying it in my Firefox and pasting it into my vim editing session in an xterm. My post contained a link, and in the displayed text of the original post this link is shortened in Mastodon's usual style of displaying them. Currently, it renders as 'web.archive.org/web/2022040414…'. However, when I copied and pasted the text of the post, what I got in the plain text was the full text of the link, not the shortened text (in fact it seems basically impossible to copy the short text, which was slightly inconvenient for writing this entry).

This behavior is almost always going to be what you want if you're copying the text of a Mastodon post that contains one or more links. You almost never want the shortened display version of the link, you want the full URL that the author wrote and that you can use. So Mastodon's Javascript arranges to give you that full expanded version. A lot of people may not even notice it, because it 'just works' from their perspective. The only reason I noticed is that I was expecting to have to copy the full link by hand, and then didn't need to because it was already there.

(This is like the quiet tricks that get done with 'back' like actions.)

web/BrowserSmartCutPasteCanBeGood written at 21:33:42; Add Comment

Page tools: See As Normal.
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.