Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method match (clipboard.match(regex)) to check clipboard for pattern matching before reading - as it is done in iOS #199

Open
ErmachenkoBoris opened this issue Nov 8, 2023 · 1 comment

Comments

@ErmachenkoBoris
Copy link

ErmachenkoBoris commented Nov 8, 2023

Hi!
The clipboard is a powerful thing and it can be used to predict user actions - as it is already used in mobile devices.

Idea

In order for the user's data to be safe, you need to ask permission before reading.
But before asking, we could check the contents for the presence of a pattern - at the same time, we do not receive data, but only information(true/false) about whether the contents of the clipboard correspond to our pattern. This is already available in native mobile apps.

Suggestion

I suggest thinking about implementing this behavior in browsers. This will allow us to process such cases, for example - a user logged in to the Internet banking website with a phone number in the clipboard - we can immediately offer to make a money transfer to this number, saving the user time

Promise<boolean> match(RegExp reg);

Usage examples

This will allow us to process such cases, for example - a user logged in to the website with a phone number in the clipboard - we can immediately offer to make a money transfer to this number, saving the user time

    const phoneNumberReg = ^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}$;

    // ask only if necessary
    navigator.clipboard.match(phoneNumberReg).then(
        (res) => {
            if(res) {
                return navigator.clipboard.readText();
            }
         }
  );

Native Apps and Web Apps

Let's close the feature gap!

@ErmachenkoBoris
Copy link
Author

ErmachenkoBoris commented Nov 8, 2023

hi, @garykac (and other contributors, I don't know who it would be more correct to call)
what do you think about it?:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant