Skip to content

Instantly share code, notes, and snippets.

@llimos
Created August 5, 2020 08:17
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 llimos/ee818bcb3060adc8469f4978c654a184 to your computer and use it in GitHub Desktop.
Save llimos/ee818bcb3060adc8469f4978c654a184 to your computer and use it in GitHub Desktop.
Firefox bookmarklet for HN discussion of current page
javascript:(()=>{const w=window.open();fetch(`https://hn.algolia.com/api/v1/search?tags=story&query=${encodeURIComponent(window.location.href)}`).then(a => a.json()).then(a=>{const c=a.hits.filter(b=>b.url===window.location.href)[0];if(c){w.location.replace(`https://news.ycombinator.com/item?id=${c.objectID}`)}else{w.confirm('Not on HN. Submit?') ? w.location.replace(`https://news.ycombinator.com/submitlink?u=${encodeURIComponent(document.location)}&t=${encodeURIComponent(document.title)}`):w.close();}})})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment