The saidit script enhances reddit comment pages by highlighting unread comments. It works by keeping track of the comments you’ve already viewed. Here’s what it looks like:
Features
- Highlights unread reddit comments
- Read comments are stored locally
- Automatic removal of old data
- Efficient implementation
Installation
If you’d like to give it a spin, make sure you have Greasemonkey installed. Then, just install saidit from userscripts.org. Have fun!
How it works
For every comment viewed on reddit, saidit records the comment id in a “seen comments list” using DOM Storage. When a reddit comments page is loaded, saidit scans through each comment and checks if the id is in the list. If the id is not found, the class “unread”, is added to the comment div (this class can then be styled to emphasize unread comments). The seen comments list is then updated to include the new comments.
Since the script scans through hundreds of comments during the time-sensitive page loading process, I needed to make checking comment ids as fast as possible. Experimentation showed that if the seen comment ids were loaded into the fields of an Object, looking up ids was much faster than using an Array. Currently, saidit takes up to 2.5 seconds on the largest comment pages (200+) on my machine. I’m continuing to look into ways of making it faster.
Interoperability
An interesting side-effect of using DOM Storage is that read comment data is accessible to JavaScript on reddit and any other user scripts. If you can think of any clever ways to use this data, feel free to load it using the loading code below, or simply fork saidit to create a new script. Please use your new powers for good, not evil!
Here’s what the data loading code looks like, using Mozilla’s non-standard implementation of DOM Storage:
var redditStorage = globalStorage.namedItem("www.reddit.com"); var pageThingID = getThingID(getPageThing()); var seenArray = []; var seenObject = {}; var seenData = redditStorage.getItem("seen-"+pageThingID); seenArray = seenData.value.split(","); // Build an object for faster access seenArray.forEach(function(element) { seenObject[element] = true; });
The “unread” class can be styled in subreddit CSS to achieve different effects. Just use a CSS rule similar to the default (perhaps with !important added):
.comment.unread .tagline { font-weight: bold; background-color: #fea; display: inline; }
If you discover any interesting ways to use these, please leave a comment!
2 Comments
Related posts:
- Hack: Wordpress cancel reply button: I’m a huge fan of the commenting improvements introduced in Wordpress 2.7. It’s been a tremendous boon to have first-class...
- My Alien Visitor: He claims to be from San Francisco. Affinity for bacon. Arrived with a document depicting various lifeforms from his...
- Letting IE6 down easy: If you were browsing using Internet Explorer 6 right now, here’s what you’d see: Note: Internet Explorer version 6 or...
- On the era of Amazon.com: Today, I read that Amazon.com had its ‘best holiday ever’, selling a ‘record-breaking 72.9 items per second’ (via reddit). It’s...
- Socialite on AMO: As of approximately 7:08 am, Socialite is now publicly available on AMO (addons.mozilla.org). It’s been a long time coming, and...



This is a jolly good thing. How might one go about modifying the script to append a string to the unread posts? Something short like “New!!” so one might use Ctrl-F to jump between the unread posts quickly?
Awesome script. I am new to reddit and am used to forums where I can view unread posts easily, and this script makes reading reddit so much more convenient. Thanks for the work.