Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Startpage AI Search Results Summarizer

A Deno-built, installable Violentmonkey userscript for Startpage web-result pages. It retrieves the first configured number of ordinary web results through Jina Reader, sends successful source Markdown to an OpenAI-compatible /v1/chat/completions API, and renders a sanitised, citation-restricted answer above the results.

Build

The project intentionally uses Deno only. It has no Node, npm, pnpm, or Bun project commands.

deno task build

This produces dist/startpage-ai-summary.user.js; install that file through Violentmonkey.

Deno resolves the pinned npm: dependencies declared in deno.json as part of its own dependency system. nodeModulesDir: "auto" is set because esbuild resolves application imports using its Node-compatible resolver; Deno creates and manages the local node_modules/ directory automatically. Do not use npm, pnpm, Bun, or Node commands. The dependencies are bundled into the generated userscript, which has no runtime CDN imports or @require dependencies.

Source layout

  • src/startpage-ai-summary.ts — application lifecycle, UI state, hotkey, and orchestration
  • src/settings.ts — Violentmonkey Values schema/defaults
  • src/startpage.ts — narrowly scoped Startpage query/result extraction
  • src/network.ts — Jina and OpenAI requests, cancellation, concurrency
  • src/prompt.ts — source-delimited model prompt
  • src/render.ts — markdown sanitisation, citation reconstruction, usage cost
  • src/styles.ts — isolated spai-* styling
  • src/types.ts — shared types

Configuration

Open Violentmonkey's dashboard, select this script, then use its Values storage to set one settings object. The values are held by Violentmonkey's extension storage and are not available to Startpage page JavaScript. Do not enter the API key anywhere in Startpage.

Example:

{
  "openaiBaseUrl": "https://api.openai.com",
  "openaiApiKey": "sk-...",
  "openaiModel": "gpt-5.4",
  "jinaApiKey": "jina_...",
  "jinaEngine": "cf-browser-rendering",
  "resultLimit": 8,
  "maxCharsPerResult": 12000,
  "maxConcurrentJinaRequests": 8,
  "jinaTimeoutMs": 4000,
  "openaiTimeoutMs": 10000,
  "maxCompletionTokens": 2000,
  "hotkey": "Alt+A",
  "showUsageAndCost": true,
  "inputPricePerMillionUsd": 0,
  "outputPricePerMillionUsd": 0
}

The script’s reset menu command writes the defaults, which can be used to initialize the Value. Its defaults are the values above except openaiApiKey, openaiModel, and jinaApiKey, which are empty. jinaEngine defaults to cf-browser-rendering and can be changed in the settings object.

Endpoint permission

The metadata initially grants privileged cross-origin access only to r.jina.ai and api.openai.com. You may change openaiBaseUrl through Violentmonkey Values to any HTTPS OpenAI-compatible provider. To make that work, explicitly add the provider hostname as another @connect line in build.ts, rebuild, and reinstall the generated userscript. The script does not contain an API-host allowlist beyond Violentmonkey's @connect permission.

Security behavior

  • API credentials are read only with GM_getValue; they are not put into DOM nodes, attributes, page storage, URLs, console logs, or errors shown in the page.
  • Result URLs are parsed, and only http: and https: results are selected. Jina requests always use the fixed https://r.jina.ai/ origin. When configured, jinaApiKey is sent only to that origin as Authorization: Bearer …; Jina requests always send DNT: 1, X-Retain-Images: none, and X-Return-Format: markdown, while X-Engine uses the configurable jinaEngine.
  • The answer is parsed by markdown-it with raw HTML disabled and then sanitised by DOMPurify with a restrictive tag/attribute allowlist.
  • No model-provided links or images are rendered. Only valid [^N] citation markers become links, and their destinations are reconstructed exclusively from the selected Startpage result URL for source N.
  • The script adds only its own spai-* UI nodes. It identifies the Startpage Web results root from .w-gl-attribution and result title links from a[data-testid="gl-title-link"].

Notes

Jina receives selected result URLs. The configured OpenAI provider receives the query and retrieved source text. Source failures are tolerated: the summary is generated from the successful retrievals only, and the panel reports the retrieved count.

About

AI summary userscript for startpage.com search engine

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages