K-Meleon
Macros are a unique feature of K-Meleon. You can use them to customize the browser or expand its features. Macros can be activated from toolbars, menus, right-click menus, keyboard shortcuts, events, and even other macros. Macros have several advantages over larger extensions:
WARNING: Responsibility for macros lies with their respective owners.
You can find many user-created macros in the extensions forum. There are also many older macros in the Macro Library. You can install a macro by saving it to your K-Meleon > Macros folder. You can open your macros folder by navigating to Configuration > Macros.
Some macros are part of larger packages. These may require an extensions manager. See the extensions page for more information.
K-Meleon macros are more approachable than other web browser extension systems. This section will walk you through the steps to build one. Below is the entire code for a simple "Hello world!" macro. To run this in K-Meleon:
# Anything on a line starting with "#" is a comment.
# Comments do not affect how your code works.
_HelloWorld_BuildMenu{
# You can replace this keyboard accelerator with any shortcut you like:
setaccel("CTRL ALT SHIFT H","macros(HelloWorld)");
}
HelloWorld{
alert("Hello world!");
}
$OnInit=$OnInit."_HelloWorld_BuildMenu;";
#The name specified below can be used by other macros and config files:
$macroModules=$macroModules."HelloWorld;";
You'll notice that the macro has two main sections. First, it builds a menu to access the macro. Next, it defines the function that the macro carries out.
It can be difficult to try to remember many keyboard shortcuts. Most software reminds users of frequent keyboard shortcuts from within its menus. K-Meleon will automatically list your keyboard shortcut if you create a menu option, so let's add an option to the right-click menu of a page:
_HelloWorld_BuildMenu{
# The number at the end of the line for menu items can indicate relative
# position as below (0, -1) or it can specify the exact order of several items.
$_name="Menu Item";
setmenu("DocumentSave",macro,$_name,"HelloWorld",-1);
setmenu("ImageView",macro,$_name,"HelloWorld",-1);
setmenu("Link",macro,$_name,"HelloWorld",-1);
setaccel("CTRL ALT SHIFT H","macros(HelloWorld)");
}
HelloWorld{
alert("Hello world!");
}
$OnInit=$OnInit."_HelloWorld_BuildMenu;";
$macroModules=$macroModules."HelloWorld;";
You should now see a generic Menu Item (along with your keyboard shortcut) anytime you right-click an empty area of a web page. If it's not visible, close and restart K-Meleon to reload your macro. All the added code does is position a menu item that calls a function.
Next, let's make the above macro into something more useful. Some web pages use tiny fonts, so let's create an accessibility option to give those pages an 18 point font like large-print books:
_HelloWorld_BuildMenu{
$_name="Large-print";
setmenu("DocumentSave",macro,$_name,"HelloWorld",-1);
setmenu("ImageView",macro,$_name,"HelloWorld",-1);
setmenu("Link",macro,$_name,"HelloWorld",-1);
setaccel("CTRL ALT SHIFT H","macros(HelloWorld)");
}
HelloWorld{
alert("Large print activated for current page until refreshed.");
# "!important" allows this CSS style to override styles on a web page
injectCSS("html, body, main, p, blockquote, table, tr, td, ol li, ul li {
font-size: 18pt !important; }");
}
$OnInit=$OnInit."_HelloWorld_BuildMenu;";
$macroModules=$macroModules."HelloWorld;";
Aside from the name changes, you've only added one line of code to inject some CSS. The line of CSS will increase the font of most parts of a page to 18pt. This will have the most impact on fluid pages like the K-Meleon wiki or Wikipedia.
And congrats on building a macro.
The above macro is stand-alone. It works without additional files or settings. It's also possible to launch a macro from K-Meleon's keyboard accelerator shortcuts or other macros.
To launch the "HelloWorld" macro above from your keyboard shortcuts:
Custom accelerators allow you to write smaller extensions. Because the config file creates the keyboard shortcut, you don't have to build one in your macro. The HelloWorld macro can be shortened down to:
HelloWorld{
alert("Hello world!");
}
$macroModules=$macroModules."HelloWorld;";
K-Meleon can also launch macros from menus and toolbars. Macros handle many of the default menu options in K-Meleon. To add custom menu options for macros:
For example, the code below would add the HelloWorld macro to K-Meleon's right-click menu on any page. Try adding it and then right-clicking this page:
!Nav {
HelloWorld=macros(HelloWorld)
}
Nav is the topmost menu section that has navigation options. The exclamation point adds the HellowWorld entry inline rather than replacing items or popping out a submenu. If you want to add an item to the main menu, just choose an area that suits your macro. For example, you could replace Nav with Network above.
You can find more information about custom configurations on the ConfigFiles page. You can find the names of K-Meleon's menus in the default menus.cfg located at K-Meleon/browser/defaults/settings.
The documentation for the old macro language and a library of user-submitted legacy macros are archived on the wiki.