How to open a list of URLs in Firefox or SeaMonkey?

20

8

I have a list of URLs in a text file, for example,

http://url1
http://url2
http://url3

I wonder how to open them each in one tab in Firefox (or SeaMonkey), without the hassle of creating a new tab, copying into address bar and hitting return for each URL?

My OS is Ubuntu 10.10. Both command line and GUI solutions are welcome.

Tim

Posted 2012-02-02T15:55:00.937

Reputation: 12 647

Answers

27

You can save the following to a HTML file:

<!doctype html>
<html>
<head>
<title>Open Windows</title>
<script>
function openWindow(){
    var x = document.getElementById('a').value.split('\n');
    for (var i = 0; i < x.length; i++)
        if (x[i].indexOf('.') > 0)
            if (x[i].indexOf('://') < 0)
                window.open('http://'+x[i]);
            else
                window.open(x[i]);
}
</script>
<style>
html, body
{
    height : 99%;
    width  : 99%;
}

textarea
{
    height : 80%;
    width  : 90%;
}
</style>
</head>
<body>
<textarea id="a"></textarea>
<br>
<input type="button" value="Open Windows" onClick="openWindow()">
<input type="button" value="Clear" onClick="document.getElementById('a').value=''">
</body>
</html>

Now load the file in Firefox, copy the list of URLs in the textarea and click Open Windows.

Dennis

Posted 2012-02-02T15:55:00.937

Reputation: 42 934

This is perfect. Is there anyway to add a slight delay, lets say 5 seconds between opening each tab? – DomainsFeatured – 2016-11-30T17:16:25.300

@DomainsFeatured Sure. You could use setInterval to iterate over the domains and cancel it once all of them have been processed. – Dennis – 2016-11-30T17:29:18.827

Hey Dennis, could you post the code here please? http://stackoverflow.com/questions/40894481/how-to-add-delay-to-html-javascript-function I'm not sure how to do that. Would be so grateful!

– DomainsFeatured – 2016-11-30T17:29:57.610

Awesome answer, I made a JSFiddle for anyone as lazy as I am - https://jsfiddle.net/y1dgezuL/

– Neil P – 2018-10-21T16:12:25.660

Hah... I haven't thought 'bout that one! I usually do it with firefox \cat file.txt`` (as WakiMiko wrote). Anyway using your way will work on all OS. :D – tftd – 2012-02-02T16:39:15.350

1Now this is what I call "for the win." +1 for platform independence. Would definitely accept this answer. Supported: SeaMonkey, FireFox, IE, Chrome, Safari, etc...Ubuntu, Windows, Mac, etc. – Matt – 2012-06-06T22:39:38.003

Technically chrome blocking as pop-ups. But since I need source and I'm running fiddler, you made my day. Thanks a done. – Jones – 2013-04-08T15:12:05.193

20

A simple

firefox $(cat file.txt)

should suffice. It will pass each link as an argument to the firefox command, as long as every link is separated by whitespace.

jhenninger

Posted 2012-02-02T15:55:00.937

Reputation: 1 461

+1. Thanks! That works! I wonder if you happen to know how to do that in SeaMonkey? I tried seamonkey $(cat urls), but only the url in the first line is opened. – Tim – 2012-02-02T17:03:41.693

9

On windows you can create a batch file (named say, multiurl.bat):

@echo off    
for /F "eol=c tokens=1" %%i in (%1) do "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" %%i

and then run multiurl.bat urls.txt from the command line and it will load the URLS in new tabs if FireFox is already open, or it will run it and then load the URLS.

tfitzgerald

Posted 2012-02-02T15:55:00.937

Reputation: 211

You aren't required to create a .bat file to use the for command. – Der Hochstapler – 2012-02-02T16:25:07.170

2This is not relevant - the users asks for a solution that will work on Linux machines! – tftd – 2012-02-02T16:37:28.113

1@TheDevil Come on, this answer took longer than three minutes to test and type. I suggest tfitzgerald keeps this answer up, there might be others interested. I sure won't delete my answer for OS X. – Daniel Beck – 2012-02-02T17:20:03.147

@TheDevil Yes, he edited his question as I was writing my answer. – tfitzgerald – 2012-02-03T01:47:44.570

1@OliverSalzburg That is correct. But I don't think I said you are required to...but why would you want to type that whole line each time you wanted to do this? That is what scripts are for! – tfitzgerald – 2012-02-03T01:48:55.177

@fitzgerald The user didn't specify how often he plans on using the functionality. If only a single use would be intended, creating a dedicated script is unnecessary. Your answer might leave the impression that a script is required for this to work. – Der Hochstapler – 2012-02-03T10:29:57.797

Yes, the words, "you can" obviously translate to "you must" over the Internet. Thanks for reminding me though, if you were to do this just in a command prompt you would want to change the %%i to just %i. The double percent signs are only for when using the for command in a batch file. – tfitzgerald – 2012-02-04T21:51:47.043

4

On Mac OS X, save the following script as openurls.sh, run chmod +x openurls.sh in Terminal, and then type ./openurls.sh from the same directory.

#!/usr/bin/env bash

while read line ; do
    open -a Firefox "$line"
done < "/path/to/file-with-urls.txt"

Daniel Beck

Posted 2012-02-02T15:55:00.937

Reputation: 98 421

Is there a way to specify the Firefox profile? – DomainsFeatured – 2016-11-30T16:46:52.833

+1. Thanks! Do you also know how to do that for SeaMonkey instead of Firefox? – Tim – 2012-02-02T16:12:32.363

@Tim I don't have SeaMonkey to test it. Also, I'm afraid this script opens windows instead of tabs, sorry about that. – Daniel Beck – 2012-02-02T16:16:52.563

1This can easily be fixed with changing some settings in Firefox. Go to Edit->Preferences->Tabs and select "Open new window in new tab instead" :) – tftd – 2012-02-02T16:41:24.723

@TheDevil Thanks! I guess it's obvious I only use FF for answering questions on SU. – Daniel Beck – 2012-02-02T16:42:39.823

1

Open your text file in firefox as

file:///C:/URLTextFile.txt
  1. Select the whole link
  2. Right click on it
  3. Click on "Open Link in new tab"

Siva Charan

Posted 2012-02-02T15:55:00.937

Reputation: 4 026

1Only opens one (ex. the first url from many selected) – Xen2050 – 2016-05-17T20:29:25.190