Do action after looping TAG in JS

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
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Do action after looping TAG in JS

Post by Cornysz » Tue Apr 21, 2020 5:34 pm

BUILD=8970419
Freeware
Win 10
Firefox 56

Hi, how to do action but after looped TAG? This is my script

Code: Select all

var macro;
macro = "CODE:";
macro += "VERSION BUILD=8970419 RECORDER=FX" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "TAB T=1" + "\n";

//nama
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:O6wiAW* EXTRACT=TXT" + "\n";
macro += "SET Va1 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=SPAN ATTR=class:_341bF0 EXTRACT=TXT" + "\n";
macro += "SET Va2 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:_18SLBt EXTRACT=TXT" + "\n";
macro += "SET Va3 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=A ATTR=DATA-SQE:link&&HREF:https://shopee.co.id/* EXTRACT=HREF" + "\n";
macro += "SET url {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:_3amru2 EXTRACT=TXT" + "\n";
macro += "SET Va4 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "SET !EXTRACT {{Va1}}" + "\n";
macro += "ADD !EXTRACT {{Va2}}" + "\n";
macro += "ADD !EXTRACT {{Va3}}" + "\n";
macro += "ADD !EXTRACT {{url}}" + "\n";
macro += "ADD !EXTRACT {{Va4}}" + "\n";
macro += "SAVEAS TYPE=EXTRACT FOLDER=* FILE=kornismacro.csv" + "\n";
//Click
macro += 'EVENT TYPE=CLICK SELECTOR="#main>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(2)>BUTTON:nth-of-type(2)" BUTTON=0' + "\n";

