General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
Search selected text (using google)
Posted by: Sesh
Date: January 04, 2002 03:06AM

Hi all,
If you have installed google toolbar on your internet explorer you may remeber that you can select any text in a document and select "google search" to search the selected text using google.

Here is how you can achive same functionality in kmeleon.

In macros.cfg add this macro

searchtext{
menu=Search google
open(javascript:self.location='http://www.google.com/search?num=100&q='+document.getSelection());
}

In menus.cfg under document popup, add macros(searchtext)
Here is my documentpopup.

DocumentPopup {
&Back = ID_NAV_BACK
&Forward = ID_NAV_FORWARD
&Reload = ID_NAV_RELOAD
&Stop = ID_NAV_STOP
-
macros(searchtext)
Select &All = ID_EDIT_SELECT_ALL
Select &None = ID_EDIT_SELECT_NONE
&Copy Text = ID_EDIT_COPY
-
View So&urce = ID_VIEW_SOURCE
Save &Page As... = ID_FILE_SAVE_AS
%ifplugin fullscreen
-
&Preferences = ID_PREFERENCES
fullscreen(&Full Screen\tF11)
%endif
bmpmenu()
}

After reloading kmeleon you should see a new entry in th document popup menu. When you select a text and click google search, you will be able to search google for this text.
Note: you can write many similar macros, I have macros for searching deja.com, search current browsing site for a given text etc etc.

thanks
-sesh

Options: ReplyQuote
Re: Search selected text (using google)
Posted by: Andrew
Date: January 04, 2002 03:15AM

Sesh,

Do you want to write that example and some of the other macros for other search engines into a Doc for the site?

Andrew

Options: ReplyQuote
Re: Search selected text (using google)
Posted by: Sesh
Date: January 04, 2002 03:25AM

Andrew,
I can do that. Tell me what format I need to send you and I can document it and contribute to kmeleon.

thanks
-sesh

Options: ReplyQuote
Re: Search selected text (using google)
Posted by: Nicole Simon
Date: January 04, 2002 03:44AM


Thanks for the script,
I will look into it at the weekend.
Saves me the question how to redefine the built in
searchbutton from google.com to google.de ;o)


In case you like, me might add some of the 'normal' german search engines.

This is sometimes necessary because you don't get a 'search only germanspeaking sites' from the normal .com link of search engines.

Nicole

Options: ReplyQuote
Re: Search selected text (using google)
Posted by: Andrew
Date: January 04, 2002 03:48AM

Nicole,

You can change the default search engine in prefs.js. See here:

http://kmeleon.sourceforge.net/docs/preferences.php

specfically:

kmeleon.general.searchEngine

Andrew

Options: ReplyQuote
Re: Search selected text (using google)
Posted by: Andrew
Date: January 04, 2002 03:49AM

Sesh,

RTF is fine. I'll just dump it into a web page and try and preserve as much as the format as I can.

We appreciate the help!

Andrew

Options: ReplyQuote
Re: Search selected text (using google)
Posted by: D'Sphitz
Date: January 04, 2002 08:06PM

slightly modified to search dictionary.com

macros.cfg entry:

dictionary{
menu=Dictionary
open(javascript:self.location='http://www.dictionary.com/cgi-bin/dict.pl?term='+document.getSelection());
}

menus.cfg entry (under documentpopup):
macros(dictionary)

Options: ReplyQuote
Re: Search selected text (using google)
Posted by: Sesh
Date: January 04, 2002 08:37PM

Please refer to thread
http://kmeleonbrowser.org/forum/read.php?f=1&i=2132&t=2132

For yet another macro that would alow you to email a Page

Options: ReplyQuote
Re: Search selected text (using google)
Posted by: Andrew
Date: January 05, 2002 07:19AM

Sesh,

See what I hacked together here:

http://kmeleon.sourceforge.net/docs/mailmacro.php

for the format. If you want to go ahead and put that together and add the dictionary.com example, it would be much appreciated.

Andrew

Options: ReplyQuote
Re: Search selected text (using google)
Posted by: Nicole Simon
Date: January 05, 2002 04:36PM

Sesh, Andrew,

I am not that good with js but there is an improvement which could be easy for someone with little experience - I guess. Perhaps some of you might put something up for google or other se:

This link (one line of course)
Start###
javascript:s=document.getSelection();for(i=0;i<frames.length;i++){s=frames.document.getSelection();if(s)break;}if(!s)void(s=prompt('Geben Sie einen Ausdruck ein, oder markieren Sie ein Wort auf einer Webseite, bevor Sie auf LeoDict klicken.',''));if(s){leow=open('http://dict.leo.org/?client=bookmarklet&search='+escape(s),'LEODict','width=700,height=400,scrollbars=yes,resizable=yes');leow.focus();}
##END

Looks if something is selected. In case yes, this is look up at leo.org, a german / englisch dictionary in a new little window.

If nothing is selected, it gives a popup where it asks for a string.
hth
Ni'one day I will do something like this for amazon *sigh*cole


Options: ReplyQuote


K-Meleon forum is powered by Phorum.