IMACROS execute a command once current link changes?

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
Sidr21
Posts: 1
Joined: Sun Apr 22, 2018 12:08 am

IMACROS execute a command once current link changes?

Post by Sidr21 » Sun Apr 22, 2018 12:16 am

As stated in the title, im trying to have imacros detect when the current url has changed and execute a command when this happens, else keep refreshing the page until the link does change. I am running the imacros add on in firefox. My current code looks like this:

var macro;

macro ="CODE:";
macro += "SET !ERRORIGNORE YES" + "\n";
macro += "SET !TIMEOUT_STEP 1" + "\n"
macro += "TAG POS=1 TYPE=A ATTR=TXT:*Some Text*" + "\n";
macro += "ADD !EXTRACT {{!URLCURRENT}}" + "\n";
macro += "REFRESH" + "\n";

for (var i=0;i<=50;i++) {

iimPlay(macro);
var link=iimGetLastExtract();
iimSet("LINK",link)

if ("LINK"= ("Some URL"))
{
break;

}
}
In the first part, the code will press on a certain text if it is present on the page, this works fine. My problem comes in during the if statement. I cant figure out how to compare the extracted link and a certain other link. I want the loop to break if the extracted link and the certain link are the same. I am very new to both Java and Imacros so any help would be greatly appreciated!
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: IMACROS execute a command once current link changes?

Post by chivracq » Sun Apr 22, 2018 8:32 pm

Sidr21 wrote:As stated in the title, im trying to have imacros detect when the current url has changed and execute a command when this happens, else keep refreshing the page until the link does change. I am running the imacros add on in firefox. My current code looks like this:

Code: Select all

var macro;

macro ="CODE:";
macro += "SET !ERRORIGNORE YES" + "\n";
macro += "SET !TIMEOUT_STEP 1" + "\n"
macro += "TAG POS=1 TYPE=A ATTR=TXT:*Some Text*" + "\n";
macro += "ADD !EXTRACT {{!URLCURRENT}}" + "\n";
macro += "REFRESH" + "\n";

for (var i=0;i<=50;i++) {

iimPlay(macro);
var link=iimGetLastExtract();
iimSet("LINK",link)

if ("LINK"= ("Some URL"))
{
break;

}
}
In the first part, the code will press on a certain text if it is present on the page, this works fine. My problem comes in during the if statement. I cant figure out how to compare the extracted link and a certain other link. I want the loop to break if the extracted link and the certain link are the same. I am very new to both Java and Imacros so any help would be greatly appreciated!
(F)CIM...! :mrgreen: (Read my Sig...)

'iimSet()' is for passing a Var from your main '.js' Script to (inside) your '.iim', you don't need it as you are still in the '.js' for your 'IF' Comparison...

And, hum..., you didn't really need a '.js' Script if you simply want to abort your Script once the Cond. has been met, it could easily be done in pure '.iim' with 'MacroError()'... :idea:

>

+Parallel Thread on SOF:
- How to make IMACROS execute a command when the current link changes?
(No Replies yet...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
User avatar
thecoder2012
Posts: 446
Joined: Sat Aug 15, 2015 5:14 pm
Location: Internet
Contact:

Re: IMACROS execute a command once current link changes?

Post by thecoder2012 » Thu May 03, 2018 2:55 am

Example without your errors:

Code: Select all

var macro;
macro ="CODE:";
macro += "SET !ERRORIGNORE YES" + "\n";
macro += "SET !TIMEOUT_STEP 1" + "\n"
macro += "TAG POS=1 TYPE=A ATTR=TXT:*Some Text*" + "\n";
macro += "ADD !EXTRACT {{!URLCURRENT}}" + "\n";
macro += "REFRESH" + "\n";

for (var i=0;i<=50;i++) {
	iimPlay(macro);
	var link=iimGetLastExtract();

	if(link == "Some URL"){
		break;
	}
}
Sidr21 wrote:I am very new to both Java and Imacros so any help would be greatly appreciated!
Java? It's Javascript!
Join 9kw.eu Captcha Service now and let your iMacros continue downloads and scripts while you sleep. - Custom iMacros? Contact me! :idea:
Post Reply