K-Meleon

Submitted by: jsnj



Notes:

After viewing MonkeeSage's Session macro, I was inspired to write these. They are a combination of macros designed to offer most of the features afforded by Groups & Sessions such as:

  • Saving all layers as a group
  • Adding the URL to a specified group
  • Adding all layers to a specified group
  • Setting a group to open when K-Meleon starts
  • Continue browsing from the last session when K-meleon starts

Delete the Onload macro located in the # TOGGLE BUTTON MACROS section of your macros file. It will be replaced with the one present in this macro.


In Macros:

Copy & paste the following:

# GLOBAL

$loaded="";


# GROUP MACROS

SaveAsGroup {
  menu = "Save As Group";
  $group = pluginmsgex(layers,"GetLayersInWindow","",STRING);
  $name = prompt("Enter a Group Name to save these layers as:", "Group Name?", "");
  $name == "" ? "" : setpref(STRING, "kmeleon.group." . $name, $group);
  $tip = "'  in the URL Bar and press SHIFT+ENTER to open or ALT+/  to open in background."; 
  $name == "" ? "" : alert("Type  '" . $name . $tip,"Group Saved As:  " . $name,INFO);
}

URLToGroup {
  menu = "Add URL To Group";
  $name = prompt("Enter name of Group to add this URL to:", "Group Name?", "");
  $name == "" ? "" : getpref(STRING, "kmeleon.group." . $name);
  $group = getpref(STRING, "kmeleon.group." . $name);
  $name == "" ? "" : setpref(STRING, "kmeleon.group." . $name, $group . $URL . "\t");
  $name == "" ? "" : alert("URL added to Group: " . $name, "Group Updated",INFO);
}

LayersToGroup {
  menu = "Add Layers To Group";
  $name = prompt("Enter name of Group to add these layers to:", "Group Name?", "");
  $name == "" ? "" : getpref(STRING, "kmeleon.group." . $name);
  $group = getpref(STRING, "kmeleon.group." . $name);
  $curr = pluginmsgex(layers,"GetLayersInWindow","",STRING);
  $name == "" ? "" : setpref(STRING, "kmeleon.group." . $name, $group . $curr);
  $name == "" ? "" : alert("Layers added to Group: " . $name, "Group Updated",INFO);
}

Group{
$group = getpref(STRING, "kmeleon.group." . getclipboard());
pluginmsg(layers, "ReplaceLayersInWindow", $group);
}

GroupBg{
$curr = pluginmsgex(layers,"GetLayersInWindow","",STRING);
$group = getpref(STRING, "kmeleon.group." . getclipboard());
pluginmsg(layers, "ReplaceLayersInWindow", $curr . $group);
}

NoGroup{
setpref(BOOL, "kmeleon.general.groupFound", false);
$tip = "'  not found."; 
$name = getclipboard();
alert("Group Name: '" . $name . $tip, "No Such Group");
}

OpenGroup{
id(ID_SELECT_URL);
id(ID_EDIT_COPY);
setpref(BOOL, "kmeleon.general.groupFound", true);
getpref(STRING, "kmeleon.group." . getclipboard()) == "" ? macros(NoGroup) : "";
getpref(BOOL, "kmeleon.general.groupFound") == "true" ? macros(Group) : "";
}

OpenGroupBg{
id(ID_SELECT_URL);
id(ID_EDIT_COPY);
setpref(BOOL, "kmeleon.general.groupFound", true);
getpref(STRING, "kmeleon.group." . getclipboard()) == "" ? macros(NoGroup) : "";
getpref(BOOL, "kmeleon.general.groupFound") == "true" ? macros(GroupBg) : "";
}

OpenLast{
$group = getpref(STRING, "kmeleon.group.last");
pluginmsg(layers, "ReplaceLayersInWindow", $group);
}

AlertLast{
setpref(BOOL, "kmeleon.general.startLastSession", true);
alert("The last session before exit will open when K-Meleon is started", "Startup Group Enabled" , INFO);
}

