K-Meleon

KMeleonWiki > Resources > MacroLibrary > MacroLibrary2 > Open Nick or Macro

Submitted by: MonkeeSage



Notes:

Sometimes you need to run macros or open (bookmark / hotlist / favorites) nicknames and quicksearches; this macro aims to make that a little easier to do by presenting a single prompt that will handle either case. Note: Nicks and macros must have unique names or else it will always open the nick instead of the macro.


In Macros:

open_nick_macro {
   # vars
   $theurl1="";
   $theurl2="";
   $nick1="";
   $nick2="";
   $isMacro="";
   $isNick="";
   $isQs="";

   # get the prompt text into $theurl
   $theurl = prompt("Nickname or macro to execute:", "Open");
   $theurl == "" ? $theurl = "" : 0;

   # check for spaces in $theurl, if no spaces $theurl1 inherits $theurl
   $len = length($theurl);
   $index = index($theurl, " ");
   $index == -1 ? $theurl1 = $theurl : $theurl1 = substr($theurl, 0, $index);
   $index == -1 ? 0 : $theurl2 = substr($theurl, $index + 1, $len);

   # check for nickname
   $nick = pluginmsgex("bookmarks", "FindNick", $theurl1, STRING);
   $nick == "" ? $nick = pluginmsgex("hotlist", "FindNick", $theurl1, STRING) : 0;
   $nick == "" ? $nick = pluginmsgex("favorites", "FindNick", $theurl1, STRING) : 0;

   # if not a nickname, it is a macro
   $nick == "" ? $isMacro = "TRUE" : 0;
   $isMacro == "TRUE" ? ($theurl1 == "" ? 0 : macros($theurl1)) : 0;

   # otherwise is a nickname, check for quicksearch token
   $len = length($nick);
   $index = index($nick, "%s");

   # if no quicksearch token, open as URL
   $index == -1 ? $isNick = "TRUE" : $isQs = "TRUE";
   $isNick == "TRUE" ? ($isMacro == "" ? open($nick) : 0) : 0;

   # otherwise is a quicksearch, tokenize $nick and replace
   # quicksearch token with $theurl2
   $nick1 = substr($nick, 0, $index);
   $nick2 = substr($nick, $index + 2, $len);
   $isQs == "TRUE" ? ($isMacro == "" ? open($nick1 . $theurl2 . $nick2) : 0) : 0;
}


In Accelerators:

CTRL M = macros(open_nick_macro)


In Toolbars:

NickMacro {
   macros(open_nick_macro)
   Open nick or macro
   hottool.bmp[...]
   coldtool.bmp[...]
   deadtool.bmp[...]
}


Comments & Questions

K-Meleon

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