Facebook URL Cleaner

By Jordon Kalilich Last update Oct 7, 2010 — Installed 2,490,030 times.

Photo URL cleaning

in
Subscribe to Photo URL cleaning 3 posts, 2 voices



Ronald Troyer Scriptwright

First off, this is a GREAT script. Very helpful.

But I have one major problem. When browsing images, if you click through too fast, the page will continue to jump back to previous items as the browser does catchup with the JavaScript. This cannot be resolved with a simple exclude filter, because if http://www.facebook.com/photo.php* is used if you go home or anywhere else from the photos page it will not clean the URL. If you use http://www.facebook.com/photo.php*photo.php, logically, at first glance it should work. But the problem is that the JavaScript is executed before the bad URL. So it's already running and just waiting for a bad URL once the photos are loaded. So that acts like you have never wrote that exclude. Is it possible to edit this script to not try to correct the photo URLs if they have photo.php*photo.php in them?

 
Jordon Kalilich Script's Author

That's a good idea. The photo thing has always annoyed me too; my current "fix" is to go through photos very slowly.

 
Ronald Troyer Scriptwright

Hey, I worked the revision into the code. Basically if you are browsing around the photos section it will do nothing if there are two 'photo.php's in the title. Here is the code.

// ==UserScript==
// @name          Facebook | URL Cleaner
// @namespace     http://www.theworldofstuff.com/greasemonkey/
// @description   Cleans Facebook URLs that don't actually take you to a new page.
// @include       http://*.facebook.com/*
// ==/UserScript==

window.gm_cleanURL = function() {
   // if the url is ugly
   var reg = /^(https?:\/\/([-a-z0-9]+\.)*facebook\.com)\/[^#]+#(\/.+)/i;
   
   // Photo exception added 4/15/09 by Ron Troyer
   // if the url is *photo.php*photo.php* 
   var photo = /.*photo\.php.*photo\.php.*/i;
   
	//change it if url is ugly and not photo page
   if ((reg.test(window.location.href)) && (!(photo.test(window.location.href)))) {
      var foo = window.location.href.replace(reg,'$1$3');
      window.location.replace(foo);
   }
   // if not, wait till it is
   else {
      window.setTimeout(gm_cleanURL, 2000);
   }
}
gm_cleanURL();

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel