user3656551
user3656551

Reputation: 23

Extracting !URLCURRENT and editing it in imacros

I'm trying to create a macro that will extract the current url, edit it in the way described below and then be able to paste it in a new tab. I'm using Firefox 29.

For example:

I want to change this: http://url.com/a/b_c_XXXXXX_d.html to this: http://url.com/a/b_c_YYYYYY_d.html and then be able to paste it in a new tab.

Note: the macro only needs to be able to change "XXXXXX" to "YYYYYY", and there's no variation involved.

Upvotes: 1

Views: 3005

Answers (1)

edinvnode
edinvnode

Reputation: 3547

var macro;

macro ="CODE:";
macro +="SET !ERRORIGNORE YES"+"\n";
macro +="URL GOTO=http://url.com/a/b_c_XXXXXX_d.html"+"\n";
macro +="ADD !EXTRACT {{!URLCURRENT}}"+"\n";

var macro1;

macro1 ="CODE:";
macro1 +="SET !ERRORIGNORE YES"+"\n";
macro1 +="URL GOTO={{LINK}}"+"\n";


iimPlay(macro)

var link=iimGetLastExtract();

link=link.replace(/XXXXXX/,YYYYYY);

iimSet("LINK",link)
iimPlay(macro1)

Try this code and if there is an error let us know. The replace part is up to you.

Upvotes: 1

Related Questions