3 ms·
Wouldn't it make more sense to add an "unread" class to the comment and style it with css instead of appending new elements? I also think it would make sense t
by sorenjan 5y ago
Wouldn't it make more sense to add an "unread" class to the comment and style it with css instead of appending new elements?
I also think it would make sense to store the page load time, and compare to a comment's post time to determine if it's new instead of storing all comment ids.
- linkdd 5y agoI already have a custom CSS (using Stylus) for Dark Mode. The CSS is trickier due to the HTML structure.
- sorenjan 5y agoI was thinking of something like this: let style = document.createElement('style'); style.innerHTML = ".unread::after {content: ':bell:'}"; document.getElementsByTagName('head')[0].appendChild(style); document.querySelectorAll('.athing.comtr').forEach(comm => { if (comment is unread) { comm.querySelector('.comhead').classList.add("unread"); } }) That shouldn't collide with other custom CSS, and it avoids adding extra elements in the loop. Edit: I used the actual bell emoji in the code, but HN removed that, so I just replaced it with :bell:.