// Copyright James Inge 2007.
//
// Free for use under the GNU General Public License version 2.
//
// v0.1 - Initial attempt.
// v0.2 - Detects whether all logs are already being shown, since links to specific log entries were getting broken.

// ==UserScript==
// @name           Show all geocaching logs
// @namespace      http://inge.org.uk/userscripts
// @description    Automatically shows all log entries for a geocache, rather than just the first five, without having to click the link. Handy for working out stats for the cache.
// @include        *
// ==/UserScript==

// Rather than change or reload the cache page, this script intercepts
// links on other pages that link to geocaching pages.  Being a
// quick hack, it will interfere with any website that happens to use
// the filename "cache_details.aspx".  If so, just exclude that site
// using the Tools/Greasemonkey/Manage User Scripts dialogue.

var allLinks, thisLink;
allLinks = document.evaluate( '//a[@href]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < allLinks.snapshotLength; i++) {
	thisLink = allLinks.snapshotItem(i);
	if(thisLink.href.match( "cache_details.aspx?" )) {
		if( !thisLink.href.match( "&log=y" ))
		thisLink.href += "&log=y";
	}
}
