0

i want to redirect from the first link to the other using javascript or jquery in greasemonkey

       http://*.tumblr.com/post/*/*
       http://$1.tumblr.com/image/$2
shreef_1990
  • 45
  • 1
  • 8
  • 1
    Is not a duplicate it is a brand new one i need the redirector to be case sensitive to the formula of the i/p to get a definitive o/p also as you see i want to implement the first and second variable $1,2 and ignore the 3rd so both examples you mention which i was already read them are in complete in my opinion but if you can put the answer using these examples which i could not at all then please By all means and Thank You For Your help – shreef_1990 Jul 21 '13 at 03:40
  • None of those details are in your question! And it's still not clear what you are trying to do exactly. Nevertheless, all manner of redirects and regex location swaps have already been asked and answered. This question is a duplicate as well as unclear. The best match requires clarification on your part. – Brock Adams Jul 21 '13 at 04:08
  • I don't see this as a duplicate of the question linked to, as this asks for a very different thing. – F-3000 Apr 01 '14 at 06:27

1 Answers1

0

Use this regex

/^http:\/\/(.*).twitter.com\/post\/(.*)\/(.*)/g

Like this

var regexp = new RegExp(/^http:\/\/(.*).twitter.com\/post\/(.*)\/(.*)/g);
var results = regexp.exec(window.location.href);

To create your array, then you can

if(results){
    window.location="http://"+results[1]+".twitter.com/image/"+results[2]+"/"+results[3];
}

To redirect

Live Version

Graham P Heath
  • 7,009
  • 3
  • 31
  • 45