You are browsing as a guest. Sign up (or log in) to start making projects!

AttachGuard

  • 1 Devlogs
  • 1 Total hours

A simple Gmail extension that warns you when you mention an attachment but forget to add one. It scans your email for words like “attached” or “enclosed” and checks if a file is actually included. If not, it alerts you before sending so you can fix it, attach the file, or send anyway.

Open comments for this post

36m 44s logged

I started building AttachGuard, a Chrome extension for Gmail that helps prevent one of the most common email mistakes: forgetting to attach a file after mentioning it in the email. Before writing any functionality, I set up the project structure and created the manifest.json file, which tells Chrome important information about the extension, such as its name, version, icons, and which websites it should run on. I also configured it to inject my content script only when Gmail is open. After setting up the extension, I began writing the main logic inside my content script. The extension reads the text from the Gmail compose window and searches for common attachment-related phrases like “attached,” “enclosed,” and “resume attached.” If one of those phrases is detected, it then checks the Gmail interface to see whether a file has actually been attached before the email is sent. One of the biggest challenges I ran into was learning how Gmail’s interface works. I originally expected the compose window to already exist when the page loaded, but Gmail creates new compose windows dynamically without refreshing the page. Because of this, my script couldn’t detect newly opened emails. After researching different approaches, I learned about the MutationObserver API and used it to watch for new compose windows being added to the page. Once a new compose window appears, my extension automatically attaches the necessary event listeners. I also made sure the extension works whether someone clicks the Send button or uses the Ctrl/Cmd + Enter keyboard shortcut. Before the email is sent, AttachGuard checks for attachment keywords, looks for indicators that Gmail is displaying an uploaded attachment, and, if necessary, displays a confirmation dialog asking whether the user wants to send the email anyway or go back and attach the missing file. Working on this project has helped me learn much more about Chrome extensions, the purpose of the manifest.json file, DOM manipulation, event listeners, and observing dynamic web pages with JavaScript. There are still a lot of improvements I want to make, such as expanding the list of attachment keywords, reducing false positives, and improving how attachments are detected, but I’m excited that the core functionality is now working.

0
0
9

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…