Imacro if else Statement personal code - imacros

i need to make this on imacro comannd
if found TAG POS=1 TYPE=A ATTR=TXT:invite to click this
else
to click this TAG POS=3 TYPE=A ATTR=TXT:SeeMore

Try this simple workaround:
SET !TIMEOUT_STEP 1
SET !ERRORIGNORE YES
TAG POS=1 TYPE=A ATTR=TXT:invite
TAG POS=3 TYPE=A ATTR=TXT:SeeMore
SET !ERRORIGNORE NO
SET !TIMEOUT_STEP 6

I use Mozilla Firefox with JavaScript scripting Interface.
Copy this html below in index.html and open it with Firefox.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
invite<br>
Second link<br>
SeeMore<br>
</body>
</html>
Save this code in click.js in Imacros:
if (iimPlayCode('TAG POS=1 TYPE=A ATTR=TXT:invite') == 1){
iimPlayCode('TAG POS=1 TYPE=A ATTR=TXT:invite');
} else {
iimPlayCode('TAG POS=1 TYPE=A ATTR=TXT:SeeMore');
}
Open index.html in Firefox and run click.js.
It should work as you need.
Runs OK with this: Firefox 35.0.1, iMacros for Firefox 8.9.7, Windows 7.

Related

need help for imacros code to request first 25 "answer request" from writer on quora

i am new to imacros...
i have tried to record the imacros to request an answer from the writer but I think it's dynamically changing the pos and values...
so, looking for a way to do this...
here is the code that I have recorded
VERSION BUILD=1005 RECORDER=CR
TAG POS=12 TYPE=SVG ATTR=TXT:
TAG POS=2 TYPE=PATH ATTR=STROKE-LINECAP:round&&TXT:
TAG POS=3 TYPE=CIRCLE ATTR=CX:12&&CY:12&&R:9&&TXT:
TAG POS=1 TYPE=A ATTR=ID:__w2_wx4nZclL125_button
TAG POS=23 TYPE=SVG ATTR=TXT:
TAG POS=25 TYPE=SVG ATTR=TXT:
TAG POS=1 TYPE=A ATTR=ID:__w2_wx4nZclL134_button
TAG POS=29 TYPE=SVG ATTR=TXT:
TAG POS=31 TYPE=SVG ATTR=TXT:
TAG POS=1 TYPE=A ATTR=ID:__w2_wOt2sXY49_button
TAG POS=35 TYPE=SVG ATTR=TXT:
TAG POS=1 TYPE=DIV ATTR=ID:__w2_wJ28TPOd2_list_item
TAG POS=37 TYPE=SVG ATTR=TXT:
TAG POS=1 TYPE=A ATTR=ID:__w2_wDJBb2oM9_button
TAG POS=1 TYPE=A ATTR=ID:__w2_wx4nZclL2_submit

Extracting text with imacros

