From 0e5dab8f379d73b49cff5fc1b74c945049a0fba2 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Tue, 30 Jun 2026 23:04:07 +0700 Subject: [PATCH] Add bulk Gmail alias generation --- entrypoints/popup/App.tsx | 96 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/entrypoints/popup/App.tsx b/entrypoints/popup/App.tsx index a123fa5..0fd0723 100644 --- a/entrypoints/popup/App.tsx +++ b/entrypoints/popup/App.tsx @@ -46,6 +46,8 @@ const getAccountStorageKey = (email: string, suffix: string) => { function App() { const [baseEmail, setBaseEmail] = useState('your.email@gmail.com'); const [customTag, setCustomTag] = useState(''); + const [bulkTags, setBulkTags] = useState(''); + const [generatedBulkAliases, setGeneratedBulkAliases] = useState([]); const [recentAliases, setRecentAliases] = useState([]); const [copiedEmail, setCopiedEmail] = useState(null); const [isSettingsOpen, setIsSettingsOpen] = useState(false); @@ -395,15 +397,58 @@ function App() { } }; + const normalizeAliasTag = (tag: string) => + tag + .trim() + .toLowerCase() + .replace(/[^a-z0-9._-]+/g, '-') + .replace(/^[._-]+|[._-]+$/g, '') + .slice(0, 64); + + const parseBulkTags = (value: string) => + Array.from( + new Set( + value + .split(/[\n,;\t]+/) + .map(normalizeAliasTag) + .filter(Boolean) + ) + ); + const handleCustomGenerate = () => { if (!customTag.trim()) return; - const alias = generateAlias(customTag.trim()); + const alias = generateAlias(normalizeAliasTag(customTag)); if (alias) { copyToClipboard(alias); setCustomTag(''); } }; + const handleBulkGenerate = () => { + const aliases = parseBulkTags(bulkTags) + .map((tag) => generateAlias(tag)) + .filter((alias): alias is string => Boolean(alias)); + + setGeneratedBulkAliases(aliases); + + if (aliases.length > 0) { + copyToClipboard(aliases[0]); + } + }; + + const copyBulkAliases = async () => { + if (generatedBulkAliases.length === 0) return; + + try { + await navigator.clipboard.writeText(generatedBulkAliases.join('\n')); + setCopiedEmail('✓ Bulk aliases copied!'); + generatedBulkAliases.forEach(saveRecentAlias); + setTimeout(() => setCopiedEmail(null), 2000); + } catch (err) { + console.error('Failed to copy bulk aliases:', err); + } + }; + const handleKeyPress = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { handleCustomGenerate(); @@ -815,6 +860,55 @@ function App() { )} +
+
+ + comma, tab, semicolon, or newline +
+