Nameless
Nameless copied to clipboard
Change copy function to Clipboard API
As the execCommand is deprecated and not recommended, this is a remake of it. Simple, small, also used in
https://github.com/NamelessMC/Nameless/blob/848a2e33af959ce8cc59b70a5a0e3614706352d7/error.tpl#L384
navigator only exists when HTTPS is enabled, so this will not work on HTTP only sites
navigatoronly exists when HTTPS is enabled, so this will not work on HTTP only sites
But then even, should we remove it from error.tpl or what?
No, as you can see in the error.tpl file we check that it [navigator] is not undefined first, and then use it if it exists. Otherwise it falls back to the other way
On Wed, Aug 17, 2022 at 23:46 PadowYT2 @.***> wrote:
navigator only exists when HTTPS is enabled, so this will not work on HTTP only sites
But then even, should we remove it from error.tpl or what?
— Reply to this email directly, view it on GitHub https://github.com/NamelessMC/Nameless/pull/3028#issuecomment-1219062984, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGG43DCTT3BIHLVWGXUAGJ3VZXE4PANCNFSM56P5PAJA . You are receiving this because you commented.Message ID: @.***>
Should we be using deprecated functions at all? I have seen sites do something like this instead:
if (window.isSecureContext) {
navigator.clipboard.writeText(url);
// Display "URL copied to clipboard" toast
} else {
// Create popup or toast with the URL, with a message that it should be copied manually
}
Looks like there are some other places in the codebase that still use execCommand, if you could fix all of those, and use Derks suggestion of window.isSecureContext instead of navigator.clipboard !== undefined, that would be great.
Being done in new PR alongside other changes