mirror of
https://github.com/bitwarden/browser.git
synced 2024-06-20 09:35:22 +02:00
* [deps] Autofill: Update prettier to v3 * prettier formatting updates --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
24 lines
537 B
TypeScript
24 lines
537 B
TypeScript
import { TabMessage } from "../../types/tab-messages";
|
|
|
|
async function copyText(text: string) {
|
|
await window.navigator.clipboard.writeText(text);
|
|
}
|
|
|
|
async function onMessageListener(
|
|
msg: TabMessage,
|
|
sender: chrome.runtime.MessageSender,
|
|
responseCallback: (response: unknown) => void,
|
|
) {
|
|
switch (msg.command) {
|
|
case "copyText":
|
|
await copyText(msg.text);
|
|
break;
|
|
case "clearClipboard":
|
|
await copyText("\u0000");
|
|
break;
|
|
default:
|
|
}
|
|
}
|
|
|
|
chrome.runtime.onMessage.addListener(onMessageListener);
|