Created
November 29, 2024 08:26
-
-
Save Strajk/915fa99e85208d2e148c385f9a568962 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Name: Disposable email | |
| // Description: Generate a disposable email address, open the inbox in the browser, and copy the email address to the clipboard | |
| // Acknowledgments: | |
| // - https://www.alfredforum.com/topic/4643-temporary-email-%E2%80%94-generate-disposable-email-inboxes/ | |
| import "@johnlindquist/kit" | |
| import { uniqueNamesGenerator, adjectives, animals, colors } from 'unique-names-generator'; | |
| // The ones with auto: true will copy the email address to clipboard, the ones with auto: false will not | |
| const providers = { | |
| "maildrop.cc": { name: "Maildrop", auto: true }, | |
| "harakirimail.com": { name: "Harakirimail", auto: true }, | |
| "incognitomail.co": { name: "Incognitomail", auto: false }, | |
| "temporarymail.com": { name: "Temporarymail", auto: false }, | |
| "mail.tm": { name: "Mail.tm", auto: false }, | |
| "dropmail.me": { name: "Dropmail", auto: false }, | |
| "guerrillamail.com": { name: "Guerrillamail", auto: false } | |
| }; | |
| let provider = await arg({ | |
| placeholder: `Select Provider`, | |
| choices: Object.entries(providers).map(([name, def]) => ({ | |
| name: def.name, | |
| description: def.auto ? `🤖 Auto-copies email to clipboard` : `🫵 Manually copy email from website`, | |
| value: name | |
| })) | |
| }); | |
| let def = providers[provider]; | |
| if (!def) throw new Error(`Invalid provider: ${provider}`); | |
| if (def.auto) { | |
| const desiredEmailName = uniqueNamesGenerator({ | |
| dictionaries: [adjectives, animals], | |
| length: 2, | |
| separator: '-', | |
| }); | |
| const email = `${desiredEmailName}@${provider}`; | |
| let url: string; | |
| if (provider === 'maildrop.cc') { | |
| url = `https://${provider}/inbox/?mailbox=${desiredEmailName}`; | |
| } else { | |
| url = `https://${provider}/inbox/${desiredEmailName}`; | |
| } | |
| await clipboard.writeText(email); | |
| await open(url); | |
| await notify(`Email: ${email} copied to clipboard`); | |
| } else { | |
| await open(`https://${provider}`); | |
| await notify(`Get the email address from the website`); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment