Google a list of names

User Help for Mozilla Firefox
Post Reply
User avatar
TheKiller
Posts: 169
Joined: November 12th, 2010, 10:40 am
Location: Romania
Contact:

Google a list of names

Post by TheKiller »

Say we have a list of names, each name in a new line.
  1. Iron Man
  2. Spiderman
  3. Superman
    ...
Is there an extension in which we can insert the list and have Firefox search each keyword and open 3 tabs with the search results?
Thanks.
User avatar
dickvl
Posts: 54161
Joined: July 18th, 2005, 3:25 am

Re: Google a list of names

Post by dickvl »

Maybe try a bookmarklet:

Code: Select all

javascript:(function(){var h='https://www.google.com/search?q=',s=window.getSelection().toString(),i,L=[],U=[],t=new RegExp("([^\n]+)\n?","gi");while(t.test(s)){L.push(h+RegExp.$1)}if(L=prompt(L.join('\n'),L.join(','))){L=L.split(/[,]/);for(i=0;L[i];i++){void(window.open(L[i]))}}})()
User avatar
TheKiller
Posts: 169
Joined: November 12th, 2010, 10:40 am
Location: Romania
Contact:

Re: Google a list of names

Post by TheKiller »

How would i use that? This should be an useful and easy to write extension
User avatar
dickvl
Posts: 54161
Joined: July 18th, 2005, 3:25 am

Re: Google a list of names

Post by dickvl »

A bookmarklet works like a normal bookmark.
The only difference is that you use JavaScript in the location filed of the bookmark instead of the URL of a web page.

Create a new bookmark and paste the JavaScript code in its location field.
See also:
https://en.wikipedia.org/wiki/Bookmarklet

This is a very simple bookmarklet that splits the selected text by a line break (linefeed: \n or %0a as defined via the RegExp("([^\n]+)\n?")) and works for text formatted like you posted above.
It won't work in other cases like quoted strings or comma separated strings.
https://developer.mozilla.org/en-US/doc ... xpressions
User avatar
therube
Posts: 21714
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: Google a list of names

Post by therube »

Neat. Works.

(If you use NoScript, the domain of the page you are on needs to be Allowed.)
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
User avatar
TheKiller
Posts: 169
Joined: November 12th, 2010, 10:40 am
Location: Romania
Contact:

Re: Google a list of names

Post by TheKiller »

I added the bookmark... But how do i actually use it?
I tried highlighting the text and pushing the bookmark, but it just opens an empty new tab.
User avatar
therube
Posts: 21714
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: Google a list of names

Post by therube »

Highlight some text on a page, then click the "bookmark" ("button").

Make sure you copied, pasted, the supplied code correctly.
It should be all on one line.


Using the Bookmarks Toolbar
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
User avatar
TheKiller
Posts: 169
Joined: November 12th, 2010, 10:40 am
Location: Romania
Contact:

Re: Google a list of names

Post by TheKiller »

It works thanks. I dont know what i did wrong before.
Post Reply