5 ms·
Show HN: Bookmarklet to Highlight OP's Username
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')
- gabrielsroka 4y agoI'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.
- Leftium 4y agoOh, 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~
- gabrielsroka 4y agoDrag and drop of bookmarklets has been around forever. In fact https://news.ycombinator.com/bookmarklet.html 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
- Leftium 4y agoYes, 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.
- Baljhin 4y agoRelated: try userscript 'HN Highlight Author' > Highlights author (name) without breaking comment collapse https://greasyfork.org/scripts/393187 https://greasyfork.org/scripts/393187 Works for me on Firefox; haven't tested on Chrome.
- Leftium 4y agoNote the Refined Hacker News browser extension does this automatically, and more: https://github.com/plibither8/refined-hacker-news#readme https://github.com/plibither8/refined-hacker-news#readme This bookmarklet might be a nice option on mobile. I prefer to view via my own HckrNews web app, which also highlights the OP: https://hw.leftium.com/#/item/35076225 https://hw.leftium.com/#/item/35076225
- gabrielsroka 4y agoEven though I wrote a popular Chrome extension, or perhaps because I did, I don't use extensions.