Facebook URL Cleaner

By Jordon Kalilich Last update Nov 17, 2009 — Installed 4,820 times. Daily Installs: 188, 72, 46, 31, 31, 16, 22, 22, 23, 23, 18, 21, 11, 11, 13, 10, 17, 10, 9, 8, 18, 12, 99, 112, 115, 197, 172, 169, 130, 84, 79, 89

There are 3 previous versions of this script.

// ==UserScript==
// @name          Facebook URL Cleaner
// @version       6
// @date          2009-11-17
// @description   Cleans Facebook URLs that don't actually take you to a new page.
// @namespace     http://www.theworldofstuff.com/greasemonkey/
// @copyright     Copyright 2008-2009 Jordon Kalilich (http://www.theworldofstuff.com/)
// @license       GNU GPL version 3 or later; http://www.gnu.org/copyleft/gpl.html
// @require       http://usocheckup.dune.net/29910.js?maxage=5
// @include       http*://*.facebook.com/*
// ==/UserScript==

// to enable when browsing photo galleries, change the following value to true:
var enableInGalleries = false;

function checkURL(event) {
   if (reg.test(location.href)) {
      if (!(/photo\.php.*#.*photo\.php/i.test(location.href)) || enableInGalleries) { // thanks, discrete structures
         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'));
      }
   }
}

if (top.location == location && /\.facebook\.com$/i.test(location.hostname)) {
   var reg = /^(https?:\/\/([-a-z0-9]+\.)*facebook\.com)\/[^#]*#(\/.+)/i;
   document.addEventListener('DOMNodeInserted', checkURL, true);
}