Rotating Puff Begone

By Adam K Last update Aug 13, 2007 — Installed 1,108 times. Daily Installs: 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 0
/******************************************************************************
 * Rotating Puff Begone
 * version 0.2.1
 * 13/08/2007
 * Based on a similar GreaseMonkey script by Alexander Else
 * Copyright (c) 2005-2007, Adam Kent
 * Copyright (c) 2005, Alexander Else
 * (see http://www.else.id.au/greasemonkey-scripts.php for original code)
 * Released under the GPL license, version 2
 * http://www.gnu.org/copyleft/gpl.html
 ******************************************************************************/

// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.  To install it, you need
// Greasemonkey 0.3 or later: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Rotating Puff Begone", and click Uninstall.
//
// --------------------------------------------------------------------

// ==UserScript==
// @name          Rotating Puff Begone
// @namespace     http://semicircular.net
// @description   Remove the right hand column "rotating puff" from the SMH / Age, and makes all links 'fullpage'
// @include       http://*.smh.com.au/*
// @include       http://smh.com.au/*
// @include       http://*.theage.com.au/*
// @include       http://theage.com.au/*
// ==/UserScript==
    
var idDiv, idDivs, links, a;

function xpath(query) {
	return document.evaluate(query, document, null,
			XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
}

function killNode(target) {
	if(target.parentNode) {
		target.parentNode.removeChild(idDiv);
	} else {
		delete(target);
	}
}

idDivs = xpath("//div");
links = xpath("//a[@href]");

for(var i = 0; i < idDivs.snapshotLength; i++) {
	idDiv = idDivs.snapshotItem(i);
	switch(idDiv.id) {
		case 'woffRotator_parent':
		case 'rotatingpuff':
		case 'networkStripAd':
		case 'adSpotBanner-Leader':
		case 'adSpot-textBox':
		case 'adSpot-textBox2':
		case 'adSpotIsland':
		case 'adSpot-navsearch':
		case 'adSpot-advertorial':
		case 'printout-sponsor':
			killNode(idDiv);
		default:
	}
	switch(idDiv.className) {
		case 'adSpot-textBox':
		case 'ed-promo':
			killNode(idDiv);
		default:
	}
}

for (var i = 0; i < links.snapshotLength; i++) {
	a = links.snapshotItem(i);

	if (a.href.match(/(smh|theage)\.com\.au\//i) &&
			a.href.match(/\.html$/i )) { 
		a.href = a.href + '?page=fullpage';
	} 
}

// Changelog
// 05-11-2005 - 0.0.1 initial release
// 09-04-2006 - 0.2   add 'fullpage' to all smh/theage links to remove pagination
// 13-08-2007 - 0.2.1 add extra div type for most recent SMH/Age redesign