corbindavenport / link-cleaner

Progressive Web App for removing tracking code and other variables from web links
https://linkcleaner.app
GNU General Public License v3.0
128 stars 13 forks source link

Add option to auto copy to clipboard #16

Open corbindavenport opened 2 years ago

corbindavenport commented 2 years ago

Suggested here: https://twitter.com/LinkofHyrule89/status/1573131451054301185

Not all browsers support writing to the clipboard without a gesture (e.g clicking a button): https://github.com/w3c/clipboard-apis/issues/182

Chromium will also soon require granting a permission before writing to the clipboard without a gesture: https://chromium.googlesource.com/chromium/src/+/10300ac7da93a7e322274f1e

Enabling the setting will probably require asking for a permission first, and only saving the setting if the permission is granted. There can also be a message above the share buttons that says if the result was successfully copied to the clipboard or not. Will need to test in Chrome Canary for future-proofing.

vonDubenshire commented 1 year ago

Man, what happened to Chrome's clipboard changes that they added in late 2019 until 2021?

I'm assuming some sort of security issue, because they allowed an icon in the share sheet after a copy function that you could then "send to a device" etc.

It vanished by summer 2021 as I only saw references to the development of unsanitized clipboard and the "pickling" functionality.

Funny enough it still exists inside Google Lens on Android if you use the Text feature, can copy to my PC.

corbindavenport commented 1 year ago

If you mean Chrome on Android, it switched to a custom share sheet somewhere around v85 in 2020: https://www.androidpolice.com/2020/08/26/chrome-85-enables-64-bit-support-on-android-10-replaces-the-share-sheet-and-more-apk-download/

The normal Android share sheet has easier access to clipboard and other apps, I really don't like Chrome switching to its own (worse) menu. Google has probably added and removed buttons from the menu over time.

corbindavenport commented 4 months ago

This is implemented now as an opt-in setting, but currently requires the Clipboard API, and the error catching isn't fully working yet. Gonna do more testing before closing.

In Firefox for example, the popup confirmation appears when shortening a link with the url parameter, but there's an error in the console:

image