SITUATION: I am finding it difficult to EXTRACT a specific text from a website.
The template example on the iMacros website (http://wiki.imacros.net/Data_Extraction#Data_Extraction_and_Web_Scraping) for
extracting a variable from iMacros is as follows:
TAG POS=1 TYPE=SPAN ATTR=CLASS:bdytxt&&TXT:* EXTRACT=HTM
However in the html code below, the specific element text1 doesn't have a class to specify in the ATTR section. I am specifically trying to extract text1 from the example below:
//This code is within an html page
<div class="class1">
<img class="class2" src="...">
<strong>
text1
</strong>
<br>
<small>text2</small>
<small class="class3">
<br>
<em>text3:</em>
<span>
<a href="..." class="class4">
<small style="color: #aaa; font-size: 80%">text4</small>
text5
</a>
</span>
<br>
<em>text6</em>
text7,
text8
</small>
</div>
What I have tried:
I know that when I record using "Experimental event recording mode" and click on the specific text1 that I get the following code:
EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(5)>DIV>STRONG>A" BUTTON=0
I tested to see if the SELECTOR would work in the EXTRACT code like so:
TAG POS=1 TYPE=SPAN SELECTOR="HTML>BODY>DIV:nth-of-type(5)>DIV>STRONG>A" EXTRACT=TXT
but as you can imagine, it didn't.
QUESTION: Does anyone know how I can extract text1 from the above situation?
Well, there can be several ways to extract this text. For example:
TAG POS=1 TYPE=IMG ATTR=CLASS:"class2"
TAG POS=R1 TYPE=A ATTR=* EXTRACT=TXT
Or if you use 'iMacros for Chrome', here's a solution with the help of selector:
TAG SELECTOR="HTML>BODY>DIV:nth-of-type(5)>DIV>STRONG>A" EXTRACT=TXT

imacros downloading the url address

I am trying to record and as I click around a site I want to capture every url address I am landing on. Is there a way to do this?
Here is an example of my macro:
VERSION BUILD=8021970
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=https://www.meritorpartsonline.com/webapp/wcs/stores/servlet/CategoryDisplay?urlRequestType=Base&catalogId=10051&categoryId=10001&pageView=detailed&urlLangId=-1&beginIndex=0&langId=-1&top_category=10001&top=Y&parent_category_rn=10001&storeId=10154
TAG POS=1 TYPE=A FORM=ID:displayForm ATTR=ID:WC_CategoriesSidebarDisplayf_links_2_1
TAG POS=1 TYPE=A FORM=ID:displayForm ATTR=ID:WC_CategoriesSidebarDisplayf_links_2_1
TAG POS=4 TYPE=IMG ATTR=SRC:https://www.meritorpartsonline.com/wcsstore/MeritorStorefrontAssetStore/images/*
TAG POS=4 TYPE=IMG ATTR=SRC:https://www.meritorpartsonline.com/wcsstore/MeritorStorefrontAssetStore/images/*
TAG POS=4 TYPE=IMG ATTR=SRC:https://www.meritorpartsonline.com/wcsstore/MeritorStorefrontAssetStore/images/*
TAG POS=4 TYPE=IMG ATTR=SRC:https://www.meritorpartsonline.com/wcsstore/MeritorStorefrontAssetStore/images/*
TAG POS=4 TYPE=IMG ATTR=SRC:https://www.meritorpartsonline.com/wcsstore/MeritorStorefrontAssetStore/images/*
TAG POS=4 TYPE=IMG ATTR=SRC:https://www.meritorpartsonline.com/wcsstore/MeritorStorefrontAssetStore/images/*
TAG POS=1 TYPE=A FORM=ID:displayForm ATTR=ID:WC_CategoriesSidebarDisplayf_links_2_1
TAG POS=1 TYPE=A ATTR=ID:WC_BreadCrumbTrailDisplay_link_4
TAG POS=1 TYPE=A FORM=ID:displayForm ATTR=ID:WC_CategoriesSidebarDisplayf_links_2_2
TAG POS=4 TYPE=IMG ATTR=SRC:https://www.meritorpartsonline.com/wcsstore/MeritorStorefrontAssetStore/images/*
TAG POS=4 TYPE=IMG ATTR=SRC:https://www.meritorpartsonline.com/wcsstore/MeritorStorefrontAssetStore/images/*
TAG POS=4 TYPE=IMG ATTR=SRC:https://www.meritorpartsonline.com/wcsstore/MeritorStorefrontAssetStore/images/*
TAG POS=4 TYPE=IMG ATTR=SRC:https://www.meritorpartsonline.com/wcsstore/MeritorStorefrontAssetStore/images/*
TAG POS=4 TYPE=IMG ATTR=SRC:https://www.meritorpartsonline.com/wcsstore/MeritorStorefrontAssetStore/images/*
TAG POS=4 TYPE=IMG ATTR=SRC:https://www.meritorpartsonline.com/wcsstore/MeritorStorefrontAssetStore/images/*
TAG POS=4 TYPE=IMG ATTR=SRC:https://www.meritorpartsonline.com/wcsstore/MeritorStorefrontAssetStore/images/*
Play the macro below and surf the web. It will write every url that you visit, in the ‘dnlUrls.txt’ file. (Stop this macro when you want to finish tracking.)
SET !LOOP -9999999
SET urlFolder EVAL("('{{urlAddress}}' != '{{!URLCURRENT}}') ? '*' : 'noSuchFolder';")
SET urlAddress EVAL("('{{urlAddress}}' != '{{!URLCURRENT}}') ? '{{!URLCURRENT}}' : '{{urlAddress}}';")
SET !EXTRACT {{urlAddress}}
SET !ERRORIGNORE YES
SAVEAS TYPE=EXTRACT FOLDER={{urlFolder}} FILE=dnlUrls.txt
SET !ERRORIGNORE NO
WAIT SECONDS=1

Loop Specific Lines From datasource imacro

`SET !ERRORIGNORE YES
SET !DATASOURCE user.txt
SET !LOOP 1
SET !DATASOURCE_COLUMNS 4
URL GOTO=myurl
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:form1 ATTR=ID:username CONTENT={{!COL1}}
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:form1 ATTR=ID:password CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:form1 ATTR=ID:remember CONTENT=YES
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:form1 ATTR=ID:submit
SET !ERRORIGNORE YES
SET !DATASOURCE gradu.txt
SET !LOOP 1
SET !DATASOURCE_COLUMNS 4
SET MyLoop {{!LOOP}}
ADD MyLoop {{!LOOP}}
ADD MyLoop {{!LOOP}}
ADD MyLoop -1
SET !DATASOURCE_LINE {{MyLoop}}
URL GOTO=myurl
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:sourceCodeArea ATTR=*
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:formApprove ATTR=NAME:title CONTENT={{!COL1}}
TAG POS=1 TYPE=TEXTAREA FORM=ID:formApprove ATTR=NAME:description CONTENT={{!COL1}}
SET !VAR1 EVAL("var s = '{{!COL1}}'.replace(/ /g, ','); s;")
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:formApprove ATTR=NAME:tags CONTENT={{!VAR1}}
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:formApprove ATTR=ID:approveButton2
wait seconds=25
TAG POS=1 TYPE=TEXTAREA FORM=ACTION:/sketch/*/postComment ATTR=ID:commentTextArea CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/sketch/*/postComment ATTR=NAME:Submit
ADD MyLoop 1
SET !DATASOURCE_LINE {{MyLoop}}
URL GOTO=myurl
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:sourceCodeArea ATTR=*
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:formApprove ATTR=NAME:title CONTENT={{!COL1}}
TAG POS=1 TYPE=TEXTAREA FORM=ID:formApprove ATTR=NAME:description CONTENT={{!COL1}}
SET !VAR1 EVAL("var s = '{{!COL1}}'.replace(/ /g, ','); s;")
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:formApprove ATTR=NAME:tags CONTENT={{!VAR1}}
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:formApprove ATTR=ID:approveButton2
wait seconds=25
TAG POS=1 TYPE=TEXTAREA FORM=ACTION:/sketch/*/postComment ATTR=ID:commentTextArea CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/sketch/*/postComment ATTR=NAME:Submit`
I am trying to login to website using datasource user.txt and post first three lines from datasource gradu.txt.After that i want to login to next user using datasource user.txt and want to post next three lines of datasource gradu.txt.But my code not working.How can it work.here is my code.

imacro on tumblr posts for adding multiple tags

I have been using iMacros to input multiple tags when posting photos to save time. They have recently updated the site and I can not figure out how to get iMacro to enter multiple tags.
When recording a macro this is the code iMacro comes up with
TAG POS=11 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=* CONTENT=foo,
The , is needed to start a new tag. It is not starting a new tag or recording the content correctly.
I have looked at the code where the tags come up and this is it below
<section class="tag_editor" style="display: block;">
<div class="tags">
<input class="post_tags" type="text" value="" style="display: none;" name="post[tags]">
<div class="editor_wrapper">
<input class="editor borderless" type="text">
</div>
</div>
</section>
It looks like the input I need is around editor_wrapper and editor borderless and I think I need it added to FORM=NAME:NoFormName and ATTR=* in the iMacro TAG. I have tried different combinations yet iMacro will not autofill the tags for me. The new post feature on tumblr is a pop-up ajax looking window.
The old macro that worked before the site update looked like this. Not sure if it will be of any help.
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/blog/foobar/new/photo ATTR=ID:tag_editor_input CONTENT=foo,
WAIT SECONDS=.3
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/blog/foobar/new/photo ATTR=ID:tag_editor_input CONTENT=bar,
WAIT SECONDS=.3
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/blog/foobar/new/photo ATTR=ID:tag_editor_input CONTENT=foo,
Looking for help getting this to work again. It saves me a ton of time to have these tags auto filled for me.
try this one to fill the second input:
TAG POS=1 TYPE=INPUT:TEXT ATTR=CLASS:editor* CONTENT=foo,
let me know if it works