/*===================================================================================*\
|  Google Groups Plus v1.0                                                       |
|    2006 by Damian Penney																															|
|  This script add a very basic killfile to Google Groups, click on the X by any      |
|  authors name to make them disappear for good. It's essentially the Metafilter      |																				|
|  killfile script written by Mystyk with a bit of jiggery pokery applied.            |
\*===================================================================================*/

// ==UserScript==
// @name           Google Groups Plus
// @description    Kill User on Google Groups and Cleanup UI
// @include        http://groups*.google.*/*
// ==/UserScript==


function GroupsPlus_Run(){	
  // Add about link after group name
//  var candidates = document.evaluate("/html/body/div[3]/table/tbody/tr/td/div[3]/table/tbody/tr/td|", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  var candidates = document.evaluate("/html/body/div[3]/table/tbody/tr/td|/html/body/div/table/tbody/tr/td/div[3]/table/tbody/tr/td", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
	if(candidates.snapshotLength > 0)
	{
		cand = candidates.snapshotItem(0);
	
		var slashesFound = 0;
		var rootURLLength = 0;
		for(rootURLLength = 0; rootURLLength < location.href.length && slashesFound < 5; rootURLLength++)
		{
			if(location.href.charAt(rootURLLength) == '/')
			{
				slashesFound++;
			}
		}
		
		var rootURL = location.href.substr(0, rootURLLength);
		
		
		var navLink = document.createElement('a');
		navLink.setAttribute('href', rootURL + 'post');
		var linkText = document.createTextNode("New Post");

	
		cand.appendChild(navLink);
		navLink.appendChild(linkText);
		
		navLink = document.createElement('a');
		navLink.setAttribute('href', rootURL + 'subscribe');
		linkText = document.createTextNode("Edit Subscription");

		cand.appendChild(document.createTextNode('\u00a0|\u00a0'));

		cand.appendChild(navLink);
		navLink.appendChild(linkText);

		navLink = document.createElement('a');
		navLink.setAttribute('href', rootURL + 'about');
		linkText = document.createTextNode("About");
		
		cand.appendChild(document.createTextNode('\u00a0|\u00a0'));

		cand.appendChild(navLink);
		navLink.appendChild(linkText);
				
	}	

	
	// Remove right col width
  candidates = document.evaluate("/html/body/table/col[2]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
	if(candidates.snapshotLength > 0)
	{
		var cand = candidates.snapshotItem(0);
		cand.style.width = '1ex';
	}

	// Remove actual right cols td 
  candidates = document.evaluate("/html/body/table/tbody/tr/td[2]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
	if(candidates.snapshotLength > 0)
	{
		var parentNode = candidates.snapshotItem(0).parentNode;
		parentNode.removeChild(candidates.snapshotItem(0));
	}

	// Remove div that the right col content is contained within
  candidates = document.evaluate("/html/body/div[5]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
	if(candidates.snapshotLength > 0)
	{
		var parentNode = candidates.snapshotItem(0).parentNode;
		parentNode.removeChild(candidates.snapshotItem(0));
	}
  
  
  // Remove right col width
  candidates = document.evaluate("/html/body/table/col[2]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
	if(candidates.snapshotLength > 0)
	{
		var parentNode = candidates.snapshotItem(0).parentNode;
		parentNode.removeChild(candidates.snapshotItem(0));
	}


	// Remove right cols div
  candidates = document.evaluate("/html/body/div/table/tbody/tr[2]/td/div", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
	if(candidates.snapshotLength > 0)
	{
		var parentNode = candidates.snapshotItem(0).parentNode;
		parentNode.removeChild(candidates.snapshotItem(0));
	}

  // Remove right cols td
  candidates = document.evaluate("/html/body/div/table/tbody/tr[2]/td/table/tbody/tr/td[2]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
	if(candidates.snapshotLength > 0)
	{
		var parentNode = candidates.snapshotItem(0).parentNode;
		parentNode.removeChild(candidates.snapshotItem(0));
	}

  candidates = document.evaluate("/html/body/div/table/tbody/tr[2]/td/table/col[2]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
	if(candidates.snapshotLength > 0)
	{
		var parentNode = candidates.snapshotItem(0).parentNode;
		parentNode.removeChild(candidates.snapshotItem(0));
	}

  // Make sure the iframe is the right height
  candidates = document.evaluate("/html/body/div/iframe", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
	//alert(document.documentElement.scrollHeight);
	if(candidates.snapshotLength > 0)
	{
		candidates.snapshotItem(0).style.Height = document.scrollHeight;
	}

  
}


GroupsPlus_Run();
// End



