Open multiple links in separate tabs.

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
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
bigkahuna
Posts: 4
Joined: Wed Jul 23, 2008 10:17 pm

Open multiple links in separate tabs.

Post by bigkahuna » Wed Jul 23, 2008 10:41 pm

What I am trying to do is go to a page with 15 links in a row, and I want to open each one in a separate tab. Is this possible? If so, can someone post the code for this. I have tried for a couple of hours now and I can't figure it out. The demo code below works fine, if you want to keep opening all the links in the same tab. However that's not what I am trying to do.

VERSION BUILD=300002
TAB T=1
TAB CLOSEALLOTHERS
TAG POS={{!LOOP}} TYPE=A ATTR=TXT:openMe<SP>inA<SP>newTab
WAIT SECONDS=1
BACK
User avatar
Tech Support
Posts: 4947
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Re: Open multiple links in separate tabs.

Post by Tech Support » Thu Jul 24, 2008 8:45 am

Here is an example macro that opens four websites:

Code: Select all

VERSION BUILD=6001001 RECORDER=FX
TAB T=1
PROMPT Enter<SP>stock<SP>symbol !VAR1 GOOG
URL GOTO=http://finviz.com/quote.ashx?t={{!VAR1}}
TAB OPEN NEW
TAB T=2
URL GOTO=http://finance.yahoo.com/q?s={{!VAR1}}
TAB OPEN NEW
TAB T=3
URL GOTO=http://finance.google.com/finance?q={{!VAR1}}&meta=hl%3Den
TAB OPEN NEW
TAB T=4
URL GOTO=http://moneycentral.msn.com/detail/stock_quote?Symbol={{!VAR1}}&getquote=Get+Quote
=> You need to add

Code: Select all

TAB OPEN NEW
TAB T={{!LOOP}}
to your macro, then it should work. I can not test it, as I do not have the URL of the website.
bigkahuna
Posts: 4
Joined: Wed Jul 23, 2008 10:17 pm

Re: Open multiple links in separate tabs.

Post by bigkahuna » Thu Jul 24, 2008 11:41 pm

I could not get it to work with that code either. Here is a link to the page I am trying to use it on.

http://searchservice.myspace.com/index. ... mit=Search

What I want to do from this page or anyone like it, is run the macro, and have it cycle down all the "Add to friends links" and have each one open in a separate tab. So in this case it would probably open up 10 new tabs.
bigkahuna
Posts: 4
Joined: Wed Jul 23, 2008 10:17 pm

Re: Open multiple links in separate tabs.

Post by bigkahuna » Fri Jul 25, 2008 11:05 pm

Is this possible?
additional001
Posts: 175
Joined: Sun Jul 06, 2008 3:24 am

Re: Open multiple links in separate tabs.

Post by additional001 » Sat Jul 26, 2008 12:36 pm

I too am having an issue very much like bigkahuna's. The website and circumstances are different but are indeed the same issue. I believe what he and I are really for is a way to simulate right clicking with the mouse and using the "Open in new tab" feature of FF. What I mean by "simulate" is achieve the same end result... not exactly use the right click menu. I looked at the Demo-Tabs sample code, I just didn't see a way to adapt it to what I need. Also I found this post by searching the forums. I admit to the fact that I do not quite understand the TAB{{!LOOP}} example. How does that work & is that what bigK and I are working towards?

Thanks for any info and help!
alexpc
Posts: 4
Joined: Fri Jul 18, 2008 2:13 am

Re: Open multiple links in separate tabs.

Post by alexpc » Sun Jul 27, 2008 5:32 pm

I was trying the same thing, and finally got some code that works for me:

TAG POS=1 TYPE=A ATTR=TXT:Link EXTRACT=HREF
TAB OPEN NEW
TAB T=2
URL GOTO={{!EXTRACT}}

Hope this helps.

Regards,
Alex.
additional001
Posts: 175
Joined: Sun Jul 06, 2008 3:24 am

Re: Open multiple links in separate tabs.

Post by additional001 » Sun Jul 27, 2008 6:19 pm

Thanks for the help Alex, but the prob with that code and indeed the demo is that it relies on you being able to actually know the URL to go to. When the URLs are dynamic in nature this is not so easy.

Let me explain further what I am trying to do and hope someone can enlighten me on how to code it.

A page is loaded with several photos on it (easy enough)
Once the page is loaded Two Tabs are opened (also easy enough)
TAG POS=1 TYPE=A ATTR=TXT:Add<SP>Comment (content from the line is then loaded in Tab 2)
TAG POS=2 TYPE=A ATTR=TXT:Add<SP>Comment (content in this tab needs to go in Tab 3)


