nameandnature: Giles from Buffy (giles)
[personal profile] nameandnature
I've finally got around to writing the Greasemonkey script which I've long been threatening.

What it does

The script remembers which comments you've seen on LJ (or Dreamwidth) and helps you navigate to new comments. That's right, I'm finally dragging LiveJournal kicking and screaming into the 1980s.

If you're on an entry page, pressing "n" skips you to the next new comment, and "p" skips to the previous one. If the style has an "Expand" link, moving to an unexpanded comment with these keys will also expand the thread. If the style has a permanent link or a reply link for each comment in that comment's header or footer, the script inserts another link next to it, labelled "NEW". That link shows you that the comment is new at a glance. Clicking the "NEW" link selects the comment so that pressing "n" will go to the next comment from there. On some styles, the currently selected comment will be outlined with a dotted line.

On a journal or friends page, the script will also add the number of new comments to the link text, so that, say, "15 comments" becomes "15 comments (10 new)", and enable the "n" and "p" keys to move between entries which have new comments, and the "Enter" key to view the selected entry. This only works if you're looking at a journal which adds "nc=N" to entry links to say there are N comments on an entry (LJ can do this as a trick to confuse your browser's history function into thinking you've not visited that entry whenever there are new comments). If you want to turn this on for your journal then ensure you're logged in, visit this page, check the box which says "Add &nc=xx to comment URLs" and hit the "Save" button.

How it works

You don't need to understand this section to use the script. If you don't care about programming, skip to the next part.

LJ makes it a total pig to do this sort of thing: there's so little uniformity in journal styles that getting a script like this to work for all of them is impossible. It's fair enough that LJ allows people to customise their journal's appearance, but there aren't even standardised CSS class names for stuff. Not that I'm bitter. So, what the script does is look for anchor tags of the form <a name="tNNNN"> or elements with an id attribute of ljcmtNNNN or tNNNN. NNNN is the comment number, which seems to be unique for each comment on a given user's journal. It then looks for the permanent link to that comment, which is usually to be found in the header of the comment (or footer, in my current style), and adds a "New" link after that. So, new comments are marked with a link to the next new comment.

The upshot of all this is that if you're reading a journal with a style which doesn't use either anchor tags or elements with the given id for all comments, the script won't work correctly. If the style doesn't provide each comment with a permanent link in the comment's header, the comment won't be marked with a "New" link. Such is life. Please don't ask me for special case changes to make it work with LJ's many horribly customised journals. Pick a sensible style of your own and learn to use "style=mine" instead. There's even another Greasemonkey userscript which will help. On the other hand, if there's a large class of the standard styles for which it doesn't work, tell me and I'll have a look at it.

Using it

If you want to use it, you will need:

After you've installed all of the above, visit an entry on LJ or Dreamwidth and marvel at the "NEW" links on all the new comments (which will be all of them at this point, as the script wasn't around previously to remember which ones you'd seen before). See above for operating instructions.

Privacy

Note that the script stores a Firefox preference key for each journal entry you visit, listing the IDs of the comments it finds there. The script doesn't let the database grow without limit: when the script has seen 500 entries, it starts to drop the history for the entries you've not visited recently.

Clearing the browser's history doesn't affect the script's list of visited entries. Thus your visits to polybdsmfurries will be recorded for posterity, even if you clear the browser's history. You can wipe the entire history by using the "Manage User Scripts" entry on the Tools menu to delete the script and its associated preferences (you can re-install it afterwards, but you must clear out the preferences for it to delete the history).

The script does not record the contents of any entry or comment. The script does not transmit any information to LJ or any other website, it merely acts on what it sees when you request journal entries.

Your questions

This entry is intended to serve as a repository for questions about the script, so if you've got a question, comment here. I prefer this to commenting on my other entries or to emailing me, unless you already know me. Ta.

To keep up to date with new releases of my greasemonkey scripts, track the tag "greasemonkey" on my journal. This link should enable you to subscribe to that tag and get notified when I post a new entry about greasemonkey scripts.

Revision history

2006-01-02, version 0.1: First version.

