Skip to content

Instantly share code, notes, and snippets.

@corentinbettiol
Forked from frabert/COPYING
Last active August 4, 2022 07:14
Show Gist options
  • Save corentinbettiol/6d9dc3a032c17ebcd94dcbed27647b0b to your computer and use it in GitHub Desktop.
Save corentinbettiol/6d9dc3a032c17ebcd94dcbed27647b0b to your computer and use it in GitHub Desktop.
Display small, low-opacity favicons of links on HN & Lobsters pages & comments.

Display favicons next to HN & Lobsters posts (and comments)

Fork of this gist.

Main differences:

  • Does not add another favicon when you go back in your history and re-show a hn page,
  • Display favicons on comments links too,
  • Favicons are smaller (12x12px),
  • Favicons are displayed with a opacity = 0.6 (help do not be disturbed by flashy favicons)
  • Display favicons on lobste.rs too!

Click here to install

This will open the favicons.user.js file, that's recognized by a module like Tampermonkey.

image

image

image

// ==UserScript==
// @name Favicons for HN & Lobsters updated
// @version 1.1
// @grant none
// @author Francesco Bertolaccini & Corentin Bettiol
// @description Display small, low-opacity favicons of links on HN pages & comments.
// @homepageURL https://gist.github.com/corentinbettiol/6d9dc3a032c17ebcd94dcbed27647b0b/#file-favicons-js
// @match https://*.ycombinator.com/*
// @match https://*.lobste.rs/*
// @icon data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABHNCSVQICAgIfAhkiAAAAHpJREFUGFdj/J/G8J+BCMBEhBqwEiYGIXcGBv+lBNVDTGRiJqiQ4X+F+///v34C8a///0/u/w9y8/8VU/7///H9///fCDGIiYe3MzDU+TIwqOtDTObiY2A4tI2BoRYhBlH46wcDw7udDAxfPyOc8Pc3ihjRvmakejgCAOe9OAwKA5afAAAAAElFTkSuQmCC
// @run-at document-end
// ==/UserScript==
for(let link of document.links) {
if(!link.href.match("ycombinator.com") && !link.href.match("lobste.rs") && !link.href.match("javascript:void")){
if(link.firstChild && link.firstChild.nodeName !== "IMG") {
const domain = new URL(link.href).hostname
const imageUrl = `https://icons.duckduckgo.com/ip3/${domain}.ico`
const image = document.createElement('img')
image.src = imageUrl
if(window.location.host.match("lobste.rs")){
image.width = 14
image.height = 14
image.style.marginRight = '0.5em'
image.style.marginLeft = '0.25em'
image.style.opacity = '0.8'
link.style.display = 'flex'
link.style.alignItems = 'center'
}
else{
image.width = 12
image.height = 12
image.style.paddingRight = '0.25em'
image.style.paddingLeft = '0.25em'
image.style.opacity = '0.6'
}
link.prepend(image)
}
}
}
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment