Wrong format of SET - imacros

I want to run my script to check if the fuel value is above 150 to do if/else stuff.
When I try to run the script it returns with
wrong format of SET command, line 8 (Error code: 910)"
VERSION BUILD=8940826 RECORDER=FX
TAB T=1
URL GOTO=https://cannonsatoshi.com/account
TAG POS=1 TYPE=P ATTR=ID:fuel_value* EXTRACT=TXT
SET !EXTRACT_TEST_POPUP NO
SET !VAR2 {{!EXTRACT}}
SET !VAR3 EVAL(" if {{!VAR2}}=>150{
iimPlay("loop2.iim")
} else {
iimPlay("Wait.iim")
} ")

Don’t confuse Scripting Interface with the EVAL command (where only “pure” JavaScript is possible). If you want to use ‘if’-clause, try js-script like this:
iimPlayCode("TAB T=1" + "\n" + "URL GOTO=https://cannonsatoshi.com/account" + "\n" + "TAG POS=1 TYPE=P ATTR=ID:fuel_value* EXTRACT=TXT" + "\n");
if (parseInt(iimGetExtract()) >= 150)
iimPlay("loop2.iim");
else
iimPlay("Wait.iim");

Related

Imacros extracting

Ji, just a quick question:
Why does that not working properly?
var extract = iimGetLastExtract();
if (extract == "#EANF#") {
break;
};
var extractMacro = "CODE:";
extractMacro += "SAVEAS TYPE=EXTRACT FOLDER=* FILE=scraper.txt" + "\n";
var retcode = iimPlay(extractMacro);
So i want to check if last extract is null and if it is, then break the loop. I want to save !extract to file too, but im getting blank "".
Thats my scraping .iim
TAB T=1
TAG POS=1 TYPE=A ATTR=ONMOUSEDOWN:return<SP>rwt(this,'','','','{{i}}','* extract=href
Try the below code/logic, it should work
iimPlay("CODE:TAG POS=1 TYPE=A ATTR=ONMOUSEDOWN:return<SP>rwt(this,'','','','{{i}}','* extract=href);
var extract = iimGetLastExtract();
while (extract != "#EANF#")
{
iimSet("extract",extract);
iimPlay("CODE:ADD !EXTRACT {{extract}}\n SAVEAS TYPE=EXTRACT FOLDER=* FILE=scraper.txt");
}

Imacros eval firefox

Currently using Imacros and got a problem, Im using
VERSION BUILD=8961227 RECORDER=FX
Windows 7
Firefox 44.0.1
Im trying to make something for instagram and Id like if it says follow then it will set the wait time to 30, if it says following it will change the Variable 7 to 0, so far the program will run but it will accept the if statement no matter if it says follow or following and set the wait time to 30, it wont pass it on to the else statement, any solutions?
VERSION BUILD=8961227 RECORDER=FX
TAB T=1
FILTER TYPE=IMAGES STATUS=OFF
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 10
URL GOTO=https://www.instagram.com/instagram/
TAG POS=1 TYPE=BUTTON ATTR=TXT:* EXTRACT=TXT
SET !VAR0 {{!EXTRACT}}
SET !EXTRACT NULL
SET !VAR3 Follow
SET !VAR4 Following
SET !VAR7 EVAL("if (\"{{VAR0}}\" == \"{{VAR3}}\") {VAR7= 5;} else {VAR7= 0;}; ")
wait seconds = {{!VAR7}}
TAG POS=1 TYPE=BUTTON ATTR=TXT:Follow
wait seconds = {{!VAR7}}
PROMPT EXTRACT:<SP>_{{!EXTRACT}}_<BR>VAR0:<SP>_{{!VAR0}}_<BR><BR>VAR3:<SP>_{{!VAR3}}_<BR>VAR4:<SP>_{{!VAR4}}_<BR><BR>VAR7:<SP>_{{!VAR7}}_
Try this EVAL statement:
SET !VAR7 EVAL("('{{!VAR0}}' == '{{!VAR3}}') ? 30 : 0;")

go to the next step if {{!EXTRACT}} is true

i'm new here and newbie in imacros and javascript
I have made a script that will extract a random word from a page with a regex syntax.
The script is working fine, is going to page.. is search for the word and if is there will extract the word.
But i need that the script is to refresh the page until the word is found and after that to run the second imacro script
VERSION BUILD=8961227 RECORDER=FX
SET !TIMEOUT 1
SET !ERRORIGNORE YES
TAB T=1
URL GOTO=url
SEARCH SOURCE=REGEXP:"raspuns":\[\"(.[^"]*)" EXTRACT=$1
SET !VAR1 {{!EXTRACT}}
and if the word is found run the second script (if not refesh)
TAB T=2
URL GOTO=url
TAG POS=1 TYPE=TEXTAREA ATTR=AUTOCOMPLETE:off CONTENT={{!EXTRACT}}
TAG POS=1 TYPE=BUTTON ATTR=CLICK:sendMessage()&&CLASS:go&&TXT:
anyone can help me with this?
Not super sure if I know exactly what you want and as it is imacros there are some weird workarounds but this might help you
VERSION BUILD=8961227 RECORDER=FX
SET !TIMEOUT 1
SET !ERRORIGNORE YES
TAB T=1
URL GOTO=url
SEARCH SOURCE=REGEXP:"raspuns":\[\"(.[^"]*)" EXTRACT=$1
SET !VAR0 raspuns
SET !VAR1 {{!EXTRACT}}
SET !EXTRACT NULL
SET !VAR2 EVAL("('{{!VAR0}}' == '{{!VAR1}}') ? 1 : 0;")
TAB T=2
URL GOTO=url
TAG POS={{!VAR2}} TYPE=TEXTAREA ATTR=AUTOCOMPLETE:off CONTENT={{!EXTRACT}}
TAG POS={{!VAR2}} TYPE=BUTTON ATTR=CLICK:sendMessage()&&CLASS:go&&TXT:
As you didnt give a url its very hard for me to test, but point is, if if takes the word youre looking for, raspun, it will set the TAG position to 1, therefore tagging what you need, but if it doesnt, it will set the TAG pos = 0, therefore just passing through the code, hope that helps

