I can't solve a problem with iMacros and it is really bugging me, so I would really appreciate if someone could help me. I hope I've opened the topic on the correct board; otherwise, please forgive me, for this is my first post.
I spent hours and hours going through the wiki and this forum, but I cannot reach my goal of selecting checkboxes with the target text next to them on a specific website. So I'm starting to wonder if it's the problem of the HTML code, or if I'm doing something entirely wrong. I will describe the details below.
1. Config Info:
iMacros for Firefox plugin 8.9.7, free (VERSION BUILD=8970419); browser: Pale Moon 28.9.3; OS: Windows 10 Pro 64-bit English
2. Target site code:
The text content were replaced with general English terms because they were originally in Hungarian. (Also, "etc etc" was written by me in the STYLE section because it was a rather long style section with no real impact on my issue/macro itself.)
Code: Select all
<DIV id="cuccLayer" STYLE="position:absolute; font-weight:bold; (etc etc...); ">
<center>Title1</center>
<hr>
<input type="checkbox" onClick="cuccArray[0]=1-cuccArray[0];"> 410 pcs. ITEM1<br><input type="checkbox" onClick="cuccArray[1]=1-cuccArray[1];"> 27 pcs. ITEM2<br><input type="checkbox" onClick="cuccArray[2]=1-cuccArray[2];"> 9 pcs. ITEM3<br><input type="checkbox" onClick="cuccArray[3]=1-cuccArray[3];"> 1 pc. ITEM4<br><input type="checkbox" onClick="cuccArray[4]=1-cuccArray[4];"> 89 pcs. ITEM5<br><input type="checkbox" onClick="cuccArray[5]=1-cuccArray[5];"> 23 pcs. ITEM6<br>
<hr>
<center>
<input type="image" src=".../SUBMIT.gif" title="SUBMIT" onClick="document.urlap.par1.value=cuccArrayToString(); document.urlap.Submit.value='svSelejtezes'; document.urlap.submit();">
<input type="image" src=".../sample2.gif" width="35" height="35" title="Title2" onClick="cuccHide(); return false;">
</center>
</DIV>
3. Problem:
I'm trying to write a macro that will look for specific text(s) on a site and then select the checkbox on the left side of it. For example, let's say I want to select the checkboxes to the left of the texts "pcs.<SP>ITEM3", "pcs.<SP>ITEM4" and "pcs.<SP>ITEM5".
However, the checkboxes and the text are in a shared DIV container called "cuccLayer" and the texts don't have their own HTML tags and because of that, I fail to use relative positioning, even though I went over a lot of chivracq's posts dealing with the topic. I simply cannot come up with a solution, because all the macros I wrote (even after tweaking with POS=R1,R-1, etc) seem to handle all the text as a whole (verified by extraction in test mode) and I cannot position the checkboxes. My last idea before giving up and posting here was using relative positioning with the <br>tag, with no success (maybe TAG cannot be used with empty tags lacking an end tag, or simply <br> is not recognized?)
The position/order of the checkboxes + texts are not static but PHP/JS-related, so the checkbox must be selected based on the current text following it (for more info, see: end of section 4).
4. Context, additional info about the target site and my macro:
A sudden wave of nostalgia hit me, and I started to play again with a 19 year old Hungarian browser-based online RPG which I really enjoyed as a teen. Currently, I'm progressing with the quests. However, because only a few die-hard fans play the game anymore, making money is quite difficult because of a lack of ingame economy, so the only solution left is "farming" gold (meaning doing repetitive tasks to get items that I can sell in the game's own shop itself so I can generate gold without the need to trade with other players on the ingame marketplace).
I already succesfully wrote several "farming" macros that combine both JavaScript and iMacros (this is the main reason I'm using an older build with Pale Moon, due to the need for JS support). This means that the macro automates an ingame activity called mining, and my player character automatically mines ores with various value to sell. However, after a while, my inventory overflows with heavy and cheap ores, taking up much space from the ligher and more expensive ones, such as diamonds etc. When this occurs, a new interface comes in, telling me that I'm carrying too much stuff and I need to throw away something (this currently requires manual intervention on my part, meaning my macro is not fully automated). My target code provided in section 2 is this problematic interface which lists all the amount ("x pcs."), and items ("ITEM3, ITEM4 and ITEM5") in my bag and ask me to select with the checkbox what I want to throw away with a submit form. "ITEM3, ITEM4 and ITEM5" are the heavy and cheap stuff I want to automatically dispose of, so my macro can run in a loop and keep only the expensive items.
Also, because this is a PHP/JS-based online game, the array of items in my inventory are generated by the game and therefore dynamic, so I guess the onClick="cuccArray[x]=1-cuccArray[x]; attribute of the checkbox I want to select cannot really be predicted/automated, because if the items in my inventory change, the array can be numbered completely differently.
5. Closing thoughts
I deliberately chose not to include any of my macros I experimented with, because I tried so many combinations that I wouldn't even know which one to write here. So if this seems as lazy to anyone, please forgive me. Thank you for everyone who went through my post, I would really appreciate some help. Even if my goal cannot be achieved because of the HTML structure, I would like to know it, because otherwise I will keep trying and failing. It might have started out as silly nostalgia but now the idea of me not being to solve the macro is bugging me even more than my love for that old browser RPG. I also really hope that the solution is not something really easy because I would feel very dumb (as I've mentioned, I've already succesfully did scripts and macros for other parts of this game, so I can use iMacros on at least a basic level).