Facebook URL Cleaner

By Jordon Kalilich Last update Oct 7, 2010 — Installed 2,678,519 times.

URL Cleaner with href removal also (code inside)

in
Subscribe to URL Cleaner with href removal also (code inside) 1 post, 1 voice

LeoXavior Scriptwright
FirefoxWindows

Small changes and addition of 'working' ?href= removal also:

function checkURL(event) {
	if(document.location.href.indexOf('?ref=') >= 0){
		location.replace(document.location.href.substring(0, document.location.href.indexOf('?ref=')));
	}
	var reg = /^(https?:\/\/([-a-z0-9]+\.)*facebook\.com)\/[^#]*#!(\/.*)/i;
	if (reg.test(location.href)) {
		document.removeEventListener('DOMNodeInserted', checkURL, true); // we need to remove the event listener or we might cause an infinite loop apparently
		location.replace(location.href.replace(reg, '$1$3'));
	}
}

// fire it up here
if (top.location == location && /\.facebook\.com$/i.test(location.hostname)) {
   document.addEventListener('DOMNodeInserted', checkURL, true);
}

Maybe could use some tweaks, but it works any suggestions for improving?