fivem icon indicating copy to clipboard operation
fivem copied to clipboard

feat(extra-natives-five): Add COPY_TEXT_TO_CLIPBOARD

Open Doxoh opened this issue 6 months ago • 18 comments

Goal of this PR

The possiblity to copy text into the clipboard of the player.

How is this PR achieving the goal

By adding the native COPY_TEXT_TO_CLIPBOARD

This PR applies to the following area(s)

FiveM

Successfully tested on

Latest game build: 3258 but works for all

Platforms: Windows

Checklist

  • [x] Code compiles and has been tested successfully.
  • [x] Code explains itself well and/or is documented.
  • [x] My commit message explains what the changes do and what they are for.
  • [x] No extra compilation warnings are added by these changes.

Doxoh avatar May 24 '26 22:05 Doxoh

Check failed because of Error downloading object: vendor/libnode/bin/libnode22.dll (e03bef1): Smudge error: Error downloading vendor/libnode/bin/libnode22.dll (e03bef17df5371aa2947bbf43e94d6e615c137a163c76749075cb02239a04c6f): batch response: This repository exceeded its LFS budget. The account responsible for the budget should increase it to restore access.

Doxoh avatar May 24 '26 22:05 Doxoh

Check failed because of Error downloading object: vendor/libnode/bin/libnode22.dll (e03bef1): Smudge error: Error downloading vendor/libnode/bin/libnode22.dll (e03bef17df5371aa2947bbf43e94d6e615c137a163c76749075cb02239a04c6f): batch response: This repository exceeded its LFS budget. The account responsible for the budget should increase it to restore access.

just ignore the checks, they've been broken for a while, the libnode binaries still need to be migrated to a cdn

ook3D avatar May 24 '26 22:05 ook3D

for now you can do

set GIT_LFS_SKIP_SMUDGE=1
git clone https://github.com/citizenfx/fivem.git

This will close the repo without the LFS files. Then you need to download these manually from https://github.com/citizenfx/libnode/releases/tag/v22.22.0 and place them in the vendor/libnode/bin folder

Gogsi avatar May 24 '26 22:05 Gogsi

yeah I know, thanks. Local its working :) Was an Information for this pr :)

Doxoh avatar May 24 '26 22:05 Doxoh

Hi, to also give some feedback in terms of security: I know, this native could be very useful, tho malicious server could abuse it and constantly overwrite the users clipboard like a wallet clipper for example :/

divocbn avatar May 24 '26 23:05 divocbn

Hi, to also give some feedback in terms of security: I know, this native could be very useful, tho malicious server could abuse it and constantly overwrite the users clipboard like a wallet clipper for example :/

what if this is not silent and fivem displays a small warning that it was overwritten or so?

lLukDreams avatar May 25 '26 08:05 lLukDreams

To anyone who thinks this can be used in a malicious way

This thing already exists with Javascript so nothing actually changes except having a shorter way of copying something to the Client's clipboard

AngeloneISL avatar May 25 '26 09:05 AngeloneISL

To anyone who thinks this can be used in a malicious way

This thing already exists with Javascript so nothing actually changes except having a shorter way of copying something to the Client's clipboard

With the difference that the pages request a clipboard permission. Adding this without a dedicated clipboard permission would involve more risk.

FabianTerhorst avatar May 25 '26 09:05 FabianTerhorst

what if this is not silent and fivem displays a small warning that it was overwritten or so?

Sounds to me like a good idea, basically the same as the url confirmation modal that radium made, @FabianTerhorst what do you think about it?

divocbn avatar May 25 '26 11:05 divocbn

I found a better way.

The server need to set sv_requiredClipboardPermission 1 in server.cfg. Then by connecting to server, the client ask prechecks like this.

The User get a mask to accept it or not: image

Doxoh avatar May 25 '26 15:05 Doxoh

What is the purpose of this native at all? I cant think of a use-case

yorick2002 avatar May 25 '26 19:05 yorick2002

Hi, to also give some feedback in terms of security:

I know, this native could be very useful, tho malicious server could abuse it and constantly overwrite the users clipboard like a wallet clipper for example :/

They can already do this via CEF, having it permission gates would make sense though.

AvarianKnight avatar May 25 '26 19:05 AvarianKnight

I found a better way.

The server need to set sv_requiredClipboardPermission 1 in server.cfg.

Then by connecting to server, the client ask prechecks like this.

The User get a mask to accept it or not:

image

I don't think this properly addresses the issue, something similar to how voice permission is requested in CEF would make more sense.

AvarianKnight avatar May 25 '26 19:05 AvarianKnight

What is the purpose of this native at all? I cant think of a use-case

I can think of multiple, mainly dev tools. Currently if I want to copy coordinates I have to go through cef, with this I could just copy to clipboard and not need anything extra.

AvarianKnight avatar May 25 '26 19:05 AvarianKnight

What is the purpose of this native at all? I cant think of a use-case

I can think of multiple, mainly dev tools. Currently if I want to copy coordinates I have to go through cef, with this I could just copy to clipboard and not need anything extra.

Oh yeah thats true forgot about that 👍

yorick2002 avatar May 25 '26 19:05 yorick2002

yeah, thats the reason why we want it

Doxoh avatar May 25 '26 20:05 Doxoh

Looks useful ❤️

frostfire575 avatar May 25 '26 23:05 frostfire575

@radium-cfx what do u think about this?

Doxoh avatar Jun 05 '26 10:06 Doxoh