2006-01-03, version 0.2: Added the "p" key. Used javascript to move between comments so doing so does not pollute the browser's history. Coped with the id=ljcmtNNNN way of marking comments. Made "n" and "p" keys work even in the absence of permalinks on each comment.

2006-01-04, version 0.3: Apparently you can have id=tNNNN, too.

2006-01-04, version 0.4: Broke 0.3, fixed it again. I hope.

2006-01-19, version 0.5: Updated to cope with LJ's new URL formats. Changed how comments are stored internally so that the database does not grow without limit: the script now remembers comments for the last 500 entries you visited, and forgets the entries you've visited least. Also added "New" marker based on reply link as well as thread link, for styles which don't have a thread link for every comment.

2006-01-19, version 0.6: Convert dashes I find in URLs to underscores internally, to preserve access to history from older versions of the script before LJ's URL change.

2006-02-09, version 0.7: Work around the fact that Firefox leaks memory like a sieve. Never display negative number of new comments. Change licence to MIT as GPL is overkill for this script.

2006-02-09, version 0.8: There was a bug in the workaround code I got off the Greasemonkey mailing list. Fixed that.

2006-06-04, version 0.9: Enabled the "n" and "p" keys on the friends/journal view. Added the box around the current comment.

2007-02-20, version 1.0, baby: Try harder to draw a box around the current new comment. Applied [livejournal.com profile] legolas's fix for pressing CTRL at same time as the N or P keys (see comments).

2008-03-31, version 1.1: Make it work faster on entries with lots of comments. Altered behaviour of "NEW" link so it now selects the comment you're clicking on, as that makes more sense.

2008-09-24, version 1.2: Support Russian keyboards thanks to [livejournal.com profile] mumi_0, make threads expand.

2009-01-27, version 1.3: Support for independentminds journals.

2009-05-04, version 1.4: Support for Dreamwidth.

2009-09-22, version 1.5: Amend support for Dreamwidth.

2010-08-09, version 1.6: Made syndicated journals work.

2016-04-16, version 1.7: Add @grant line necessary for it to work on Firefox, apparently. Thanks [livejournal.com profile] sally_maria.

2017-10-18, version 1.8: Fix for https URLs.

Page 1 of 2 << [1] [2] >>

Date: 2006-01-08 03:42 pm (UTC)
From: [identity profile] feelforfaith.livejournal.com
This is an excellent script, thank you!

I do have one problem with it though. I can't navigate to the "next" and "previous" new comments when I use "begin finding as you begin typing" option in Firefox, because it brings up the find dialog instead.

How can I modify the script to use for example the Alt-n and Alt-p combinations instead?

(no subject)

From: [identity profile] feelforfaith.livejournal.com - Date: 2006-01-08 11:07 pm (UTC) - Expand

(no subject)

From: [identity profile] feelforfaith.livejournal.com - Date: 2006-01-09 04:27 pm (UTC) - Expand

Date: 2006-01-09 01:25 am (UTC)
From: [identity profile] mrlachatte.livejournal.com
I like this script a lot. I can't figure out what it's supposed to do on friends pages, though, as there's nothing new showing up on mine.

(no subject)

From: [identity profile] mrlachatte.livejournal.com - Date: 2006-01-10 02:02 am (UTC) - Expand

(no subject)

From: [identity profile] mrlachatte.livejournal.com - Date: 2006-01-10 02:03 am (UTC) - Expand
(deleted comment)
(deleted comment)

(no subject)

From: [identity profile] ttrtt.livejournal.com - Date: 2007-09-02 02:24 pm (UTC) - Expand

Date: 2006-01-22 11:51 pm (UTC)
pm215: (Default)
From: [personal profile] pm215
This is a really handy script; thanks. Are you interested in new-feature suggestions? You could make "n" on a journal page find the first journal entry on the page with unread comments, load it and point the browser at either the top of the entry (if all comments are unread) or the first unread comment.

