Clipboard API: Enable `copy` event simulation with user's express permission (domain-wide)?

It appears that the only way to trigger a `copy` event programmatically is
to use `document.execCommand('copy')`, which most browsers prevent:

http://www.w3.org/TR/clipboard-apis/#integration-with-other-scripts-and-events

What about enabling so enabling semi-restricted programmatic clipboard
injection on a page if the user grants their express permission via a
once-per-domain security prompt (similar to the Geolocation API)?  IOW,
given a user's express permission to the origin and following a user's
pointer event or keyboard interaction, I would like to be able to simulate
the `copy` event (and the `beforecopy` event, if practical).

I'm not quite sure how far this will go as "clipboard poisoning" is always
a real concern.  In fact, I understand that better than most, since my desire
to get such an adaptation to the Clipboard API spec is the direct result of
my work as the co-maintainer of the popular
ZeroClipboard<https://github.com/zeroclipboard/ZeroClipboard> library
(used by GitHub, bit.ly, and many other sites).  Jon and I would like
nothing better than to eliminate ZeroClipboard's dependency on
Flash<https://github.com/zeroclipboard/ZeroClipboard/issues/171> but
that is unattainable given the current restrictions of this spec.

If Flash doesn't live on for anything else, it may well live on longer than
it should for its unmatched ability to do programmatic clipboard
injection<http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/Clipboard.html#setData()>
after
a user's click or keypress.  :(

Thoughts?


Sincerely,
    James Greene
    http://jamesgreene.net/

Received on Friday, 12 July 2013 19:58:24 UTC