How ashiqfury/pagepilot-summariser works
Purpose and Runtime
PagePilot Summariser is a Manifest-based Chrome extension that extracts readable text from the active webpage, sends it to a user-configured OpenAI-compatible chat-completions endpoint, and displays a bullet summary in the extension popup. Its browser integration and permissions boundary are defined in manifest.json.
Extension Entry Points
• Webpage-side extraction starts in content.js, injected into supported pages under manifest control.
• The user initiates work through the popup UI in popup.html; popup.js is the primary orchestration controller.
• Persistent provider configuration is managed by the options UI: options.html and options.js.
• Shared AI request and response-normalization logic resides in summarizer.js.
Page Content Extraction Boundary
content.js operates in the target page’s DOM context. It identifies likely readable containers (article, main, common content elements, then body fallback), strips whitespace and common subscription/noise patterns, and returns cleaned text through Chrome extension messaging.
This isolates untrusted, variable webpage structure from popup and provider logic. The content script should not own credentials, rendering, or remote API calls.
Popup Orchestration and Presentation
popup.js coordinates the end-to-end request after the user chooses to summarize:
1. Resolve the active tab and message content.js for extracted content.
2. Load endpoint, model, and API key from Chrome storage.
3. Pass content plus settings to the summarization layer.
4. Render normalized summary bullets and expose clipboard copy behavior.
popup.html provides the interaction surface, while styles.css is the shared presentation layer. The popup is the key control boundary between browser APIs, user state, and AI processing.
AI Provider Integration
summarizer.js builds the concise summarization prompt, invokes the configured OpenAI-compatible chat-completions API, handles provider failures/configuration mistakes, and converts returned model text into displayable bullets.
External requests are intentionally constrained by manifest.json host permissions, currently covering OpenRouter and OpenAI. Adding another compatible provider requires both a configurable endpoint and a corresponding host permission update.
Settings and Credential Flow
options.js persists the provider endpoint, model identifier, and API key through Chrome storage; options.html is the configuration entry point. The popup reads these values at summary time rather than embedding provider configuration in page scripts.
Credentials therefore remain extension-managed and are not passed into webpage DOM execution. The remote AI provider receives only the configured request metadata and extracted page text.
Primary Control Flow
User click in popup.html → popup.js queries active tab → message to content.js → cleaned text returned to popup → settings loaded from Chrome storage → summarizer.js calls OpenRouter/OpenAI-compatible endpoint → response transformed to bullets → popup renders and optionally copies output.
Failure points are page-script availability, empty/noisy extraction, missing settings, provider authentication/endpoint mismatch, network errors, and nonconforming provider responses.
Main entry points: popup.js Popup Controller · content.js Content Extractor · summarizer.js Summarization Layer · manifest.json Extension Manifest
Components 12
Chrome Extension
Browser-managed UI, scripts, storage, and permission boundary.
- Extension Manifest · Defines injection, permissions, and allowed provider hosts.
manifest.json - Popup UI · User entry point and summary display.
popup.html - Popup Controller · Coordinates tab messaging, settings, summarization, rendering, and copy.
popup.js - Content Extractor · Extracts and cleans readable text in the target page DOM.
content.js - Chrome Storage · Persists endpoint, model, and API key.
- Options UI · Provider configuration entry point.
options.html - Settings Controller · Saves provider settings to extension storage.
options.js - Summarization Layer · Builds prompts, calls chat completions, handles failures, and normalizes bullets.
summarizer.js - Shared Styles
styles.css - Normalized Bullets · Displayable summary returned from the AI layer.
AI Provider
- OpenAI-Compatible API · Configured OpenRouter or OpenAI endpoint.
Other components
- Active Page DOM · Variable webpage content isolated from credentials and provider calls.
Connections 15
- Extension Manifest → Content Extractor: injects on supported pages
- Extension Manifest → OpenAI-Compatible API: host permissions · Restricts permitted remote provider hosts.
- Popup UI → Popup Controller: summarize action
- Shared Styles → Popup UI: styles
- Popup Controller → Content Extractor: message active tab
- Content Extractor → Active Page DOM: reads readable content
- Content Extractor → Popup Controller: returns cleaned text
- Options UI → Settings Controller: settings submission
- Settings Controller → Chrome Storage: persists endpoint, model, key
- Popup Controller → Chrome Storage: loads settings
- Popup Controller → Summarization Layer: content and settings
- Summarization Layer → OpenAI-Compatible API: chat-completions request · Sends extracted text and configured request metadata.
- OpenAI-Compatible API → Summarization Layer: model response
- Summarization Layer → Normalized Bullets: normalizes response
- Normalized Bullets → Popup Controller: render and copy