// DeviantART - FullViewer v0.5
// Made By Luke Stevenson {http://lucanos.deviantart.com}
// Distributed and Maintained via GMVC
// Last updated: 25 March 2006
//
//   This script modifies all links to "*/deviation/*" pages to point to
// the corresponding "*/view/*" page.  This means the links jump straight
// to Full View as opposed to going through the Standard View page first.
//
// ==UserScript==
// @name              DeviantART - FullViewer
// @namespace         http://gmvc.lucanos.com/
// @description       (v0.5) Makes all links which refer to "*/deviation/*" refer to "*/view/*".
// @include           http://*.deviantart.com*
// @include           http://deviouslyartistic.com*
// ==/UserScript==

(function () {
	var allLinks, thisLink, thisHREF, zoomOutLink, zoomOutHREF;
	// Get All Elements with an HREF attribute
	allLinks = document.evaluate("//*[@href]",document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
	// Grab the Zoom Out Button details
	zoomOutLink = document.evaluate("//*[@id='content']/div[1]/div[3]/table/tbody/tr/td[1]/a",document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
	if ( zoomOutLink.snapshotLength>0 ) {
		zoomOutHREF = zoomOutLink.snapshotItem(0).href;
	}

	for ( var i = 0; i < allLinks.snapshotLength; i++ ) {
		thisLink = allLinks.snapshotItem(i);
		thisHREF = thisLink.href;
		if ( !zoomOutLink.snapshotLength>0 || thisHREF != zoomOutHREF && !thisHREF.match('/scrap$') ) {
			// If No Zoom Out link found, or if the Zoom Out or Scrapping Buttons are not the Current Link - Change it.
			thisLink.href = thisHREF.replace('/deviation/','/view/');
		}
	}

})(); 