0

我想在greasemonkey中使用javascript或jquery从第一个链接重定向到另一个

       http://*.tumblr.com/post/*/*
       http://$1.tumblr.com/image/$2
4

1 回答 1

0

使用这个正则表达式

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

像这样

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

要创建您的阵列,那么您可以

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

重定向

现场版

于 2013-07-21T04:02:35.360 回答