Skip to content

Instantly share code, notes, and snippets.

@lhns
Created June 9, 2022 14:15
Show Gist options
  • Save lhns/08e5be12fb7de8f3098dcde8aaf10096 to your computer and use it in GitHub Desktop.
Save lhns/08e5be12fb7de8f3098dcde8aaf10096 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name HN Favicons
// @version 0.3
// @license MIT
// @description Favicons for Hacker News
// @match https://*.ycombinator.com/*
// @grant GM.addElement
// ==/UserScript==
for(let link of document.links) {
if(!link.href.match("ycombinator.com") && !link.href.match("javascript:void") && link.firstChild.nodeName !== "IMG") {
const domain = new URL(link.href).hostname
const imageUrl = `https://icons.duckduckgo.com/ip3/${domain}.ico`
const container = document.createElement('span');
container.style.paddingRight = '0.25em';
container.style.paddingLeft = '0.25em';
link.prepend(container);
GM.addElement(container, 'img', {
src: imageUrl,
width: 12,
height: 12
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment