4 ms·
Funny, I just made something like this today (but more primitive), mostly so that I won't miss Walter Bright's comments. // ==UserScript== // @name
by insertnickname 8y ago
Funny, I just made something like this today (but more primitive), mostly so that I won't miss Walter Bright's comments.
// ==UserScript==
// @name Hacker News VIP highlighter
// @version 1
// @grant none
// @match https://news.ycombinator.com/*
// ==/UserScript==
function highlightVIPs() {
'use strict';
const VIPs = [
"WalterBright"
];
const userTags = Array.from(document.getElementsByClassName("hnuser"));
userTags.forEach(tag => {
const username = tag.href.split("=")[1];
if (VIPs.includes(username)) {
tag.style.fontWeight = 'bold';
}
});
}
highlightVIPs();
(I'm not much of a JavaScript programmer, but it seems to work.)
- eat_veggies 8y agoPretty cool! If you want to speed your script up, consider implementing VIPs as a Set() so lookups are approx. O(1) rather than O(n). https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- jessaustin 8y agoProbably won't see much speedup with one VIP? b^)
- insertnickname 8y agoI currently have nine usernames in the array (removed all except Walter from the comment for brevity and privacy), but it's still a pretty small `n`. I don't know at what `n` the set becomes faster than the array, but I haven't noticed any performance impact from the script, and I can't be bothered even googling how to profile it in the browser.
- sbjs 8y agoTo be fair, Walter is a pretty solid choice. He's a successful businessman and extremely technically smart. There are quite a handful of similar people on here, who are very successful and intelligent and whose comments are always well thought out and insightful. (I want to be one of them one day but my career is just budding, so only time will tell.) It almost makes me think HN should have a related feature, where people can universally stand out, separate from the leaderboard (link at the bottom). But knowing HN's philosophy, I know this would be against the spirit of the humble-meritocracy they're trying to build, and would do more harm than good. In fact, I even wonder if this HN-Friends extension is going to have an adverse affect on its users. Right now the usernames are (probably intentionally) understated, to draw more attention to the content than the author. If we notice the person, we already have a bias not only toward their comment, but to read their comment before anyone else's. This goes against the meritocracy that I love about HN. But I also wonder how many thread discussion I had where I missed the context of who is talking, and the direction could have gone so much differently because of it. And even more importantly, I love and encourage this kind of innovation, and don't in any way want to discourage you or anyone from making clever things like this!
- insertnickname 8y agoIt's always fun to read a great comment and only then notice that it was Walter Bright who wrote it (and it often is).
- deleted 8y ago[deleted]
- JasonFruit 8y agoWhat exactly is the b^) face? Smily staring cyclops? If it's an emotion, it escapes me.
- whatsstolat 8y agoLooks like a side profile, with glasses
- wingerlang 8y agoCould be a misspelled B^) which looks more like a smiley with a nose. http://symbolhound.com/?q=b%5E%29 http://symbolhound.com/?q=b%5E%29
- JasonFruit 8y agoThat seems possible. I'm not so up on my smileys as I might be.
- jessaustin 8y agoMy right eye is missing and I wear an eyepatch.
- anonytrary 8y agoHis solution is fine -- the asymptotic complexity in this case doesn't matter since N is bounded and small.
- jonathanyc 8y agoHashing sets add a large fixed cost that dominates for small n. IIRC the rule of thumb is that arrays are better up til around a dozen or two.
- deleted 8y ago[deleted]
- jamestimmins 8y agoIf you're interested, I just put https://followalong.co https://followalong.co into alpha. It lets you follow people on HN and get email alerts when they post