K-Meleon
 

Home/News
Screenshots
Download
Documentation
Resources
Get Involved
Forum
Bugs
Development

SourceForge Logo
Spam Chongqed

 

 

 

 

 

 

K-Meleon

Documentation - Macros and Macro Scripting - Advanced Search Macros

Introduction

This document explains how to create advanced macros for searching.

Defining the Macro

You can add macros directly in K-Meleon. Select Edit - Preferences - Configs and then select the tab labeled "Macros". Scroll to the bottom of the file and add the following code:

Search google.com for currently selected text

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

Search currently browsing site for selected text using google

search_text_site{
menu=Search &Site
open(javascript:self.location='http://www.google.com/search?q='+escape(document.getSelection())+'+site%3A'+location.host);
}

Search dictionary.com for currently selected text

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

Search deja.com for currently selected text

search_text_deja{
menu=Search &Deja
open(javascript:self.location='http://groups.google.com/groups?q='+escape(document.getSelection()));
}

These code snippets do two things. First, they define a menu item for later use. They also define the macro that will execute when you select that menu item. In the first example, the macro "search_text_site" uses Javascript to search Google using the text that you have currently selected.

Click on the "OK" button to save your changes. A dialog will appear asking you if you wish to save your changes to "macros.cfg". Select "Yes" to save the changes. Now that we've defined the macro, we need to have a way to execute it.

Adding a Menu Entry for the Macros

When creating macros, you have the option of binding the macros to a toolbar button, accelerator keys, creating a menu entry or all three. In this example, we'll create a menu entry for our macros. Again, select Edit - Preferences - Configs and then select the tab labeled "Menus". You can actually add it to any menu you wish or create a whole new menu for your macro. It's your choice!

In this window, add the following at the top:

&Search{
macros(search_text_site)
macros(search_text_google)
macros(search_text_deja)
macros(search_text_dictionary)
}

To add the macros to your Document Popup menu, scroll down until you find Document Popup defined and add this entry:

DocumentPopup {
        :&Search
        -
        &Back = ID_NAV_BACK
        &Forward = ID_NAV_FORWARD
        &Reload = ID_NAV_RELOAD
	  .
	  .
	  .

Click on the "OK" button to save your changes. A dialog will appear asking you if you wish to save your changes to "menus.cfg". Select "Yes" to save the changes.

Exit K-Meleon and restart the browser (if you have the symbiotic loader installed, you may have to re-boot).

Coding and text by sesh with additional text by Andrew Mutch and Po.

Last updated: April 16, 2002
Created: April 16, 2002

(c) 2000-2001 kmeleon.org. All rights reserved.
design by splif.