HN Highlight Author

Highlights author without breaking comment collapse

  1. // ==UserScript==
  2. // @description Highlights author without breaking comment collapse
  3. // @name HN Highlight Author
  4. // @namespace Violentmonkey Scripts
  5. // @match https://news.ycombinator.com/item
  6. // @version 1.2
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. let author = document.querySelector('table.fatitem a.hnuser').textContent;
  11. let authorComments = document.querySelectorAll(`table.comment-tree span.comhead > a[href*=${author}]`);
  12. authorComments.forEach(elm => {
  13. if (elm.querySelector('font'))
  14. elm.querySelector('font').style.color = '#fff';
  15. elm.style.backgroundColor = 'rgba(198, 120, 221, 0.8)';
  16. elm.style.borderRadius = '3px';
  17. elm.style.color = '#fff';
  18. elm.style.padding = '1px 2px';
  19. elm.style.paddingBottom = '2px';
  20. })