News:

Help! We're trapped in the computer, and the computer is trapped in 2008! Someone call the time police!

Main Menu

[Java] Looking for some regex help (greasemonkey script)

Started by LordVader, January 31, 2010, 05:18:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LordVader

Working on a script for facebook and im try'n to catch url's that get hashes appended to them and redirect the page to the proper url without the hash..
for example:
http://www.facebook.com/<username>?v=app_2392950137&ref=profile#/reqs.php

I would like to redirect back to:
http://www.facebook.com/reqs.php

The problem is there is a wide variety of possible urls in many combinations i've tried some of the url cleaner script exampe code and the regex catches most but not all the above example is not caught in this reqex:
var reg = /^(http?:\/\/([-a-z0-9]+\.)*facebook\.com)\/[^#]+#(\/.+)/i;
var ugly = reg.test(window.location.href);

LordVader

#1
Got it solved, the reqex does work, just needed to adjust how I was using it used this as an example it works pretty good actually:
http://userscripts.org/scripts/review/29910

And this is what I needed it for:
http://userscripts.org/scripts/review/57047

If anyone has any suggestions for the above script feel free :)