Created
June 9, 2022 14:15
-
-
Save lhns/08e5be12fb7de8f3098dcde8aaf10096 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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