news.volyx.in

Show HN: HN Avatars in 357 bytes

701 points by tomxor · 1646 days ago · 493 comments on HN

Article summary

The article presents a self-contained JavaScript code that generates annotated avatars for Hacker News comments. The code uses a deterministic avatar generator and can be pasted into the console of any HN page. The generator is based on the xorshift32 PRNG and uses the HN username as a seed. The code is also available in a golfed version, which is smaller but may have some limitations.

Main themes

  • JavaScript code
  • Hacker News comments
  • Avatar generation
  • Browser security
  • Userscript management
  • Web extensions
  • Code obfuscation

What commenters say

  • Some users found the golfed version of the code to be more visually appealing when the avatar is added next to the username, while others preferred the un-golfed version which adds the avatar to the beginning of the line.
  • The code can be permanently loaded in the browser using a userscript manager like Greasemonkey or Violentmonkey.
  • There are concerns about the potential security risks of running unknown JavaScript code in the browser, but in this case, the code is relatively simple and does not appear to pose a significant threat.
  • Some users suggested creating a web extension to execute the JavaScript code, while others preferred using a userscript manager.
  • The code can be used as a bookmarklet by prefixing it with 'javascript:' and suffixing it with ';void(0);'.
  • The security of the code is also discussed, with some users pointing out that the HN cookie is 'httpOnly' and 'secure', making it inaccessible from JavaScript.
  • The use of Unicode escape codes to obfuscate malicious code is also mentioned, but it is noted that this would not be effective in this case.