- From: Boris <notifications@github.com>
- Date: Wed, 08 Nov 2023 11:17:04 -0800
- To: w3c/clipboard-apis <clipboard-apis@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/clipboard-apis/issues/199@github.com>
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](https://developer.apple.com/documentation/uikit/uipasteboard#3671022). ## 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! -- Reply to this email directly or view it on GitHub: https://github.com/w3c/clipboard-apis/issues/199 You are receiving this because you are subscribed to this thread. Message ID: <w3c/clipboard-apis/issues/199@github.com>
Received on Wednesday, 8 November 2023 19:17:11 UTC