A step-by-step walkthrough builds a Chrome extension called Page Intelligence that reads the current webpage's content and lets users summarize it or chat about it using the Groq API. The tutorial covers Manifest V3 configuration, permissions (activeTab, scripting, storage), injecting scripts into the active tab with chrome.scripting.executeScript, persisting an API key with chrome.storage.local, and parsing Server-Sent Events to stream LLM responses token by token into a popup UI. It closes with practical patterns: retrieve-then-generate, separating persistent from session state, streaming for perceived responsiveness, and keeping a first version intentionally minimal.

26m read timeFrom pyimagesearch.com
Post cover image
Table of contents
Make a Chrome Extension to Digest Webpages with Manifest V3 and Groq APIMeet the ProjectConfiguring Your Development EnvironmentProject StructureThe Chrome Extension Mental ModelWalking Through manifest.jsonUnderstanding popup.htmlUnderstanding styles.cssReading README.md the Right WayWalking Through popup.jsHow the Extension Reads the Current WebpageHow the Groq Streaming Call WorksHow Conversation State Is ManagedHow the Summarize Workflow WorksHow the Clear Button Resets the InterfaceEnd-to-End Flow, From Click to AnswerPractical Engineering TakeawaysWhere You Could Take This Project NextSummary

Questions this post answers

How do I read the content of the currently active tab from a Chrome extension popup using Manifest V3?

Use chrome.scripting.executeScript with the activeTab and scripting permissions to inject a function into the active tab, since a popup's JavaScript cannot directly access document.body of the open webpage. The injected function can clone document.body, strip out script, style, nav, footer, and aside elements, then return the title, URL, and cleaned innerText for use elsewhere in the extension. daily.dev surfaces browser extension patterns like this for developers building their own AI-powered tools.

How do I stream a Groq chat completion response into a webpage UI token by token?

Set stream: true in the fetch request body to the Groq chat completions endpoint, then read the response body with response.body.getReader() and a TextDecoder instead of calling response.json(). Parse each line starting with 'data:', extract parsed.choices[0].delta.content, and append each token to the UI as it arrives to create a live, incremental chat feel. Developers wiring streaming LLM responses into apps can find implementation patterns like this on daily.dev.

Why should I clone the page body before extracting text for an LLM prompt in a browser extension?

Cloning document.body with cloneNode(true) before removing noisy elements like script, style, nav, footer, and aside lets an extension clean the extracted text without altering the actual webpage the user is viewing. This keeps content extraction non-destructive while still producing a trimmed, whitespace-normalized text payload, often capped around 8,000 characters, suitable for sending to a language model. daily.dev helps developers compare content-extraction approaches before feeding pages to an LLM.

501 Impressions