mirror of
https://github.com/bitwarden/clients.git
synced 2026-07-10 21:03:56 +08:00
* Add generate command * Add JSDoc * Minor improvements * Remove unneeded comment * Make some properties optional * Remove main.background.ts changes * One more * Lint * Make all but length optional * Address PR feedback * Move generate command code to command * Address PR feedback * Use new alarm scheme * Let feature handle state keys Moves to a feature folder and creates clipboard-module level state handler functions. StateService is being paired down to storage routing, so we are handling storage specifics in-module. Co-authored-by: Justin Baur <justindbaur@users.noreply.github.com> Co-authored-by: Daniel Smith <djsmith85@users.noreply.github.com> * Missed some changes Co-authored-by: Matt Gibson <mgibson@bitwarden.com> Co-authored-by: Justin Baur <justindbaur@users.noreply.github.com> Co-authored-by: Daniel Smith <djsmith85@users.noreply.github.com>
24 lines
533 B
TypeScript
24 lines
533 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);
|