Zombies, again

I happened across this thread this morning, and didn’t realize it was a zombie until I noticed a banned user posting in it. Something about ‘BANNED’ appearing under the user’s name catches my attention a lot better than the date of post. I know I’m not the only one who gets a little frustrated reading a thread and noticing 30 posts in that it’s a zombie, so I put together a quick greasemonkey script to identify zombie threads for me:

// ==UserScript==
// @name Zombie ID
// @namespace http://www.straightdope.com
// @description ID Zombies
// @include http://boards.straightdope.com/sdmb/showthread.php?*
// ==/UserScript==

var zombieAgeInDays = 120;
var monthIndex = 0;
var dayIndex = 1;
var yearIndex = 2;
var zombieText = "*** ZOMBIE ***"

var allT = document.evaluate('/html/body/div[2]/div/div/div/div/table/tbody/tr[1]/td/div[2]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < allT.snapshotLength; i++) {
	var dateField = allT.snapshotItem(i).textContent;
	if (dateField.indexOf('Yesterday') == -1 && dateField.indexOf('Today') == -1) {
		date_parts = dateField.replace(/^\s+|\s+$/g,"").split(',')[0].split('-');
		d = new Date(parseInt(date_parts[yearIndex]), parseInt(date_parts[monthIndex]) - 1, parseInt(date_parts[dayIndex]));
		tday = new Date();
		if (tday.valueOf() - d.valueOf() > zombieAgeInDays * 24 * 3600 * 1000) {
			allT.snapshotItem(i).textContent = allT.snapshotItem(i).textContent + zombieText;
		}
	}
}

How does it work? First, you have to have the greasemonkey plug-in installed for firefox (may work with other browsers - I have very little experience in this area.) Set this us as a script to run on all urls that match “http://boards.straightdope.com/sdmb/showthread.php?", and when you’re reading the thread itself, it parses all the dates for each of the posts, and if they’re greater than 120 days ago, it adds "** ZOMBIE ***” to the post’s header. This catches my eye quite noticeably.

You can make some changes fairly easily, even if programming’s not your thing. If 120 days isn’t the right cutoff for a zombie for you, edit the line that says:

var zombieAgeInDays = 120;

to be whatever age is appropriate. If you’re viewing your dates in a non-American way (it’s currently set up to assume the date is displayed as mm-dd-yyyy), you can change the order of these variables:

var monthIndex = 0;
var dayIndex = 1;
var yearIndex = 2;

(I haven’t tested this, because I can’t actually find the vbulletin setting to control date display. This does exist, doesn’t it?)

This is about the second greasemonkey script I’ve written, so if any of you more experienced have any suggestions for improvement feel free to let me know, or just make them and add to this thread. Also feel free to let me know if you see any problems.

Enjoy.

So the current WoW general discussion thread would be marked as a zombie because its first post was made more than 120 days ago, despite it seeing regular current use?

I think you missed the point of his post, brah.

The posts > 120 days old would be so marked, yes. The newer ones, no.

I made a suggestion about this issue a few months back.

That thread was one of the ones I was thinking of when I said I knew I wasn’t the only who found it frustrating. Want to try out the script and see if it works for you?

The script does not appear to be working for me. I definitely have Greasemonkey installed and enabled, and the script is enabled. I tested it on some threads with posts older than 120 days, and nothing looks different in those threads. The .js file contents are exactly this:

// ==UserScript==
// @name Zombie ID
// @namespace http://www.straightdope.com
// @description ID Zombies
// @include http://boards.straightdope.com/sdmb/showthread.php?*
// ==/UserScript==

var zombieAgeInDays = 120;
var monthIndex = 0;
var dayIndex = 1;
var yearIndex = 2;
var zombieText = “*** ZOMBIE ***”

var allT = document.evaluate(’/html/body/div[2]/div/div/div/div/table/tbody/tr[1]/td/div[2]’, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < allT.snapshotLength; i++) {
var dateField = allT.snapshotItem(i).textContent;
if (dateField.indexOf(‘Yesterday’) == -1 && dateField.indexOf(‘Today’) == -1) {
date_parts = dateField.replace(/^\s+|\s+$/g,"").split(’,’)[0].split(’-’);
d = new Date(parseInt(date_parts[yearIndex]), parseInt(date_parts[monthIndex]) - 1, parseInt(date_parts[dayIndex]));
tday = new Date();
if (tday.valueOf() - d.valueOf() > zombieAgeInDays * 24 * 3600 * 1000) {
allT.snapshotItem(i).textContent = allT.snapshotItem(i).textContent + zombieText;
}
}
}

