Need some help with imacros

B2B

Regular Member
Joined
Mar 19, 2018
Messages
262
Reaction score
60
Hey, I can't figure out what to do here-
(This script is to automate sending of messages on FF dot net, the * I added after TXT is showing some other page entirely. Inspect element is showing some kind of a href for that element)

TAB CLOSEALLOTHERS
'SET !PLAYBACKDELAY 1.50
SET !LOOP 1
SET !ERRORIGNORE YES
URL GOTO=https://www.fanfiction (dot) net/book/Zombie-Survival-Guide/
TAG POS=1 TYPE=A ATTR=TXT:*
TAG POS=1 TYPE=A ATTR=TXT:PM
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:subject CONTENT=Hey!
TAG POS=1 TYPE=TEXTAREA ATTR=NAME:message CONTENT="How you doin'?"
TAG POS=1 TYPE=BUTTON:SUBMIT ATTR=TXT:"Send Message"


Thanks again,
 
Hey, I can't figure out what to do here-
(This script is to automate sending of messages on FF dot net, the * I added after TXT is showing some other page entirely. Inspect element is showing some kind of a href for that element)

TAB CLOSEALLOTHERS
'SET !PLAYBACKDELAY 1.50
SET !LOOP 1
SET !ERRORIGNORE YES
URL GOTO=https://www.fanfiction (dot) net/book/Zombie-Survival-Guide/
TAG POS=1 TYPE=A ATTR=TXT:*
TAG POS=1 TYPE=A ATTR=TXT:pM
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:subject CONTENT=Hey!
TAG POS=1 TYPE=TEXTAREA ATTR=NAME:message CONTENT="How you doin'?"
TAG POS=1 TYPE=BUTTON:SUBMIT ATTR=TXT:"Send Message"


Thanks again,
Hi,
I guess there is a line missing to click on the profile before.. maybe I am wrong... let me know what is that you are trying to do.. i can help to fix it
 
I have replaced the username with the wildcard * that's all I have done. I would really appreciate any help
 
I have replaced the username with the wildcard * that's all I have done. I would really appreciate any help
Hi,
I guess there is a line missing to click on the profile before.. maybe I am wrong... let me know what is that you are trying to do.. i can help to fix it

I am trying to automate sending messages on Fanfiction dot net. Newbie when it comes to coding (it terrifies me)
 
Do you login first manually and then trying to run this imacro script? Because when I tried i need to click on the username first and the click on PM then enter message and click send ? Is that right?
 
Do you login first manually and then trying to run this imacro script? Because when I tried i need to click on the username first and the click on PM then enter message and click send ? Is that right?
Yes, you need to login first manually. You won't be able to send PM for the first 12 hours. I will PM you my credentials as soon as I finish typing this message.
 
I am not too familiar with iMacro, but you can try run a Javascript to run a loop for all the links on the current page and those that contain /u/ are the ones you are looking for.

I will help you get started:
Code:
//   This strips the document links and stores in array
var arr = [], l = document.links;
//   This is a loop to loop through all the links
for(var i=0; i<=l.length; i++) {
   //   if it includes /u/ it must be a user link
   if ((l[i].href).includes("/u/")) {
       //   After this you do whatever you want your script to do (aka go to page etc)
       alert(l[i].href)
   }
}
Something like this would print out all the links that contain /u/. After that you want the macro to path to those links in a new tab.

Also for the Logins or for future use, use the XPath of the element it's alot better (and easier).
 
  • Like
Reactions: B2B
I am not too familiar with iMacro, but you can try run a Javascript to run a loop for all the links on the current page and those that contain /u/ are the ones you are looking for.

I will help you get started:
Code:
//   This strips the document links and stores in array
var arr = [], l = document.links;
//   This is a loop to loop through all the links
for(var i=0; i<=l.length; i++) {
   //   if it includes /u/ it must be a user link
   if ((l[i].href).includes("/u/")) {
       //   After this you do whatever you want your script to do (aka go to page etc)
       alert(l[i].href)
   }
}
Something like this would print out all the links that contain /u/. After that you want the macro to path to those links in a new tab.

