How nikhilsearch/google-sheet-email-extractor works
Project type and purpose
• This is a Google Apps Script “add-on” for Google Sheets.
• Purpose: provide a custom menu in a spreadsheet to extract email addresses either from URLs in cells or from arbitrary cell text.
File structure
• Top-level files:
• Email extrator code V3.gs – the entire script.
• README.md – documentation.
• No separate frontend/backend directories; it’s a single-file serverless script running in Google’s Apps Script environment.
README for additional insights
• Custom menu named “Email Extractor” with two actions:
a. Extract from URLs in Column A → outputs to Column B.
b. Extract from a specified cell’s text → shows an alert.
• Uses built-in UrlFetchApp and SpreadsheetApp services.
• Handles standard and obfuscated email formats via regex.
Components and interactions
a. Main components:
1. Google Sheets UI (custom menu entry)
2. Apps Script Runtime (serverless environment)
3. Script Functions:
– onOpen() → adds menu
– extractFromUrls() → fetch + parse + write to sheet
– extractFromCellText() → prompt + parse + show alert
4. External HTTP Service (web pages fetched via UrlFetchApp)
5. Regex Parser (within extract functions)
6. Spreadsheet Data (cells A and B)
b. Relationships and data flow:
1. User clicks menu → Apps Script Runtime triggers onOpen or extraction function.
2. extractFromUrls reads cell values via SpreadsheetApp, loops URLs → UrlFetchApp sends HTTP GETs → receives HTML responses → regex extracts email addresses → SpreadsheetApp writes results back.
3. extractFromCellText prompts user for a cell reference → reads that cell → regex extracts emails → shows results in an alert dialog.
c. Architectural patterns/design principles:
• Single responsibility: each function handles one workflow.
• Layered approach: UI layer (menu + prompts), service layer (UrlFetchApp), processing layer (regex), persistence layer (SpreadsheetApp).
d. Key technologies/frameworks/libraries:
• Google Apps Script Services: SpreadsheetApp, UrlFetchApp, Ui.
• JavaScript Regex for email extraction.
Detail
• Both workflows (URLs vs. cell text) in parallel branches.
• Triggers (onOpen event) that add the menu.
• Denote user interactions (menu click, prompt, alert).