Facebook Cleaner URLS

By LeoXavior Last update Jan 25, 2011 — Installed 3,059 times.

Script Summary: Cleans Facebook URLs that don't actually take you to a new page only when it's disirable to do so.



Version: 1.0.3

Cleans Facebook URLs that don't actually take you to a new page only when it's disirable to do so.
Currently the script ignores the following pages on facebook:

  • Photos - regex & page title
  • Friends - dom/html element
  • Events - dom/html element
  • Groups - dom/html element
  • Messages(all) - dom/html element
  • Links - regex
  • Notes(all) - dom/html element
  • Apps/Games - dom/html element
Basically most pages with previous | next ajax buttons needs to be ignored
Anyone that finds other url's i'm missing in the list above or regex tips please contact me :)

// @history 1.0.3 Cleaned up some unused code
// @history 1.0.2 Updated isTopWindow() now accepts l as a location param.
// @history 1.0.1 Fixed a console error relating to top.location == location, seems to be a bug in firefox
// @history 1.0.0 Initial release

This script is a heavily modified and hopefully improved version of Jordon Kalilich's URL cleaner script.
http://userscripts.org/scripts/show/29910

Notes to developers and future road-map:

  • Sometime in the near future I will move the extra code like ignorePage() and other non specific url cleaning code to google code or github and make this userscript a stub to include the remote code only maintaining the core URL cleaning code within the userscript, that will allow future updates to the other custom code (that may need to change often) to happen alot cleaner. This will allow other scripts using this code as a @require to always have current stable versions of updated code due to the current way @require works it only downloads the file at install time resulting in @require file updates to never happen without uninstalling/reinstalling the parent script. This will happen sometime in the next few months, comments are welcome. The only other option I can think of is to request other scripts point to this script as a dependency in there frontpage or install/usage infor so that this code is installed separately, to allow updates to happen cleanly at a future time.
  • Firefox seems to have a bug in relation to top.location == location and similar see code below
You can use something like:
// Possible bug in firefox, using error trapping to fix this oddity with top.location == location
function isTopWindow(){
	try{
		if(top.location == location){
			return true;
		} else {
			return false;
		}
	} catch(e){
		return false;
	}
}
// usage:
if(isTopWindow() != false) // do something
This will catch the odd error that gets thrown in the console and allow the script to continue.