Date: 2006-01-22 11:56 pm (UTC)
pm215: (Default)
From: [personal profile] pm215
Oh, and in the 'bug report' category, after hitting 'back' to return from an entry page to my friends page the link was updated to say "(13 comments (-1 new)" -- note the negative number. Unfortunately it doesn't seem to be reliably reproducible :-(

(no subject)

From: (Anonymous) - Date: 2006-01-24 10:00 am (UTC) - Expand

Date: 2006-02-12 01:43 pm (UTC)
pm215: (Default)
From: [personal profile] pm215
Another bug, although I'm not sure what provokes this: sometimes my friends page ends up with links like this: "8 comments (1 new) (1 new)"...

(I'm still using 0.6.)

Date: 2006-06-04 07:09 pm (UTC)
snakeling: Statue of the Minoan Snake Goddess (Default)
From: [personal profile] snakeling
Hello! I've been using your script before, but I switched OS and lost it. As Userscripts.org is down right now, I can't access it. Have you made it available elsewhere?

(no subject)

From: [personal profile] snakeling - Date: 2006-06-05 07:34 pm (UTC) - Expand

Date: 2006-10-09 10:45 pm (UTC)
rosefox: Green books on library shelves. (Default)
From: [personal profile] rosefox
I didn't realize how much I relied on this script until I changed my style to use .permalink_url?format=light instead of $.comments.read_url (so that the killfile script would work properly) and found that losing ?nc=xx also lost me the new comment notes. Fortunately, using $.comments.read_url&format=light appears to work. Thanks for a great script!

Date: 2006-11-08 06:30 pm (UTC)
From: [identity profile] trs80.ucc.asn.au (from livejournal.com)
How does this interact with the LJ thread unfolder?

(no subject)

From: [identity profile] trs80.ucc.asn.au - Date: 2008-03-31 12:16 am (UTC) - Expand

Date: 2006-11-11 10:25 am (UTC)
From: [identity profile] tavella.livejournal.com
Oooh, thanks. This will be useful.

Date: 2007-02-01 12:47 pm (UTC)
From: [identity profile] dark-ginger.livejournal.com
Thanks *_* Just found your script on Userscripts.org and I love it! Really useful! Thanks a lot!

Date: 2007-02-19 10:53 pm (UTC)
From: [identity profile] legolas.livejournal.com
Bugreport: installing this script and then opening a new window with ctrl+n makes my friends page jump to whatever 'n' would jump to. I'm trying to fix this, I'll let you know if I do.

Date: 2007-02-19 11:16 pm (UTC)
From: [identity profile] legolas.livejournal.com
Ok, I fixed it like this: I added these lines to the keypress handler:

    //return if any modifier is active, so we don't handle e.g. ctrl+n
    if(event.ctrlKey || event.altKey  || event.ctrlKey  || event.metaKey  || event.shiftKey)
	return;

Just under the already existing
    if (event.which != 110 && event.which != 112)
        return;

Date: 2007-09-06 03:55 am (UTC)
From: [identity profile] mairondil.livejournal.com
Of all the userscripts out there, yours is probably the most useful and most reliable userscript out there. There's a few system styles out there that it doesn't work on. But no biggie.

Date: 2008-04-03 08:38 pm (UTC)
ext_3241: (Default)
From: [identity profile] pizza.maircrosoft.com (from livejournal.com)
FYI, it is working for me in opera 9.26 with:

- the 'return' statements replaced by exit
(I don't know enough js to know if this is actually the same thing, but WFM)
- the 'emulate greasemonkey script' linked here http://www.howtocreate.co.uk/operaStuff/userJavaScript.html

Date: 2008-04-04 12:12 am (UTC)
ext_3241: (Default)
From: [identity profile] pizza.maircrosoft.com (from livejournal.com)
er, I spoke slightly too soon. I *also* had to put an if block around
all the entry-specific stuff.

if (userName) {

}

*then* I find it is storing too long a comment list: it is storing a
string of comment ids, plus "extend, override, init, destroy" so the
list is four items too long. I thought this was a style issue but I
poked some more and it turns out to be something to do with the js
objects because they show up even with

commentHash = new Object();
for (commentNumber in commentHash) {

so I blame opera, and I fix that loop to ignore those items....

*then* I realise that (??) because the gm emulating thing works by
storing document cookies, it's not working properly because of post and
friends page being in different domains. So I have to edit the gm
emulator to take the domain as an argument to its value storing thing,
and edit your script to send that.

*now*, now it works.

(no subject)

From: [identity profile] pizza.maircrosoft.com - Date: 2008-04-04 12:34 am (UTC) - Expand

(no subject)

From: [personal profile] kate_nepveu - Date: 2009-05-11 04:28 pm (UTC) - Expand

(no subject)

From: [personal profile] kate_nepveu - Date: 2009-05-17 05:14 pm (UTC) - Expand

(no subject)

From: [personal profile] mair_in_grenderich - Date: 2009-05-29 08:52 am (UTC) - Expand

(no subject)

From: [personal profile] kate_nepveu - Date: 2009-05-29 03:39 pm (UTC) - Expand

(no subject)

From: [personal profile] marcmagus - Date: 2009-06-29 09:18 pm (UTC) - Expand

(no subject)

From: [personal profile] mair_in_grenderich - Date: 2009-07-01 12:57 pm (UTC) - Expand

Date: 2008-05-18 06:37 pm (UTC)
From: [identity profile] cassiusdrow.livejournal.com
After installing the 1.1 version, the n/p keys have stopped working in the posts to go to the next new comment. They work fine on my friends page.

(no subject)

From: [identity profile] cassiusdrow.livejournal.com - Date: 2008-05-20 01:49 am (UTC) - Expand

(no subject)

From: [identity profile] cassiusdrow.livejournal.com - Date: 2008-05-21 01:06 am (UTC) - Expand

Date: 2008-08-14 05:40 pm (UTC)
From: [identity profile] mumische.livejournal.com
Excellent script, thank you! But I'm often using russian keyboard layout, so I'v made some changes. Do you planning to publish international versions?

(no subject)

From: [identity profile] mumische.livejournal.com - Date: 2008-08-15 05:21 am (UTC) - Expand

(no subject)

From: [identity profile] mumische.livejournal.com - Date: 2008-08-21 03:54 am (UTC) - Expand

Date: 2009-01-30 11:18 pm (UTC)
From: [identity profile] anotokino.livejournal.com
Hi! Awesome script, but I'm having some troubles with it. (I'm using Firefox v.3.05 on Windows XP.) At first when I installed the script, it worked like it was supposed to. Now, for some reason, all comments are labelled NEW, no matter how many times I view the page.

I haven't really changed anything/installed anything new, but my antivirus (AVG, free edition) did clean out some tracking cookies, could this have anything to do with it?

(no subject)

From: [identity profile] anotokino.livejournal.com - Date: 2009-02-01 02:17 am (UTC) - Expand

(no subject)

From: [identity profile] anotokino.livejournal.com - Date: 2009-02-02 04:28 pm (UTC) - Expand

Date: 2009-05-03 06:12 pm (UTC)
sally_maria: (Default)
From: [personal profile] sally_maria
I've been using your script for ages, and it's a great help. Thank you very much.

I was wondering whether you were planning on making a version for Dreamwidth? It's one of those clever things you don't realise how much you miss, until you don't have access to it any more.

(no subject)

From: [personal profile] sally_maria - Date: 2009-05-10 11:09 pm (UTC) - Expand

Date: 2009-11-16 05:35 pm (UTC)
From: [identity profile] tavella.livejournal.com
It doesn't seem to be working on dreamwidth for me -- I've tried looking at several different journals.

I removed and reinstalled the script, just in case I had an old one.

(no subject)

From: [identity profile] tavella.livejournal.com - Date: 2009-11-16 06:58 pm (UTC) - Expand

(no subject)

From: [identity profile] tavella.livejournal.com - Date: 2009-11-16 07:01 pm (UTC) - Expand

Date: 2010-08-05 03:19 am (UTC)
From: [identity profile] lafinjack.livejournal.com
Hello, thanks for the great script! It doesn't seem to be working on posts in syndicated feeds, though - either the "X new" on your friends page or on individual comments in a syndicated post. I've tried disabling and reenabling the script, un/reinstalling it, and checked the included and excluded pages (both default). I'm pretty sure it was working a couple weeks ago, not sure why it stopped.

(no subject)

From: [identity profile] lafinjack.livejournal.com - Date: 2010-08-07 04:22 am (UTC) - Expand

(no subject)

From: [identity profile] lafinjack.livejournal.com - Date: 2010-09-18 11:20 pm (UTC) - Expand

Date: 2011-09-16 11:48 pm (UTC)
From: [identity profile] immora.livejournal.com
Thanks for the script!

Question/comment: as far as you know, is this compatible with Insanejournal? Figured I'd check in case there's something messed up on my end and it's supposed to actually work. I just use the default entry views (not customized) and the comment URL structure is ljcmtNNNN, but it doesn't seem to be working for me.

Date: 2011-11-17 10:18 pm (UTC)
From: [identity profile] gmth.livejournal.com
Hi there. I'm not sure if you're still maintaining this script, but lately when I've been clicking on the Expand link on an entry that has lots and lots of comments, the page view sometimes jumps to a higher point on the page and then I have to scroll down again to find the comment I expanded. It's not happening in IE, only Firefox, and when I contacted LJ Support about it, they recommended disabling all my add-ons and then re-enabling them one at a time to find out if one of them is causing the problem. It looks like your script is the culprit. Do you have any suggestions for a workaround? I love your script and I don't want to disable it.

(no subject)

From: [identity profile] gmth.livejournal.com - Date: 2011-11-19 01:02 am (UTC) - Expand

(no subject)

From: [identity profile] gmth.livejournal.com - Date: 2011-11-22 02:41 pm (UTC) - Expand

Date: 2011-11-21 09:26 pm (UTC)
From: [identity profile] sushigal007.livejournal.com
Hi, I have this on my main computer and it works fine. However, I've been trying to get it to work on my laptop for a few days now, but whenever I click to install it, I get the error 'Script could not be installed TypeError : lines is null.' Any idea what the problem is?

(no subject)

From: [identity profile] sushigal007.livejournal.com - Date: 2011-11-22 03:11 pm (UTC) - Expand

Date: 2012-05-29 03:40 am (UTC)
majorshipper: (Default)
From: [personal profile] majorshipper
Is there any way to change the color of the link to make it more noticeable? I looked at the code, but I know nothing about this stuff, so it was all gibberish to me.

Date: 2015-09-17 07:41 pm (UTC)
From: [identity profile] aiffe.livejournal.com
When I use this with blocker (http://dwblock.neocities.org/dwblock.html) on Dreamwidth, and when it hits a new comment in one of the blocked threads it gives the error, "Error: no comments found to expand." I'd love if instead of doing that it just completely skipped blocked comments and went to the next non-blocked comment.

Date: 2015-10-28 05:54 pm (UTC)
sally_maria: (Default)
From: [personal profile] sally_maria
This has recently stopped working for me on Firefox - which after 5 years is pretty good going. Thank you very much for an incredibly useful script.

I found a solution from someone on fail_fandomanon - http://fail-fandomanon.dreamwidth.org/151871.html?thread=808436287#cmt808436287 and it's now working again, but I wasn't sure whether you were still maintaining the script.

Date: 2016-03-06 06:46 am (UTC)
From: [identity profile] myownkindamusic.livejournal.com
It stopped working for me too last year and I'd pretty much given up on it but decided to look around for a solution again just now. I came across this and it seems to be working again...thank you so much for posting this!

(no subject)

From: [personal profile] sally_maria - Date: 2016-03-06 09:19 am (UTC) - Expand

(no subject)

From: [personal profile] sally_maria - Date: 2016-04-18 07:18 pm (UTC) - Expand
Page 1 of 2 << [1] [2] >>

Profile

nameandnature: Giles from Buffy (Default)
nameandnature

December 2025

S M T W T F S
 123456
78910111213
14151617181920
2122 2324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 9th, 2026 12:42 am
Powered by Dreamwidth Studios