// ==UserScript==
// @name Rel-To-Link
// @author UserJS.org 
// @namespace http://userjs.org/ 
// @version 1.0
// @description  Creates corresponding LINK tags for all links with rel
//			attributes.
// @ujs:category browser: enhancements
// @ujs:published 2005-06-21 16:44
// @ujs:modified 2005-09-19 09:19
// @ujs:documentation http://userjs.org/scripts/browser/enhancements/rel-to-link 
// @ujs:download http://userjs.org/scripts/download/browser/enhancements/rel-to-link.user.js 
// @ujs:download.gm http://userjs.org/scripts/download/browser/enhancements/rel-to-link.user.js
// ==/UserScript==


/* 
 * License: BSD
 */

(function () {
	var oHead = document.getElementsByTagName('head')[0];
	if( !oHead ) { return; }
	for( var i = 0, j, k, l, m, n; j = document.links[i]; i++ ) {
		k = j.getAttribute('rel'), m = j.getAttribute('href'), n = j.getAttribute('title');
		if( k ) { k = k.replace(/(^\s+|\s+$)/g,''); }
		if( k && m && ( k != 'nofollow' ) ) {
			l = document.createElement('link');
			l.setAttribute('href',m);
			l.setAttribute('rel',k);
			if( n ) { l.setAttribute('title',n); }
			oHead.appendChild(l);
		}
	}
})();
