userscripts icon indicating copy to clipboard operation
userscripts copied to clipboard

Deprecate `GM.setClipboard` API

Open ACTCD opened this issue 1 year ago • 4 comments

Since document.execCommand() has been deprecated and has unstable behavior in iOS Safari (https://github.com/quoid/userscripts/issues/285).

the clipboard can only be accessed if the user then explicitly interacts with the platform UI (ref)

We believe that in most cases, accessing the clipboard should be included in the user interaction behavior.

So we encourage using the new Clipboard API directly, and the GM.setClipboard API will no longer needed.

We plan to deprecate it in the future unless we receive use cases sufficient to consider extending support. Maybe add a deprecation prompt in v5.0 and then remove in the v6.0.

ACTCD avatar May 14 '24 17:05 ACTCD

If the commands already have a replacement (as is the case for this one), maybe they could be pre-deprecated by marking them as deprecated in the readme already, with the alternate API being listed? That way users would at least not be incentivised to use those APIs for new snippets.

masklinn avatar Oct 26 '24 11:10 masklinn

@masklinn Yes, that's what we're going to do.

ACTCD avatar Oct 26 '24 11:10 ACTCD

Wouldn't this go against compatibility with userscripts that work in, say, Violentmonkey?

Can't it be reimplemented with or be an alias of the modern API?

atnbueno avatar Jul 11 '25 16:07 atnbueno

Wouldn't this go against compatibility with userscripts that work in, say, Violentmonkey?

This "compatibility" is broken and deprecated by upstream and we cannot resolve it.

Can't it be reimplemented with or be an alias of the modern API?

No, it only leads people to mistakenly think that it works the way it was, but that's not true.

People have to read the documentation for the new API and use it as required conditions.

ACTCD avatar Jul 11 '25 16:07 ACTCD