Live data from Hacker News

Show HN: Favicons for HN

gist.github.com

51–60 of 73 posts

Re: Show HN: Favicons for HN

#52
post #33

As an aside, there's Refined Hacker News[0] which seems like it would be a great option for this to be built into. It has lots of great features while keeping things minimal. [0] https://github.com/plibither8/refined-hacker-news

Thanks for extensions. But I think there's no need to integrate its functionality to the site. This way one can choose how to customize the site without increasing complexity of the site itself.

With inline reply HN would decrease the number of requests needed to make replies, so it sounds like a net gain.

Re: Show HN: Favicons for HN

#54
My version, better alignment, grayscaled icons, eliminates duplicates on navigation:

    // ==UserScript==
    // @name     hacker news favicons
    // @match  https://news.ycombinator.com/*
    // ==/UserScript==
    for (let link of document.querySelectorAll('.titlelink')) {
      if (link.attributes["hasIcon"] != 'true') {
        const domain = new URL(link.href).hostname
        const imageUrl = `https://icons.duckduckgo.com/ip3/${domain}.ico`
        const image = document.createElement('img')
        link.attributes["hasIcon"] = 'true'
        image.src = imageUrl
        image.width = 16
        image.height = 16
        image.style.paddingRight = '0.50em'
        image.style.paddingLeft = '0.50em'
        image.style.verticalAlign = 'middle';
        image.style.filter = 'grayscale(1)';
        link.prepend(image)
      }
    }

Re: Show HN: Favicons for HN

#56

My version, better alignment, grayscaled icons, eliminates duplicates on navigation: // ==UserScript== // @name hacker news favicons // @match https://news.ycombinator.com/* // ==/UserScript== for (let link of document.querySelectorAll('.titlelink')) { if (link.attributes["hasIcon"] != 'true') { const domain = new URL(link.href).hostname const imageUrl = `https://icons.duckduckgo.com/ip3/${domain}.ico` const image =…

Afaik @include is depricated (at least I get a warning in FF), switch to // @match which is also safer. Details: https://wiki.greasespot.net/Metadata_Block / https://www.tampermonkey.net/changelog.php?ext=dhdg&show=dhd... (Since 4.4)

Re: Show HN: Favicons for HN

#58

My version, better alignment, grayscaled icons, eliminates duplicates on navigation: // ==UserScript== // @name hacker news favicons // @match https://news.ycombinator.com/* // ==/UserScript== for (let link of document.querySelectorAll('.titlelink')) { if (link.attributes["hasIcon"] != 'true') { const domain = new URL(link.href).hostname const imageUrl = `https://icons.duckduckgo.com/ip3/${domain}.ico` const image =…

Afaik @include is depricated (at least I get a warning in FF), switch to // @match which is also safer. Details: https://wiki.greasespot.net/Metadata_Block / https://www.tampermonkey.net/changelog.php?ext=dhdg&show=dhd... (Since 4.4)

Thanks!

Re: Show HN: Favicons for HN

#60
post #28

Is anyone who's good with CSS able to modify this to align the icon and text better? The current alignment where the baseline of the text is in line with the bottom of the favicon feels off.

If you set the width/height to 12px, set the image's left padding to 0, and center things vertically with flex, it looks significantly better.

  image.width = 12
  image.height = 12
  image.style.marginRight = '0.25em'
  //image.style.paddingRight = '0.25em'
  //image.style.paddingLeft = '0.25em'

  document.querySelectorAll('.athing > td:nth-child(3), .titlelink').forEach(e => { 
    e.style.display = 'flex',
    e.style.alignItems = 'center',
    e.style.marginRight = '0.25em'
  })
Screenshot: https://imgur.com/BN2wHgo
Post reply on HN