I don’t use Firefox.

You might try something like putting a line towards the beginning (right before “var zombieAgeInDays = 120;”) that says:

window.alert(‘hello’);

You should get a dialog that pops up everything you view a straightdope thread that says “hello” - if that doesn’t happen, it would seem the script isn’t being invoked correctly.

One thing you said that sounds different from me is that I didn’t create a .js file. I just used ‘Create new script’ in the Greasemonkey UI, and it invoked notepad directly on a file that had a .user - not .js - extension (in my C:\Users[user name redacted]\AppData\Roaming\Mozilla\Firefox\Profiles\y2s2z1q0.default\gm_scripts\zombie_id folder).

Also, MsWhatsit, which version of Firefox are you using?

The “hello” popup worked; the zombie notification still doesn’t.

Firefox 3.5.16

Also, the script name appears to be: sdmb_zombie_threads.user.js

That sucks. I don’t know that I have an easy answer. My guess off the top of my head is that there is some subtle difference between the javascript parsers in our different versions of Firefox (I’m on 3.6.13) that is causing it to fail for you. But there’s very little the script is doing that is advanced enough to have changed between FF 3.5 and 3.6, but you could try upgrading browsers. Other than that, I’d have to debug it and see where it’s failing, and that could be challenging remotely.

One of those other threads also includes Javascript to do this, although it only identified zombies at a thread level. It even would detect zombie threads before you would open them. You may want to look at that script, as it seemed to work on all versions of Firefox.

I’m also not sure why anyone would stick with 3.5 over 3.6. There’s very little difference and 3.6 is safer, has slightly more features, and is better optimized.

Then again, Firefox 4.0 is coming out soon, and it blows both of them out of the water, so there’s no real point in upgrading now.

I didn’t see such a reference in Little Nemo’s thread. Do you recall where you saw it?

I have to disagree here. It takes, what, five minutes to upgrade between Firefox versions?

Also, MsWhatsit, in case you don’t check it, I sent a screenshot to the email address you have on your profile on the offchance that the ZOMBIE cue is showing up, but is just a little too subtle…

Thanks, Do Not Taunt. I finally figured it out, though; it seems there’s a conflict with wierdaaron’s SDMB Optifixer script, which I’ve had installed for quite some time now. I guess it should have occurred to me earlier that there might be an issue there. When I disabled the Optifixer script, the Zombie script immediately started working.

Re my Firefox version, I’m upgraded now. I wasn’t sticking with 3.5 intentionally; I just hadn’t got around to upgrading, apparently. (Possibly I HAD upgraded but then rolled back to the old version when I recently did a system restore to get rid of a virus. But I don’t think the Firefox version had anything to do with this anyway.)

Success! Thanks, Do Not Taunt.

Hi Do Not Taunt,

Sorry for resurrecting this thread (oh, the irony); I couldn’t seem to message or email you (privacy settings, perhaps?).

I was in the process of writing a Greasemonkey script to do exactly this. Your fantastic work (thank you, by the way!) does 95% of what I want it to.

Would you allow me to use your script, combine it with another one by Polerius, make some minor code modifications and then publish it to userstyles.org? You will both be credited.

If you’re not ok with that, I understand and will build one from scratch instead.

Thank you!

Definitely. I’ve been meaning to roll it into a script (I think by WeirdAaron?) as well, but haven’t pulled together the time/motivation. Feel free to post your finished product back here.

Heh, zombieing the thread about flagging zombies…

Nice script, I love using it. However, I tried changing the code “”*** ZOMBIE " so that it’s bold, red, and larger text to make the flag easier to notice, but none of the font tags seem to work. So, I use "******** Z O M B I E *********** *********** Z O M B I E *********** *********** Z O M B I E *********** " instead.

But, anyone got a hack to be able to change the font of the flag?

Great, now the zombie threads are self-referential. Keep on like this and the next thing you know, they’ve got launch codes and it’s Judgment Day.