[Greasemonkey] Help with Replace

Scott Turner srt19170 at gmail.com
Wed Aug 3 22:23:22 EDT 2005

On 8/3/05, Randy Reed <rwreed at linkline.com> wrote:
> I'm trying to write a script that changes one href to another and I am
> encountering a frustrating error. 

This is trivial to do in Platypus. Here's the relevant code, which you can 
probably adapt:

var allurls = doc.getElementsByTagName('A');
for(var i = 0, url; url = allurls[i]; i++)
modify_single_url(doc, match_re, replace_string, url);

function modify_single_url(doc, match_re, replace_string, node) {
if (node.href) {
node.href = node.href.replace(match_re, replace_string);

-- Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/greasemonkey/attachments/20050803/20796f86/attachment-0001.htm

More information about the Greasemonkey mailing list