Skip to content

Instantly share code, notes, and snippets.

@Klaster1
Last active July 29, 2023 03:55
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 Klaster1/d4d75d9e890e9db9509fd075cbc0aab4 to your computer and use it in GitHub Desktop.
Save Klaster1/d4d75d9e890e9db9509fd075cbc0aab4 to your computer and use it in GitHub Desktop.
Hacker News paint likes
// ==UserScript==
// @name HackerNews paint likes
// @description Like comments and submissions by pressing Shift while mouse curosor is over or by hovering while Shift is down
// @version 1.1
// @grant none
// @match https://news.ycombinator.com/*
// @icon https://news.ycombinator.com/favicon.ico
// @downloadURL https://gist.github.com/Klaster1/d4d75d9e890e9db9509fd075cbc0aab4/raw/hacker-news-paint-likes.user.js
// @updateURL https://gist.github.com/Klaster1/d4d75d9e890e9db9509fd075cbc0aab4/raw/hacker-news-paint-likes.user.js
// ==/UserScript==
/** @type {HTMLElement|undefined} */
let lastHoveredComment
document.addEventListener('mouseover', e => {
lastHoveredComment = e.target.closest('.athing')
if (e.shiftKey) lastHoveredComment?.querySelector('[id*=up]')?.click()
})
document.addEventListener('keydown', e => {
if (e.key === 'Shift') {
lastHoveredComment?.querySelector('[id*=up]')?.click()
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment