1
0
mirror of https://github.com/XFox111/PasswordGeneratorExtension.git synced 2026-04-22 08:08:01 +03:00
Files
PasswordGeneratorExtension/entrypoints/content.ts
T
Eugene Fox 3ecb6c4a31 Major 4.0 (#380)
- Migrated to WXT
- Migrated to NPM
- Added Insert & copy action
- Added ESLint
2024-09-25 16:19:12 +03:00

23 lines
610 B
TypeScript

export default defineContentScript({
matches: ["<all_urls>"],
runAt: "document_idle",
main()
{
console.log("Password Generator: script loaded");
browser.runtime.onMessage.addListener((message: string, _, sendResponse) =>
{
if (message === "probe")
// @ts-expect-error sendResponse has incorrect signature
sendResponse(document.querySelectorAll("form input[type=password]").length);
else
document
.querySelectorAll("form input[type=password]")
.forEach(el => {
(el as HTMLInputElement).value = message;
(el as HTMLInputElement).focus();
});
});
},
});