« Hypergeometric tail inequaliti... | Home | プリティプリントの試... »

Firefox mouse copy and paste in Twitter

Wed 27 Nov 2013 by mskala Tags used: , ,

PROBLEM: Since just before the Twitter IPO, when they changed their site code, mouse copy-and-paste no longer works on Twitter's Web site viewed in Firefox. Where before one could highlight text with the mouse and then middle-button click to paste it somewhere, now that either causes the former contents of the clipboard to be pasted, or the string "witter.com". Copy and paste still works if and only if once uses explicit "copy" and "paste" commands with the keyboard or menu bar, but that is much less convenient, and is annoying to discover on the fly. Observed in several versions of Firefox under Linux; similar problems have been reported with other browser and other operating systems. Problem is specific to Twitter.

SOLUTION: In "about:config," set "dom.event.clipboardevents.enabled" to "false." Explanation below the cut.

Twitter's new code apparently intercepts anything that changes the contents of the clipboard. Such interception is usually done by Web sites that attempt to prevent users from using copy-and-paste, and I think it's a security hole that Firefox allows Web sites to do it at all; however, in fairness to Twitter, it appears that this time they are sincerely trying to be helpful to users. The intercept code does things like automatically un-shortening shortened URLs.

Middle-button copy-and-paste operates at a lower level than the "real" clipboard, as one can occasionally observe when using it in conjunction with explicit copy-and-paste commands. It uses a buffer that is separate from and only partially synchronized with the clipboard used by menu "copy" and "paste" commands. Twitter's intercept code catches the events that relate to the mouse buffer, but it only reads and writes the "real" clipboard, and it prevents the mouse buffer from being updated with highlighted text.

Changing this Firefox setting prevents Javascript scripts (in general, not just Twitter's) from getting the necessary callbacks to mess with the clipboard contents. Then we're back to the desired default behaviour of mouse dragging updating the middle-button buffer. This setting will break any other Javascript scripts that attempt to intercept copy and paste commands, but that's probably a good thing; such scripts are almost always part of "copy protection" schemes.

1 comment

Tom Swiss
THANK YOU! This has been driving me mad.
Tom Swiss - 2014-05-23 22:56


(optional field)
(optional field)
Answer "bonobo" here to fight spam. ここに「bonobo」を答えてください。SPAMを退治しましょう!
I reserve the right to delete or edit comments in any way and for any reason.