ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > Living Room

Anti-Necrospamming

<< < (7/12) > >>

nosh:
Works well inside threads, ewemoa. I couldn't get it working for topic listings though.

I've modified if slightly to show different colors for
under a week
1-3 weeks
3 weeks to 2 months
over 2 months.

It'll stop me from replying without thinking to somewhat older posts. :up:

ewemoa:
Works well inside threads, ewemoa. I couldn't get it working for topic listings though.
-nosh (March 30, 2009, 01:10 AM)
--- End quote ---

Ah, I hadn't thought to try to handle topic listings.  I wonder if I should consider a separate script for that...

I've modified if slightly to show different colors for
under a week
1-3 weeks
3 weeks to 2 months
over 2 months.

--- End quote ---

Beat me to it  :Thmbsup:

nosh:
Yeah, well... everything that actually required some brainpower was done by you.  ;D

ewemoa:
In case anyone wants to experiment, I think the following XPath expression may pick out relevant bits for topic listings:

//tr[@class='titlebg']/following-sibling::*/td[@width='22%']/span

--- End quote ---

Perhaps a bit on the fragile side...may be someone else can come up something more robust.

On a side note, I used the XPath Checker FF Extension to interactively come up w/ these XPath expressions (well, in combination with some tutorial sites ;) ).

I confess that it is really thanks to other folks sharing info and tools that makes putting something together like this feasible.  Hail sharing  :Thmbsup:

ewemoa:
The following is a separate attempt to work with topic listings.  It's separate to simplify testing.  Probably it makes sense to merge the scripts at some point :)


--- Code: Javascript ---// ==UserScript==// @name          NemseNaa// @namespace     http://ewemoa.dcmembers.com/greasemonkey/// @description   Script to provide visual indication of topics older than some amount// @include       https://www.donationcoder.com/forum/*// @include       https://www.donationcoder.com/forum/*// ==/UserScript== var now, then, gap, age, dateRe, xpExp, snapResults, i, elm, text, m;now = new Date();age = 30;dateRe = /(\d{4})-(\d{2})-(\d{2})/;xpExp = "//table/tbody/tr/td[7]/span";snapResults = document.evaluate(xpExp, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);for (i = snapResults.snapshotLength - 1; i >= 0; i -= 1) {  elm = snapResults.snapshotItem(i);  text = elm.textContent;  m = dateRe.exec(text);  if (m === null) {    continue;  }  then = new Date(m[1], (m[2] - 1), m[3]);  gap = (now - then) / 1000 / 60 / 60 / 24;  if (gap > age) {    elm.setAttribute("style", "color: red;");  }}// XXX//alert("It is currently: " + now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate());
Ah, and as to the XPath resources I've been using:


* http://www.zvon.org/xxl/XPathTutorial/General/examples.html
* http://commons.oreilly.com/wiki/index.php/Greasemonkey_Hacks/Getting_Started#Master_XPath_Expressions
The former was mentioned in the latter.

I don't know whether GM supports XPath 1.0 or 2.0...

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version