Favicon Resolution Service (electron/favicon.ts)

xinyuan · apps/desktop/electron/favicon.ts · typescript · MIT
integration, infra, scraping, lang:typescript, fw:electron, tag:browser

An Electron main-process utility that scrapes and ranks website favicons from HTML and manifests. Use this to reliably fetch site icons while respecting privacy and CORS.

// Source: https://github.com/YUANGEGE1234/xinyuan | License: MIT | Copyright 2025 Nous Research
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Favicon resolution, the thorough way.
 *
 * `<origin>/favicon.ico` answers for maybe half the web. Everyone else
 * declares their marks in the page head (`<link rel="icon">`, apple-touch,
 * SVG mask icons) or in a web app manifest, at paths that are frequently
 * hashed build artifacts on a CDN — unguessable. So: read the page, collect
 * every declared icon, rank them, and only then fall back to the well-known
 * paths.
 *
 * Only ever the site's own marks. A public icon service would answer for the
 * hosts that hide behind a bot wall, but asking one means telling a third
 * party which connector a user is wiring up — s

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key