Lurker News
Paste the following into the console of any HN page - for annotated avatars on all HN comments. (self contained code)

  for(u of document.querySelectorAll('.hnuser'))for(u.prepend(c=document.createElement('canvas')),x=c.getContext('2d'),c.width=18,c.height=14,s=u.innerText,r=1,i=28+s.length;i--;i<28?r>>>29>X*X/3+Y/2&&x.fillRect(6+2*X,2*Y,2,2)&x.fillRect(6-2*X,2*Y,2,2):r+=s.charCodeAt(i-28,x.fillStyle='#'+(r>>8&0xFFFFFF).toString(16)))r^=r<<13,r^=r>>>17,r^=r<<5,X=i&3,Y=i>>2

Comments (493) 108 threads

Show all comments

Showing thread 10 of 108

daenz4 replies#
I wonder how easily you could have slipped in an obfuscated cookie stealer
schleck81 reply#
UTF-encode the maliscious snippet and disguise it as the regex pattern haha
stavros1 reply#
Doesn't UTF-8 just give you the exact same letters, since it's already ASCII?
kroltan2 replies#
I think it was meant to be UTF-8 escape codes, as in \u0000 etc.

Continue this thread — 2 replies

zeusly#
HN sets one cookie and that is "httpOnly" and "secure", so it can't be read from JavaScript. You can test this yourself by typing document.cookie into your console, it should return an empty string.
usrbinbash#
Given that it takes about 20seconds to read through the snippet, not easily ;-)
neogodless#
I'm trying to do this in Firefox 98.0 and I'm not able to. I see this in the console:

> Scam Warning: Take care when pasting things you don’t understand. This could allow attackers to steal your identity or take control of your computer. Please type ‘allow pasting’ below (no need to press enter) to allow pasting.
Oh now that I'm reading it carefully, I see there's a way to enable it!