Also for the Logins or for future use, use the XPath of the element it's alot better (and easier).
@arundamo helped my finding the right element, here's the code we have come up with-
(We haven't factored in auto clicking the next page, I also came across their spam filter - after every 3 message sent it shows 'duplicate message' which can be bypassed by making any change, like a fullstop so we used !datasource)
Code:
VERSION BUILD=1005 RECORDER=CR
TAB T=1
SET !DATASOURCE Example.csv
'Increase the current position in the file with each loop
SET !DATASOURCE_LINE {{!LOOP}}
SET !LOOP 1
TAG POS={{!LOOP}} TYPE=A ATTR=HREF:https://www.fanfiction.net/u/*
WAIT SECONDS=1
TAG POS=1 TYPE=A ATTR=TXT:PM
WAIT SECONDS=1
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:subject CONTENT={{!COL1}}
WAIT SECONDS=1
TAG POS=1 TYPE=TEXTAREA ATTR=NAME:message CONTENT={{!COL2}}
WAIT SECONDS=1
TAG POS=1 TYPE=BUTTON:SUBMIT ATTR=TXT:"Send Message"
WAIT SECONDS=30
Back
Back
Back

We haven't tested it very well ( all aspects). Would love input from you! (also is it possible using javascript to not send the same message to the same username again? )
 
I hope you got the help you needed man from the post above.. It is an easy fix though.
 
  • Like
Reactions: B2B
The code looks good. However, you could just use Tabs instead of Back.

wiki.imacros.net/TAB

You could do the user yes. It would need two things:

Function to check if user has already been messaged.

Add user to database

After submitting you would need to reopen the CSV file and put the user id in.

Repeat process.

But this is inefficient -if you message let's say 10000 users the program has to keep running through the users it takes a while having to load the file everytime the script runs.

If after a while you want to make it more efficient you could write something fast using -
AWS --> You send it an API request to check user --> Brings back true/false then run script.
User message complete --> Send request as user done.

I think you get 1,000,000 free requests a month.

If I were you I would use selenium rather than using iMacro it would be a whole lot easier but that's my personal opinion.
 
  • Like
Reactions: B2B
The code looks good. However, you could just use Tabs instead of Back.

wiki.imacros.net/TAB

You could do the user yes. It would need two things:

Function to check if user has already been messaged.

Add user to database

After submitting you would need to reopen the CSV file and put the user id in.

Repeat process.

But this is inefficient -if you message let's say 10000 users the program has to keep running through the users it takes a while having to load the file everytime the script runs.

If after a while you want to make it more efficient you could write something fast using -
AWS --> You send it an API request to check user --> Brings back true/false then run script.
User message complete --> Send request as user done.

I think you get 1,000,000 free requests a month.

If I were you I would use selenium rather than using iMacro it would be a whole lot easier but that's my personal opinion.
That would be quite complicated...You seem very knowledgeable, I skillshare good for taking selenium courses? Where did you learn??

Also, If I want the script to auto click the 'next' button after the page is done, what should I add???
Thanks a lot @Digital Finger
 
That would be quite complicated...You seem very knowledgeable, I skillshare good for taking selenium courses? Where did you learn??

Also, If I want the script to auto click the 'next' button after the page is done, what should I add???
Thanks a lot @Digital Finger
Just google on youtube using selenium I would suggest using Pycharms or something with it (python is extremely easy).
And you mean on iMacro or javascript?
 
  • Like
Reactions: B2B
Just google on youtube using selenium I would suggest using Pycharms or something with it (python is extremely easy).
And you mean on iMacro or javascript?
Whichever way you are comfortable with, you may add it in the below code-
Code:
VERSION BUILD=1005 RECORDER=CR
TAB T=1
SET !DATASOURCE Example.csv
'Increase the current position in the file with each loop
SET !DATASOURCE_LINE {{!LOOP}}
SET !LOOP 1
TAG POS={{!LOOP}} TYPE=A ATTR=HREF:https://www.fanfiction.net/u/*
WAIT SECONDS=1
TAG POS=1 TYPE=A ATTR=TXT:PM
WAIT SECONDS=1
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:subject CONTENT={{!COL1}}
WAIT SECONDS=1
TAG POS=1 TYPE=TEXTAREA ATTR=NAME:message CONTENT={{!COL2}}
WAIT SECONDS=1
TAG POS=1 TYPE=BUTTON:SUBMIT ATTR=TXT:"Send Message"
WAIT SECONDS=30
Back
Back
Back
 
Whichever way you are comfortable with, you may add it in the below code-
Code:
VERSION BUILD=1005 RECORDER=CR
TAB T=1
SET !DATASOURCE Example.csv
'Increase the current position in the file with each loop
SET !DATASOURCE_LINE {{!LOOP}}
SET !LOOP 1
TAG POS={{!LOOP}} TYPE=A ATTR=HREF:https://www.fanfiction.net/u/*
WAIT SECONDS=1
TAG POS=1 TYPE=A ATTR=TXT:PM
WAIT SECONDS=1
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:subject CONTENT={{!COL1}}
WAIT SECONDS=1
TAG POS=1 TYPE=TEXTAREA ATTR=NAME:message CONTENT={{!COL2}}
WAIT SECONDS=1
TAG POS=1 TYPE=BUTTON:SUBMIT ATTR=TXT:"Send Message"
WAIT SECONDS=30
Back
Back
Back
Like the next button on this page-
https://www.fanfiction.net/anime/Dragon-Ball-Z/

(It shoudn't be limited by only this category- So I can use it on any such page like-
https://www.fanfiction.net/anime/Naruto/
https://www.fanfiction.net/anime/Soul-Eater/
https://www.fanfiction.net/book/Vampire-Academy/
etc)
 
Like the next button on this page-


(It shoudn't be limited by only this category- So I can use it on any such page like-

etc)
You can use the XPATH of the element or the CSS Selector to click on the button:
TAG SELECTOR="body.yes-fontsmoothing:nth-child(2) div.xcontrast_outer:nth-child(5) div.xcontrast.maxwidth div:nth-child(1) center:nth-child(9) > a:nth-child(6)"
 
  • Like
Reactions: B2B
You can use the XPATH of the element or the CSS Selector to click on the button:
I found out that each page has 25 posts, so the script has to execute 'next button' after every 25 messages sent, How do I incorporate such thing I'm confused.
I owe you BIG TIME!
 
I found out that each page has 25 posts, so the script has to execute 'next button' after every 25 messages sent, How do I incorporate such thing I'm confused.
I owe you BIG TIME!
Unfortunately, I cannot code this right now since I’m not on pc (on mobile).

As far as I’m aware you would need a conditional statement. For example:

If link is last link then
Click link next


You would need to do this in JavaScript since iMacro doesn’t not support conditional statements.

Otherwise if you’re challenge do this in python once you learn this (24 hours it will take you) you can bot anything.
 
  • Like
Reactions: B2B
Send me your account details via pm.

and the messages you want to send to users.
 
Back
Top