for (var i=1;i<51;i++){
iimSet("i",i)
iimPlay(macro);
};
So my expectation is, after TAG Loop (50 times) then click a button (//Click), but the reality is after 1 tag, the button clicked and looping for 50 times. How to fix that? Thank you in advance
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Do action after looping TAG in JS

Post by chivracq » Tue Apr 21, 2020 6:18 pm

Cornysz wrote:
Tue Apr 21, 2020 5:34 pm

Code: Select all

BUILD=8970419 Freeware
Win 10
Firefox 56
Hi, how to do action but after looped TAG? This is my script

Code: Select all

var macro;
macro = "CODE:";
macro += "VERSION BUILD=8970419 RECORDER=FX" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "TAB T=1" + "\n";

//nama
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:O6wiAW* EXTRACT=TXT" + "\n";
macro += "SET Va1 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=SPAN ATTR=class:_341bF0 EXTRACT=TXT" + "\n";
macro += "SET Va2 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:_18SLBt EXTRACT=TXT" + "\n";
macro += "SET Va3 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=A ATTR=DATA-SQE:link&&HREF:https://shopee.co.id/* EXTRACT=HREF" + "\n";
macro += "SET url {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:_3amru2 EXTRACT=TXT" + "\n";
macro += "SET Va4 {{!EXTRACT}}" + "\n";

macro += "SET !EXTRACT NULL" + "\n";
macro += "SET !EXTRACT {{Va1}}" + "\n";
macro += "ADD !EXTRACT {{Va2}}" + "\n";
macro += "ADD !EXTRACT {{Va3}}" + "\n";
macro += "ADD !EXTRACT {{url}}" + "\n";
macro += "ADD !EXTRACT {{Va4}}" + "\n";
macro += "SAVEAS TYPE=EXTRACT FOLDER=* FILE=kornismacro.csv" + "\n";
//Click
macro += 'EVENT TYPE=CLICK SELECTOR="#main>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(2)>BUTTON:nth-of-type(2)" BUTTON=0' + "\n";

for (var i=1;i<51;i++){
iimSet("i",i)
iimPlay(macro);
};
So my expectation is, after TAG Loop (50 times) then click a button (//Click), but the reality is after 1 tag, the button clicked and looping for 50 times. How to fix that? Thank you in advance

Yeah, but make sure to open your Threads in the correct Sub-Forum, or I don't answer/help, this one has nothing to do with the 'Data Extraction' Sub-Forum... :!:
Threads about a '.js' Script belong to the 'iMacros for FF' Sub-Forum, where this Thread will eventually get moved to, by the Forum Admin...

>>>

So you'll have to wait until the Thread got moved before I will eventually answer, I can't move it myself... :(
(And don't even think of opening a Duplicate, ah-ah...!, as this is SPAM, and a Show-Killer for me to ever help a User (again), just saying... :!: )
And you'll also first have to finish your previous Thread "correctly" for me to help you on this one anyway... I had already mentioned it when you started your 2nd Thread without following up anymore and not finishing your 1st Thread "completely correctly"... :!:

And, LOL..., I actually already gave you the Solution to this one in your previous Thread, ah-ah...! :P
- (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...
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Re: Do action after looping TAG in JS

Post by Cornysz » Wed Apr 22, 2020 1:50 am

chivracq wrote:
Tue Apr 21, 2020 6:18 pm
Yeah, but make sure to open your Threads in the correct Sub-Forum, or I don't answer/help, this one has nothing to do with the 'Data Extraction' Sub-Forum... :!:
Threads about a '.js' Script belong to the 'iMacros for FF' Sub-Forum, where this Thread will eventually get moved to, by the Forum Admin...
Ahah, sorry i didn't see it. So just wait the Forum Admin to move it right?
chivracq wrote:
Tue Apr 21, 2020 6:18 pm
So you'll have to wait until the Thread got moved before I will eventually answer, I can't move it myself... :(
(And don't even think of opening a Duplicate, ah-ah...!, as this is SPAM, and a Show-Killer for me to ever help a User (again), just saying... :!: )
And you'll also first have to finish your previous Thread "correctly" for me to help you on this one anyway... I had already mentioned it when you started your 2nd Thread without following up anymore and not finishing your 1st Thread "completely correctly"... :!:
And, LOL..., I actually already gave you the Solution to this one in your previous Thread, ah-ah...! :P
I don't know how to finish it, i mean in this thread, this is my final changes on my script. Sometimes i change my mind to delete some line of code that i ask in previous thread :wink: . And btw where is the solution in my previous thread? it is to make sub-script? thank you
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Do action after looping TAG in JS

Post by chivracq » Wed Apr 22, 2020 3:36 am

Cornysz wrote:
Wed Apr 22, 2020 1:50 am
Ahah, sorry i didn't see it. So just wait the Forum Admin to move it right?

Beh..., yep...! I "reported" your Thread to get moved when I posted my Reply and he actually "handled" the Forum earlier today, answering a few Threads and moving the ones that needed to be moved and deleting Spammers, so I don't know when he will check the Forum again... :oops:

"I didn't see it.", yeah..., not complicated to select the "correct" Sub-Forum when opening a Thread, all the Sub-Forums have Descriptive Names and an Explanation of which Threads belongs in them... :roll:
The 'Data Extraction' Sub-Forum was perfect for your 1st Thread, your 2nd one actually also already rather belonged to the 'iMacros for FF' Sub-Forum as it was also (purely) related to a '.js' Script, but it was related to 'iimGetExtract()' which is related to Data Extraction..., so I didn't say anything 8) , but this current one is pure '.js' Script and thus belongs to the 'FF' Sub-Forum... (And when in doubt, the 'General' Sub-Forum is always OK, and you can mention in your OP that you "hesitated"...)

Oh yeah!, and selecting the "correct" Thread is also important for other Users searching the Forum, and also for Users asking for Help like you, as several Advanced Users only check for New Threads opened in the Sub-Forum(s) corresponding to their "Expertise"... And yep indeed, I am Advanced in Data Extraction, but I only have some Basic Knowledge about '.js' Scripts to be honest, as I've never used any for myself... All I know about them is from the Forum... :idea:

And from opening this current Thread in a "wrong" Sub-Forum, you miss the Expertise and potential Help of Advanced Users who subscribed to the 'iMacros for FF' Sub-Forum because they are JavaScript Gurus..., but only come to the Forum when they receive an Email Notification about a New Thread in one of the Sub-Forums they've subscribed to, with as only Information at that moment, the Thread Title of that New Thread... Hence also the Importance of giving a Descriptive Title to your Threads, because that's the only Information they will have at that moment, to decide if they come to the Forum to have a look at your Thread or not... :idea:

>>>
Cornysz wrote:
Wed Apr 22, 2020 1:50 am
I don't know how to finish it, i mean in this thread, this is my final changes on my script. Sometimes i change my mind to delete some line of code that i ask in previous thread :wink: . And btw where is the solution in my previous thread? it is to make sub-script? thank you

Yeah well, you asked about a (Global) 'replace()', I answered that, then you move to stg else without really reacting to my Answer and posting how you implemented it. If each time you ask a Qt, I give you an Answer, and then you move to stg else/different, "ignoring" my Answer, then it's a bit useless if I answer your Qt's if you don't do anything with them... Just like I said, I've already given you the Answer to your Qt in this current Thread, but you didn't do anything with it... Read your previous Thread again... :wink:

And what you want is a Basic Principle for '.js' Scripts, you will also find it correctly implemented in maybe 80% or 90% of the 100's of '.js' Script Samples you must have probably already found on the Forum... Have a look / study a few Examples of '.js' Scripts and you should understand that "Principle"... Or you may want to reconsider using '.js' Scripts, '.iim' Scripts are much easier to use, I find myself... (And I've never used any '.js' Script...) I didn't really understand why you chose for a '.js' Script, you already had your Script working at the end of your 1st Thread... :?
- (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...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Do action after looping TAG in JS

Post by chivracq » Wed Apr 22, 2020 3:31 pm

Alright, you got "lucky", the Forum Admin has already responded to my Ping and has already moved your Thread to the 'iMacros for FF' Sub-Forum... 8)

OK, so now I'm "waiting" for you to follow up/finish your previous Thread "a bit correctly" before answering this one "concretely"... :wink:

But again, I already gave you the "Solution"/"Concept" in your previous Thread in this Post when I explained the Workflow/Logic you would need for your '.js' Script... 8)
And again-again also, this is a Basic Principle for writing/using '.js' Scripts, if you don't understand it, you are going to make your Life very difficult by sticking to using '.js' Scripts, ah-ah...! :(
And also again-again-again, you'll find 100's of Examples on the Forum... The only "Difference" with your Case when (other) Users ask(ed) Qt's about that Principle, is that they usually (only) want to loop a sub-part of their Script, and sometimes already inside one Looping, while you, from the other end, want to take that sub-part out of the Looping... But the Result and the Concept are exactly the same...! :idea:
- (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...
Post Reply