Skip to content

Instantly share code, notes, and snippets.

@overflowy
Last active July 12, 2023 13:12
Show Gist options
  • Save overflowy/bf5d9aedffcd46242a253a3ddf1271b4 to your computer and use it in GitHub Desktop.
Save overflowy/bf5d9aedffcd46242a253a3ddf1271b4 to your computer and use it in GitHub Desktop.
Favicons for HN
// ==UserScript==
// @name Favicons for HN
// @namespace Violentmonkey Scripts
// @match https://*.ycombinator.com/*
// @grant none
// @version 1.0
// @author [email protected]
// @description 12/19/2022, 9:34:53 AM
// @inject-into content
// ==/UserScript==
var favicons = document.getElementsByClassName("favicon");
if (!(favicons.length > 0)) {
const articleLinks = document.querySelectorAll(".titleline > a");
for (let link of articleLinks) {
const domain = new URL(link.href).hostname;
const imageUrl = `https://icons.duckduckgo.com/ip3/${domain}.ico`;
const imgEl = document.createElement("img");
imgEl.src = imageUrl;
imgEl.className = "favicon";
imgEl.width = 14;
imgEl.height = 14;
imgEl.style.paddingRight = "0.25em";
imgEl.style.paddingLeft = "0.25em";
link.style.alignItems = "center";
link.style.display = "inline-flex";
link.style.justifyContent = "center";
link.prepend(imgEl);
}
}
@polyrabbit
Copy link

Alternative - https://hackernews.betacat.io/

with:

  • favicon
  • summary
  • illustration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment