The Assistant is an MV3 Chrome extension that lets you grab the current tab’s headlines, email them to yourself via Gmail, and chat with a LLaMA model served through HuggingFace – all from the browser toolbar.
- Collects
<h1>,<h2>, and<h3>text from the active page with a single click. - Sends the captured headlines to Gmail using OAuth tokens obtained through
chrome.identity. - Provides a prompt box to query the HuggingFace Router (LLaMA 3.2 instruct model by default) and displays the reply in the popup.
- Stores user secrets (HuggingFace token, optional recipient overrides) using
chrome.storage.local. - Ships with an environment config (
env.js) so you can customize default recipients, model IDs, and API hosts without touching the core code.
| Path | Purpose |
|---|---|
manifest.json |
Chrome extension manifest (MV3) – permissions, OAuth client, scripts. |
background.js |
Service worker handling Gmail sends and HuggingFace requests. |
content_script.js |
Extracts headings from the current tab on demand. |
popup.html, popup.js |
Toolbar UI for emailing headlines, chatting with LLaMA, and saving tokens. |
env.js |
Environment-style config with defaults for email, models, and API URLs. |
Keys / client_secret_*.json |
Example secrets (do not ship these – rotate and replace with your own). |
- Google Chrome (or Chromium-based browser) with extension developer mode enabled.
- Google Cloud project with the Gmail API enabled.
- HuggingFace account and API token with access to the chosen model.
Update env.js with values appropriate for your environment:
const ENV_CONFIG = {
defaultEmailRecipient: 'your.email@example.com',
defaultHfApiKey: '', // optional development key
hfApiBaseUrl: 'https://router.huggingface.co/novita/v3/openai/chat/completions',
hfModelId: 'meta-llama/llama-3.2-3b-instruct',
gmailSubjectPrefix: 'Page Headlines from'
};Recommendations
- Keep
defaultHfApiKeyempty in shared code; enter the real key through the popup at runtime. - Add
env.jsto your.gitignore(and provideenv.template.js) if you plan to distribute or collaborate.
Chrome extensions require a dedicated OAuth client tied to the extension ID.
- Load the unpacked extension once (next section) and note the extension ID from
chrome://extensions. - In Google Cloud Console:
- Create or select a project.
- Set up the OAuth consent screen (External or Internal).
- Add the Gmail scope:
https://www.googleapis.com/auth/gmail.send. - Enable the Gmail API (
APIs & Services → Library → Gmail API → Enable). - Create OAuth credentials (
APIs & Services → Credentials → Create Credentials → OAuth client ID → Chrome App) and paste your extension ID.
- Replace the
oauth2.client_idinmanifest.jsonwith the new client ID. - Reload the extension to pick up the manifest change.
When testing, add your Google account as a test user on the OAuth consent screen to avoid verification warnings.
- Open Chrome and navigate to
chrome://extensions. - Toggle Developer mode on (top-right corner).
- Click Load unpacked and select the project directory.
- After loading, hit Reload on the card whenever you change source files.
- Click the extension icon to open the popup.
- In Settings, paste your HuggingFace API token (unless
env.jsalready supplied one) and click Save Key. - To email headlines:
- Stay on the page you want to summarize.
- Click Email Headlines.
- The first time, Chrome will launch a Google sign-in window; accept the Gmail
sendscope. - If successful, the email is sent via
gmail.users.messages.send.
- To chat with LLaMA:
- Enter a prompt in Get Prompting.
- Click Ask Your LLM.
- The popup shows the HuggingFace router response, or an error if the API request fails.
- Keep secrets, default recipients, model IDs, and API endpoints in
env.js. These can change per install and aren’t enforced by Chrome. - The manifest should contain only static extension metadata: name, version, permissions, host permissions, and the OAuth client ID. Chrome reads it at load time and will ignore dynamic substitutions.
- Never commit real API keys or OAuth client secrets; rotate any keys already in the repo and replace them with placeholders.
-
OAuth errors / bad client ID
Clear cached tokens via the background console (chrome://extensions → The Assistant → service worker) and re-runchrome.identity.getAuthToken, or remove cached tokens withchrome.identity.removeCachedAuthToken. Ensure the manifest’s client ID matches the one in Google Cloud. -
HuggingFace 401 / 400 errors
Confirm the saved token is valid and has access to the requested model. AdjusthfApiBaseUrlandhfModelIdinenv.jsto match the endpoint you’re allowed to use. -
Emails sent but popup shows error
The Gmail API may accept the send request even if the response handling throws. Inspect Chrome’s background console to see the exact error payload; adjust error handling or subject configuration accordingly.