How to replace "()" from extracted text with some other character in Imacros

I want to extract image name and then use the name to save the image
here is the js code that i use
macro += "TAG POS=1 TYPE=SPAN ATTR=ID:txt2ArtikelNr EXTRACT=TXT" + "\n";
...
...
..
macro += "ONDOWNLOAD FOLDER=* FILE={{!EXTRACT}}.jpg WAIT=YES" + "\n";
It works fine until there are brackets () in the image name. In this case it does not download the image.
e.g. If image name A123, it works fine.
If image name A (123), it does not download image
and gives me this error wrong format of SET command, line 4 (Error code: 910)
Thanks in advance
I am using firefox 38.0.5, and imacros addon 8.9.2.1
SET !EXTRACT EVAL("'{{!EXTRACT}}'.replace(/[\\(\\)]/g, '');")
If you want to replace the space sign as well, just add it into the square brackets.
And here is the code for your js-script:
macro += 'SET !EXTRACT EVAL("\'{{!EXTRACT}}\'.replace(/[\(\)]/g, \'\');")' + "\n";

Click a button if text exist in page with iMacros

I am trying to use iMacros with Firefox to click an UnFollow button ONLY if this code exist on the page...
<small class="follow-status">follows you</small>
If the above does not exist in the page source then it would run this iMacros code...
TAG POS=1 TYPE=DIV ATTR=TXT:UnFollow
From what I have read, there is no if/else type syntax but you can run Javascript with
EVAL("Javascript code here")
If anyone knows how I could do this I could really use the help
You can trick Imacros to make an If statement, but first you have to SET !ERRORIGNORE YES for this macro. Then:
SET EXTRACT NULL
'if this exist you extract the text(even if you know it)
'if doesn't exist should return error but we turned that off; Extract remains Null
TAG POS=1 TYPE=SMALL ATTR=TXT:follows<SP>you EXTRACT=TXT
SET !VAR1 EVAL("var text=\"{{!EXTRACT}}\"; if(text==\"follows you\") text = \"jibber\";else text = \"UnFollow\";text;")
'this one executes if the text is right, if not should give error but we turned that off
TAG POS=1 TYPE=DIV ATTR=TXT:{{!VAR1}}
Use a javascript file for this
run();
function run() {
var exists = doesElementExist();
alert('element exists? ' + exists);
if (exists) {
iimPlay('CODE: TAG POS=1 TYPE=DIV ATTR=TXT:UnFollow');
}
else {
// do something else here
}
}
// test if element exists
function doesElementExist() {
iimDisplay('looking for small element with class "follow-status" on page');
var code = iimPlay('CODE: SET !TIMEOUT_TAG 1\n'
+ 'TAG POS=1 TYPE=SMALL ATTR=CLASS:follow-status EXTRACT=TXT');
if (code !==1) {
return false;
}
var extract = iimGetLastExtract();
if (extract === '#EANF#') {
return false;
}
return true;
}