clients/apps/browser/src/content/misc-utils.ts
Justin Baur 1d1986e5e3
[PS-817] Add Generate Password Shortcut to MV3 (#3575)
* 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>
2022-10-18 13:03:09 -04:00

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);