Created
April 20, 2022 16:00
-
-
Save goldbattle/695f869e43fe8d0e628061cb96ed0049 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 | |
// @namespace https://campital.xyz/ | |
// @version 0.3.1 | |
// @license MIT | |
// @description Favicons for Hacker News | |
// @match https://*.ycombinator.com/* | |
// @grant GM.addElement | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
for (let link of document.querySelectorAll('.titlelink')) { | |
let domain; | |
try { | |
domain = new URL(link.href).hostname; | |
} catch(err) { | |
continue; | |
} | |
const imageUrl = `https://icons.duckduckgo.com/ip3/${domain}.ico`; | |
const container = document.createElement('span'); | |
container.style.paddingRight = '0.25em'; | |
container.style.paddingLeft = '0.25em'; | |
container.style.verticalAlign = 'middle'; | |
container.style.filter = 'grayscale(1)'; | |
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