running a script whenever a page changes?

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
Forum rules
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
zwollner
Posts: 4
Joined: Sat Jun 16, 2007 1:24 pm

running a script whenever a page changes?

Post by zwollner » Sat Jun 16, 2007 1:41 pm

I made a script that works fine, but I want it to run whenever a certain part of one page changes to something specific.

Like having an infinite loop that checks the page for something and then runs another script?
If so, I'd love to know how to do this.

Thanks in advance.
Last edited by zwollner on Mon Jul 09, 2007 6:23 pm, edited 1 time in total.
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Wed Jun 20, 2007 10:49 pm

You can create a TAG command that clicks on the link that comes up when the game appears. Then you run this macro (basically only a macro with one line!) inside a loop until the TAG command finds the link. iimPlay will return a negative value until the link appears. Then you can start the second macro (that plays the game).
zwollner
Posts: 4
Joined: Sat Jun 16, 2007 1:24 pm

Post by zwollner » Thu Jun 21, 2007 12:10 am

Thanks for the reply, but I tried that (I think i did it right) but when I run it, I get "Error# 801 in line:0, TAG not found" and then the loop i have running just stops. I need it to keep looping and checking for that TAG.

This is the main macro that I have looping:

Code: Select all

i = iimPlay("check",60);

if (i >= 0) {
    iimPlay("player",60);
};

and this is the "outwit-check"

Code: Select all

TAG POS=1 TYPE=A ATTR=ID:imInToggle
Last edited by zwollner on Mon Jul 09, 2007 6:24 pm, edited 1 time in total.
zwollner
Posts: 4
Joined: Sat Jun 16, 2007 1:24 pm

Post by zwollner » Thu Jun 28, 2007 2:15 pm

So no one know how to keep this from not erroring out when this TAG is not found:
"TAG POS=1 TYPE=A ATTR=ID:imInToggle"
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Thu Jun 28, 2007 7:12 pm

You can use a huge timeout value (e. g. 60000 seconds) so the TAG command does not time out until the item appears. You can use SET !TIMEOUT 60000 for this.

Or you create a javascript that calls the TAG command in a loop and checks for the return value of the iimPlay command. If it is > 0 then the TAG command found the text => you can start the next macro.
OrkyDD
Posts: 11
Joined: Thu Sep 20, 2007 2:57 pm

Post by OrkyDD » Thu Sep 20, 2007 7:13 pm

Check out GreaseMonkey. This will do exactly what you're looking for.

You can have it run js code whenever a certain domain or page is loaded. This code would run your script.
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Thu Sep 20, 2007 9:21 pm

So no one know how to keep this from not erroring out when this TAG is not found:
We know ;)

Please see http://wiki.imacros.net/%21ERRORIGNORE
Post Reply