AlertGroup{
$tip = "'  will open when K-Meleon is started."; 
alert("The Group: '" . $name . $tip, "Startup Group Enabled" , INFO);
}

DefineStartupGroup {
menu = "Define Startup Group";
$name = prompt("Enter Startup Group name. Type 'last' to continue from last session.", "Startup Group Name?", "");
$group = getpref(STRING, "kmeleon.group." . $name);
$name == "" ? "" : setpref(STRING, "kmeleon.group.startup", $group);
$name == "" ? "" : setpref(STRING, "kmeleon.general.startGroupName", $name);
$name == "" ? "" : setpref(BOOL, "kmeleon.general.startGroup", "true");
$name == "" ? "" : setpref(BOOL, "kmeleon.general.startHome", "false");
$name == "" ? "" : setpref(BOOL, "kmeleon.general.startLastSession", false);
$name  "" ? "" : getpref(STRING, "kmeleon.general.startGroupName")  "last" ? macros(AlertLast) : "";
$name  "" ? "" : getpref(BOOL, "kmeleon.general.startLastSession")  "false" ? macros(AlertGroup) : "";
}

DisableStartupGroup{
menu = "Disable Startup Group";
setpref(BOOL, "kmeleon.general.startGroup", "false");

setpref(BOOL, "kmeleon.general.startHome", true);
alert("Startup Group Disabled. Your Home Page will open when K-Meleon is started.", "Startup Group Disabled",INFO);
}

StartupGroup{
$group = getpref(STRING, "kmeleon.group.startup");
pluginmsg(layers, "ReplaceLayersInWindow", $group);
}

GroupStart{
id(ID_SELECT_URL);
id(ID_EDIT_COPY);
$theurl = getclipboard();
setpref(STRING, "kmeleon.general.startURL", $theurl);
getpref(STRING, "kmeleon.general.startURL") == "about:blank" ? macros(StartupGroup) : "";
$loaded="";
}

last{
$group = getpref(STRING, "kmeleon.group.last");
setpref(STRING, "kmeleon.group.startup", $group);
}

# EVENT MACROS 

OnStartup{
getpref(STRING, "kmeleon.general.startGroupName") == "last" ? macros(last) : "";
getpref(BOOL, "kmeleon.general.startGroup") == "true" ? $loaded="GroupStart" : "";
}

OnLoad {
&buttonSync;
$group = pluginmsgex(layers,"GetLayersInWindow","",STRING);
setpref(STRING, "kmeleon.group.current", $group);
$loaded == "" ? 0 : macros($loaded);
}

OnQuit{
$group = getpref(STRING, "kmeleon.group.current");
setpref(STRING, "kmeleon.group.last", $group);
}


In Menus:

Groups{
macros(OpenLast, Open Last Session Before Exit\tCtrl+Alt+L)
-
macros(SaveAsGroup, Save As Group\tAlt+G)
macros(URLToGroup, Add URL To Group\tAlt+U)
macros(LayersToGroup, Add Layers To Group\tAlt+L)
macros(DefineStartupGroup, Define Startup Group\tAlt+S)
macros(DisableStartupGroup, Disable Startup Group\tAlt+X)
}

# And in the Main section:

Main {
...
...
 %ifplugin layers
#      :&Layers
        :Groups
 %endif
...
...
}


In Accelerators:

%ifplugin layers
...
...
CTRL ALT L = macros(OpenLast)
ALT G = macros(SaveAsGroup)
ALT U = macros(URLToGroup)
ALT L = macros(LayersToGroup)
ALT S = macros(DefineStartupGroup)
ALT X = macros(DisableStartupGroup)
SHIFT VK_RETURN = macros(OpenGroup)
ALT / = macros(OpenGroupBg)
%else
...


User Comments:

K-Meleon

(c) 2000-2010 kmeleonbrowser.org. All rights reserved.
design by splif.