使用Greasemonkey和FireFox重写部分链接 [英] Rewrite parts of links using Greasemonkey and FireFox

查看:83
本文介绍了使用Greasemonkey和FireFox重写部分链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个朋友将她过去一年左右拍摄的大约20张自然照片上传到了webshots.com,但是,我刚刚为她购买了一个付费的Flickr帐户作为生日礼物,我想下载她所有来自网络快照的照片,一旦她收到有关帐户升级的电子邮件(她不在国外-无法访问互联网),就可以将它们准备好上传给Flickr.

A friend of mine uploaded about 20 or so galleries of nature shots she's done over the past year or so onto webshots.com, however, I just purchased a paid Flickr account for her as a birthday gift, and I want to download all of her photos from webshots and have them ready for her to upload to Flickr once she gets the email about her account upgrade (she's out of the country - no internet access.)

我没有访问她的webshots帐户的权限,因此我求助于Greasemonkey和DownThemAll将她的图像保存到桌面上的文件夹中.

I don't have access to her webshots account, so I've resorted to Greasemonkey and DownThemAll to start saving her images into folders on my desktop.

我对javascript有点陌生,可用于Greasemonkey的所有用户脚本"都不能完全满足我的需求.

I'm somewhat new to javascript, and all the "user scripts" available for Greasemonkey don't exactly do what I need.

加载图库页面时:

(http://[category].webshots.com/album/[album-id]), 

我需要使用Greasemonkey脚本来查找图像的所有链接:

(http://[category].webshots.com/photo/[photo-page-id])

,然后重新编写以反映此方案:

(http://community.webshots.com/photo/fullsize/[photo-page-id]) 

这容易做到吗?看起来应该如此,但我似乎无法正确解决问题.

Is this easy to do? It seems like it would be, but I can't seem to get it right.

这是我当前无法使用的Greasemonkey脚本:

// ==UserScript==
// @name           Webshot Gallery Fixer
// @namespace      WGF
// @description    Fixes webshot galleries
// @include        http://*.webshots.com/*
// ==/UserScript==

var links = document.getElementsByTagName("a"); //array
var regex = /^(http:\/\/)([^\.]+)(\.webshots\.com\/photo\/)(.+)$/i;
for (var i=0,imax=links.length; i<imax; i++) {
   links[i].href = liks[i].href.replace(regex,"$1community$3fullsize/$4");
}

推荐答案

var links = document.getElementsByTagName("a"); //array
var regex = /^(http:\/\/)([^\.]+)(\.webshots\.com\/photo\/)(.+)$/i;
for (var i=0,imax=links.length; i<imax; i++) {
   links[i].href = links[i].href.replace(regex,"$1community$3fullsize/$4");
}

应该可以解决问题

这篇关于使用Greasemonkey和FireFox重写部分链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