Hack #86. Zap Ugly XML Buttons

Make weblogs more palatable by replacing those orange XML buttons.

If you read weblogs regularly, you have undoubtedly seen an orange XML button. What is this? It's a link to the site's syndicated feed, suitable for reading in a dedicated news aggregator.

So, why does it say "XML," and why is it that dreadful shade of orange? Nobody knows. It seems to be specifically designed to clash with every possible color scheme. This hack replaces it with a plain-text link that says "Feed."

Tip

Learn more about syndication at http://atomenabled.org.

The Code

This user script runs on all pages. It identifies the orange XML buttons by their size, so it won't catch custom buttons that are a different size. But it catches most of them.

Save the following user script as zapxmlbuttons.user.js:

	// ==UserScript==
	// @name		Zap XML buttons
	// @namespace	http://diveintomark.org/projects/greasemonkey/
	// @description	convert orange XML buttons to text
	// @include		*
	// ==/UserScript==

	var snapXMLImages = document.evaluate(
		"//img[@width='36'][@height='14']",
		document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

	for (var i = snapXMLImages.snapshotLength - 1; i >= 0; i--) {
		var elmXMLImage = snapXMLImages.snapshotItem(i);
		if (/(xml|rss)/i.test(elmXMLImage.src)) {
			var elmXMLText = document.createTextNode('Feed');
			elmXMLImage.parentNode.replaceChild(elmXMLText, elmXMLImage);
		}
	}

Running the Hack

Before installing the user script, go to http://radio.weblogs.com/0001011/, which ...

Get Greasemonkey Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.