Show HN: Bookmarklet to Highlight OP's Username

3 points by gabrielsroka ↗ HN
Drag and drop or copy and paste to your bookmark toolbar. Even works on mobile.

  javascript:/*/hn op#*/document.querySelectorAll(`a.hnuser[href$=${document.querySelector('a.hnuser').href.split('=').pop()}]`).forEach(a=>a.style.backgroundColor='yellow')

7 comments

[ 3.6 ms ] story [ 31.8 ms ] thread
I'm the OP. I'm commenting so you can see my name highlighted if you use it.

I found an interesting quirk with Chrome that if you drag and drop one that has a URL (e.g., /hn op#), it turns into the name of the bookmark. I'd love to find the source code for Chrome for this particular feature.

Oh, that is interesting! I didn't even know non-links could be dragged into the bookmarks bar. How did you even discover this feature?

Then on top of that, how did you figure out a comment like that would turn into the name of the bookmark?

Both features are very hard to discover~

Drag and drop of bookmarklets has been around forever. In fact https://news.ycombinator.com/bookmarklet.html

I think one of my bookmarklets had a URL in it and I saw that it got turned into a name. So I just moved it into a JavaScript comment near the beginning.

Or I had something like this:

  javascript:alert('hi') //say hi
Yes, I've been aware of being able to drag links to the bookmark bar, but did not know non-link plain-text URL's worked, too.