Skip to content

Instantly share code, notes, and snippets.

@mykiwi
Forked from frabert/COPYING
Last active April 20, 2022 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mykiwi/0b9ebc4850ef28a8686d83e702205fee to your computer and use it in GitHub Desktop.
Save mykiwi/0b9ebc4850ef28a8686d83e702205fee to your computer and use it in GitHub Desktop.
Greasemonkey scripts
// ==UserScript==
// @name Favicons for HackerNews
// @version 1
// @grant none
// ==/UserScript==
for(let link of document.querySelectorAll('.titlelink')) {
const domain = new URL(link.href).hostname
const imageUrl = `https://icons.duckduckgo.com/ip3/${domain}.ico`
const image = document.createElement('img')
image.src = imageUrl
image.width = 16
image.height = 16
image.style.paddingRight = '0.25em'
image.style.paddingLeft = '0.25em'
link.prepend(image)
}
// ==UserScript==
// @name Favicons for Lobsters
// @version 1
// @grant none
// ==/UserScript==
for(let element of document.querySelectorAll('.story .details')) {
const link = element.querySelector('.u-url')
const icon = element.querySelector('.byline > a > img')
const domain = new URL(link.href).hostname
const imageUrl = `https://icons.duckduckgo.com/ip3/${domain}.ico`
icon.src = imageUrl
icon.srcset = ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment