Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

favicon-thief

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

favicon-thief

Find the best favicon for a given URL.

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
2
Weekly downloads
 
Created
Source

favicon-thief

Find the best favicon for a given URL.

Powers https://websktop.com.

Version License Node version Vulnerabilities Build Test Prettier

Installation

npm install favicon-thief --save

API

getFavicons

Uses findFavicons to get all favicons that represent given URL. Uses node-fetch & puppeteer to crawl webpages.

  • Results are sorted - best first.
  • Favors vector images, square images, and large images (in that order).

It's a wrapper for findFavicons that provides fetch implementations.

import { getFavicons } from 'favicon-thief';

const favicons = await getFavicons('https://websktop.com');

console.log(JSON.stringify(favicons, null, 2));
// [
//   {
//     "sizes": [
//       {
//         "width": 144,
//         "height": 144
//       }
//     ],
//     "source": "html",
//     "url": "https://www.youtube.com/s/desktop/25bf5aae/img/favicon_144x144.png"
//   },
//   {
//     "sizes": [
//       {
//         "width": 96,
//         "height": 96
//       }
//     ],
//     "source": "html",
//     "url": "https://www.youtube.com/s/desktop/25bf5aae/img/favicon_96x96.png"
//   },
//   {
//     "sizes": [
//       {
//         "width": 48,
//         "height": 48
//       }
//     ],
//     "source": "html",
//     "url": "https://www.youtube.com/s/desktop/25bf5aae/img/favicon_48x48.png"
//   },
//   {
//     "sizes": [
//       {
//         "width": 32,
//         "height": 32
//       }
//     ],
//     "source": "html",
//     "url": "https://www.youtube.com/s/desktop/25bf5aae/img/favicon_32x32.png"
//   },
//   {
//     "sizes": [],
//     "source": "html",
//     "url": "https://www.youtube.com/s/desktop/25bf5aae/img/favicon.ico"
//   },
//   {
//     "sizes": [],
//     "source": "guess",
//     "url": "https://www.youtube.com/favicon.ico"
//   },
//   {
//     "sizes": [],
//     "source": "guess",
//     "url": "https://youtube.com/favicon.ico"
//   }
// ]

findFavicons

Finds all favicons that represent given URL.

  • Pass your own fetching function.
  • Results are sorted - best first.
  • Favors vector images, square images, and large images (in that order).
  • It never throws.
import { findFavicons } from 'favicon-thief';

const myFetch = async (url: string): string => {
  // bring your own fetching implementation - turn `url` into html here
  return {
    data: '<html><head><link rel="icon" href="icon.png" sizes="160x160"></head></html>',
    url, // return different url if there was a redirect
  };
};

const favicons = await findFavicons('http://example.com', myFetch);

console.log(JSON.stringify(favicons, null, 2));
// [
//   {
//     "sizes": [
//       {
//         "width": 160,
//         "height": 160
//       }
//     ],
//     "source": "html",
//     "url": "http://example.com/icon.png"
//   },
//   {
//     "sizes": [],
//     "source": "guess",
//     "url": "http://example.com/favicon.ico"
//   }
// ]

Keywords

FAQs

Package last updated on 25 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc