Monkeying around
Jan. 2nd, 2006 10:14 pmWhat 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:
- Firefox, the web browser, and Greasemonkey, the extension which lets people write little bits of Javascript to run on certain pages.
- OR Google Chrome and TamperMonkey.
- LJ New Comments, which is what I've imaginatively entitled my script.
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
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
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
sally_maria.
2017-10-18, version 1.8: Fix for https URLs.
no subject
Date: 2006-01-08 03:42 pm (UTC)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
Date: 2006-01-08 08:27 pm (UTC)If you're happy changing a bit of Javascript, the part you're interested in is the keypress_handler function near the bottom of the script. The event has event.altKey set true if the Alt key was pressed along with the key, event.ctrlKey set if the Ctrl key was pressed, and so on. So you'd want to change the test for each key to something like:
if (event.which == 112 && event.altKey), I think, that is, you'd say "press p and alt key at the same time".Hope this helps.
(no subject)
From:(no subject)
From:(no subject)
From:no subject
Date: 2006-01-09 01:25 am (UTC)no subject
Date: 2006-01-10 12:19 am (UTC)(no subject)
From:(no subject)
From:(no subject)
From:(no subject)
From:no subject
Date: 2006-01-22 11:51 pm (UTC)no subject
Date: 2006-01-22 11:56 pm (UTC)no subject
Date: 2006-01-24 01:09 am (UTC)(no subject)
From: (Anonymous) - Date: 2006-01-24 10:00 am (UTC) - Expand(no subject)
From:(no subject)
From:no subject
Date: 2006-02-12 01:43 pm (UTC)(I'm still using 0.6.)
no subject
Date: 2006-02-21 12:41 am (UTC)no subject
Date: 2006-06-04 07:09 pm (UTC)no subject
Date: 2006-06-05 07:14 pm (UTC)(no subject)
From:no subject
Date: 2006-10-09 10:45 pm (UTC)no subject
Date: 2006-10-15 10:28 pm (UTC)I keep thinking I'll generalise its knowledge of where comments are in various styles to extend the killfiling and thread unfolding functions that other people have implemented for the default comment style, but I've been a bit busy lately. Maybe now I've got some more free time I'll give it a go.
no subject
Date: 2006-11-08 06:30 pm (UTC)no subject
Date: 2006-11-08 07:36 pm (UTC)This makes sense: LJ Thread Unfolder destroys a piece of the DOM and replaces it with the comments it loaded, so Firefox refuses to scrollIntoView the objects which LJ New Comments has cached (the folded up comments, which are just the header without the text). Making LJ New Comments recache its idea of where each comment is (without updating its idea of newness) whenever LJ Thread Unfolder unfolds a thread would make things work, but I don't know of a good way for two GM scripts to communicate like that.
My master plan is to use LJ New Comment's ability to recognise a comment in a variety of styles to make a better thread unfolder (the current one only really works in the default style, useful though that is) and possibly a kill-file (I want my Usenet). Don't hold your breath, though.
(no subject)
From:no subject
Date: 2006-11-11 10:25 am (UTC)no subject
Date: 2007-02-01 12:47 pm (UTC)no subject
Date: 2007-02-19 10:53 pm (UTC)no subject
Date: 2007-02-19 11:16 pm (UTC)//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;(no subject)
From:no subject
Date: 2007-09-06 03:55 am (UTC)no subject
Date: 2007-09-06 09:00 am (UTC)no subject
Date: 2008-04-03 08:38 pm (UTC)- 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
no subject
Date: 2008-04-04 12:12 am (UTC)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:(no subject)
From:(no subject)
From:(no subject)
From:(no subject)
From:(no subject)
From:(no subject)
From:(no subject)
From:no subject
Date: 2008-05-18 06:37 pm (UTC)no subject
Date: 2008-05-20 12:16 am (UTC)(no subject)
From:(no subject)
From:(no subject)
From:no subject
Date: 2008-08-14 05:40 pm (UTC)no subject
Date: 2008-08-14 11:34 pm (UTC)(no subject)
From:(no subject)
From:(no subject)
From:no subject
Date: 2009-01-30 11:18 pm (UTC)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
Date: 2009-01-31 11:50 pm (UTC)It sounds like that's not what you're seeing here, though. If you keep hitting reload on a page, do you get NEW comments all the time, or is it just when you go back to a page after restarting Firefox?
(no subject)
From:(no subject)
From:(no subject)
From:no subject
Date: 2009-05-03 06:12 pm (UTC)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
Date: 2009-05-04 12:56 am (UTC)I do intend to make it compatible with Dreamwidth (and with other popular LJ clones) but I've been waiting for DW's official launch as they've been changing styles and suchlike as they've been developing it. It looks like the way the script detects comments will work just as it did on LJ, so I hope to have something fairly soon.
(no subject)
From:(no subject)
From:no subject
Date: 2009-11-16 05:35 pm (UTC)I removed and reinstalled the script, just in case I had an old one.
no subject
Date: 2009-11-16 06:50 pm (UTC)(no subject)
From:(no subject)
From:no subject
Date: 2010-08-05 03:19 am (UTC)no subject
Date: 2010-08-06 04:00 pm (UTC)(no subject)
From:(no subject)
From:(no subject)
From:no subject
Date: 2011-09-16 11:48 pm (UTC)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.
no subject
Date: 2011-09-26 01:15 pm (UTC)What doesn't work is comments on communities, because IJ has changed the URL for that. I'll have a look at fixing that when I get a moment.
no subject
Date: 2011-11-17 10:18 pm (UTC)no subject
Date: 2011-11-18 10:05 am (UTC)(no subject)
From:(no subject)
From:(no subject)
From:no subject
Date: 2011-11-21 09:26 pm (UTC)no subject
Date: 2011-11-22 12:26 am (UTC)(no subject)
From:no subject
Date: 2012-05-29 03:40 am (UTC)no subject
Date: 2015-09-17 07:41 pm (UTC)no subject
Date: 2015-10-28 05:54 pm (UTC)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.
no subject
Date: 2016-03-06 06:46 am (UTC)(no subject)
From:(no subject)
From:(no subject)
From: