MozillaZine

Google a list of names

User Help for Mozilla Firefox
TheKiller

User avatar
 
Posts: 169
Joined: November 12th, 2010, 10:40 am
Location: Romania

Post Posted April 28th, 2017, 9:48 am

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.

dickvl

User avatar
 
Posts: 52100
Joined: July 18th, 2005, 3:25 am

Post Posted April 28th, 2017, 11:01 am

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]))}}})()

TheKiller

User avatar
 
Posts: 169
Joined: November 12th, 2010, 10:40 am
Location: Romania

Post Posted April 28th, 2017, 12:54 pm

How would i use that? This should be an useful and easy to write extension

dickvl

User avatar
 
Posts: 52100
Joined: July 18th, 2005, 3:25 am

Post Posted April 28th, 2017, 1:25 pm

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

therube

User avatar
 
Posts: 17185
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Post Posted April 30th, 2017, 6:35 am

Neat. Works.

(If you use NoScript, the domain of the page you are on needs to be Allowed.)
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

TheKiller

User avatar
 
Posts: 169
Joined: November 12th, 2010, 10:40 am
Location: Romania

Post Posted May 9th, 2017, 2:05 am

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.

therube

User avatar
 
Posts: 17185
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Post Posted May 12th, 2017, 12:45 pm

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
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

TheKiller

User avatar
 
Posts: 169
Joined: November 12th, 2010, 10:40 am
Location: Romania

Post Posted May 16th, 2017, 3:40 am

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

Return to Firefox Support


Who is online

Users browsing this forum: Google [Bot] and 12 guests