then the following code would I think work.. (during testing I didn't use a close tab command because I wanted to make sure it worked first)

Code: Select all

TAB T=2
TAG POS=1 TYPE=A ATTR=TXT:Add<SP>a<SP>comment
TAG POS=1 TYPE=TEXTAREA FORM=ACTION:/?mysession=cmVnaXN0cmF0aW9uX2FkZGltYWdlY29tbWVudCZwaWNpZD0yOTk4MTk5OSZ1c2VyaWQ9OTQ3MTEzNyZjYW1lZnJvbT12aWV3aW1hZ2Vjb21tZW50cw== ATTR=ID:commentText CONTENT=L$<SP>&
TAG POS=1 TYPE=TEXTAREA FORM=ACTION:/?mysession=cmVnaXN0cmF0aW9uX2FkZGltYWdlY29tbWVudCZwaWNpZD0yOTk4MTk5OSZ1c2VyaWQ9OTQ3MTEzNyZjYW1lZnJvbT12aWV3aW1hZ2Vjb21tZW50cw== ATTR=ID:commentText CONTENT=L$<SP>&<SP>♥<SP><BR><BR>(Posted<SP>by<SP>L$<SP>&<SP>♥<SP>Script)
TAG POS=1 TYPE=INPUT:IMAGE FORM=ACTION:/?mysession=cmVnaXN0cmF0aW9uX2FkZGltYWdlY29tbWVudCZwaWNpZD0yOTk4MTk5OSZ1c2VyaWQ9OTQ3MTEzNyZjYW1lZnJvbT12aWV3aW1hZ2Vjb21tZW50cw== ATTR=ID:btnPostComment
User avatar
Tech Support
Posts: 4947
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Re: Open multiple links in separate tabs.

Post by Tech Support » Mon Jul 28, 2008 10:04 pm

Hi, this macro works in our tests:

Code: Select all

TAB T=1
TAB OPEN NEW
TAB T={{!LOOP}}
URL GOTO=http://www.iopus.com/imacros/demo/v6/pos/index.htm 
TAG POS={{!LOOP}} TYPE=A ATTR=TXT:Click<SP>to<SP>open<SP>this<SP>page 
TAB T=1
The macro opens each of the three pages in its own tab. Note that the macro also opens a 4th tab which is not used, that is because in the first run the macro uses the first tab to display the URL, but TAB OPEN NEW opens a second tab. If this is a problem, you can avoid it by using the Javascript scripting interface. It gives you more precise control then the simple LOOP button.
User avatar
Tech Support
Posts: 4947
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Re: Open multiple links in separate tabs.

Post by Tech Support » Mon Jul 28, 2008 10:05 pm

Screenshot:
3tabs.png
bigkahuna
Posts: 4
Joined: Wed Jul 23, 2008 10:17 pm

Re: Open multiple links in separate tabs.

Post by bigkahuna » Wed Jul 30, 2008 1:11 am

So close to working... I tried it and it does work if I put the URL in the code for each page, however that is very slow and time consuming. Is there a way this script can run right from the page it is ran on without having to enter the URL in the code?
additional001
Posts: 175
Joined: Sun Jul 06, 2008 3:24 am

Re: Open multiple links in separate tabs.

Post by additional001 » Wed Jul 30, 2008 2:57 pm

I agree with bigK on this one... for my purposes it would be best to work from a page I already loaded (the URL is dynamic in nature and it would never be the same again)...thus I need to open the contents from a TAG line in other tabs... I also would prefer not to have to loop the script to make it work

EXAMPLE
LOAD TAB 1 Manually
OPEN TAB 2 & TAB 3 with TAG lines from TAB 1
Perform actions with TAG lines on TAB 2 & 3
CLOSE TAB 2 & 3
Repeat process 2-4 again untill no more matching TAG lines are found.
kittensteak
Posts: 1
Joined: Thu Feb 19, 2009 9:52 pm

Re: Open multiple links in separate tabs.

Post by kittensteak » Thu Feb 19, 2009 9:58 pm

I totally agree with the other posters. As is, iMacros can only perform a part of the automation.
User avatar
Tech Support
Posts: 4947
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Re: Open multiple links in separate tabs.

Post by Tech Support » Wed Mar 04, 2009 10:24 am

kittensteak, iMacros can automate the full task, it just may require some use of its Javascript interface.
ghalt
Posts: 3
Joined: Wed Mar 18, 2009 7:28 pm

Re: Open multiple links in separate tabs.

Post by ghalt » Wed Mar 18, 2009 8:07 pm

I built something similar using the Firefox plugin.

It is used on the Yahoo results page:

Code: Select all

VERSION BUILD=6111228 RECORDER=FX
SET !Var2 {{!URLCURRENT}}
TAB OPEN NEW
TAB T=2
URL GOTO={{!Var2}}
TAB T=1
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:abstr&&TXT:*
TAG POS=R-1 TYPE=A ATTR=HREF:*
TAB T=2
This relies on the way that Firefox identifies Tab numbers (starting tab always = 1, regardless of absolute position).

So, starting with the current tab, a new tab is opened. The URL from the current tab is opened in the second tab (ie the same Yahoo search results page). Then, back to the first tab, we search for the !LOOP position <div class="abstr">. That's the identifier for the snippet code that appears after each result. Then, using relative positioning, we go back to the link just before the abstract, which happens to be the result link. We open that in the current tab, then go to the next tab, and start all over again. In Firefox, when you begin the loop again, what USED TO BE Tab 2 is now Tab 1 because it was the active tab when you started the loop over again.

Make sense?

Anyway, the result works for me. I can run it as a loop on a Yahoo search results page, and it will open n number of tabs, each tab containing the page of an individual search result, with n being the number of loops I set.

Hope it helps!

PS - It can be done for non-Firefox browsers by setting a variable that is equal to !LOOP + 1

Code: Select all

SET !Var1 {{!LOOP}}
ADD !Var1 1
Then use TAB T={{!Var1}} as your Tab 2, and use TAB T={{!LOOP}} instead of Tab 1.

PPS - If you want to modify it to work with Google's results page, replace "abstr" with "s" (no quotes in either case). I just did a 'view source' on the results pages to find what the tag details were.
How to Make Online Money - Resources for profiting without paying.
clone
Posts: 4
Joined: Mon Sep 07, 2009 5:52 am

Re: Open multiple links in separate tabs.

Post by clone » Tue Sep 08, 2009 4:33 am

Here's another one that works...

// ----------------------------------------------- IOPUS_1_TAB_GET.iim -----------------------------------------------
VERSION BUILD=6240709

'Find Next URL
TAG POS={{IOPUS_URL_BEGIN}} TYPE=A ATTR=HREF:/v4/view?pageReq=MProductDetail&item=*&currentMQuery=* EXTRACT=HTM


// ----------------------------------------------- IOPUS_1_TAB_OPEN.iim -----------------------------------------------
VERSION BUILD=6240709
TAB T=1

'OPEN NEW URL
TAB OPEN NEW
TAB T=2
URL GOTO={{IOPUS_URL}}


// ----------------------------------------------- IOPUS_1_TABS.js -----------------------------------------------
var nIOPUS_URL;
var nIOPUS_PAGE;
var nStart;
var nEnd;
var _T;
var MyArray = new Array;
var i = 7; // SKIP All of the non relevant stuff.
var tmpH;
var ret;
var val;
var DELIMETER = "\[EXTRACT\]";
var BASE = "https://www.iopus.com/v4/view?pageReq=MProductDetail&item="
var URL;

//GET URL
while(1){
ret = iimSet("IOPUS_URL_BEGIN", i);
ret = iimPlay("IOPUS_1_TAB_GET");
ret = iimGetLastExtract();

if( ret == "#EANF#" ){
break;
}else{
val += DELIMETER + ret;
i+=1;
}
}

/* Check for error */
if (ret < 0){
alert ("The following error occurred: " + iimGetLastError());
}

//OPEN TABS
i=0;
MyArray = val.split(DELIMETER);
tmpH = MyArray.length;
while( i++ < tmpH ){
_T = MyArray[i];
nStart = _T.indexOf("item=")+5;
nEnd = _T.indexOf("&current");
URL = _T.substring(nStart,nEnd);
ret = iimSet("IOPUS_URL", BASE + URL);
ret = iimPlay("IOPUS_1_TAB_OPEN");
}

/* Check for error */
if (ret < 0) {
alert ("The following error occurred: " + iimGetLastError());
}


// -----------------------------------------------

PS - Tech Support, is there any way to get any asynchronous behavior out of iMacros, in tangent with the XMLHttpRequest handler to, for example, open all tabs simultaneously
Post Reply