K-Meleon
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage2) # # ---------- KMLClick.kmm # ---------- K-Meleon Macro Language to switch between -- # ---------- left button to open in new tab or normal ---- # # Version : - 0.6 2016-02-14 (by JamesD, JohnHell, last mod siria) # K-Meleon version: KM75.1 or newer (older versions partly: if tabs enabled, button manually) # Menu: Tools > Left click diverted # Button: "Left click diverted" # Preferences : - "kmeleon.plugins.macros.kmlclick.diverted"... # Forum : - http://kmeleonbrowser.org/forum/read.php?4,137550,137595 # -------------------------------------------------------------------------------- KMLClick_Click { if ($LinkURL>"") { if((index($LinkURL,"javascript:") != 0) and (index($LinkURL,"#") != length($LinkURL)-1)){ $_KMLClick_frontback=="front" ? opentab($LinkURL) : openbgtab($LinkURL); }else{ open($LinkURL); } } #else injectJS("this.click();"); } KMLClick_Toggle { macroinfo="Open left-clicked links in a new page (except javascript links)"; menuchecked = getpref(BOOL,"kmeleon.plugins.macros.kmlclick.diverted"); $_KMLClick_status = togglepref(BOOL,"kmeleon.plugins.macros.kmlclick.diverted"); &_KMLClick_SyncButton; if($_KMLClick_status == true){ setaccel("LButton", "macros(KMLClick_Click)"); statusbar("Left Click divertion ".$on); }else{ setaccel("LButton", ""); statusbar("Left Click divertion ".$off); } } KMLClick_Toggle_backfront { macroinfo="Open left-clicked links in background"; menuchecked = $_KMLClick_frontback=="background"; $_KMLClick_frontback=togglepref(STRING,"kmeleon.plugins.macros.kmlclick.diverted.backfront","background","front"); statusbar("Left clicked links open in ".$_KMLClick_frontback); } KMLClick_Toggle_checkbutton { macroinfo="Toolbar button remains pressed"; menuchecked=getpref(BOOL,"kmeleon.plugins.macros.kmlclick.checkbutton"); togglepref(BOOL,"kmeleon.plugins.macros.kmlclick.checkbutton"); checkbutton("KMLClick","macros(KMLClick_Toggle)",0); &_KMLClick_SyncButton; } _KMLClick_SyncButton{ # update image for unpressed state (both "cold") # changing "icon" not "button" because of menu: if ON the checkmark is showing, but if off the ICON $_KMLClick_status==true ? $_ico="tabbar.png[2,24,24]" : $_ico="tabbar.png[3,24,24]"; setcmdicon( "macros(KMLClick_Toggle)", $_ico); # setbuttonimg("Left click diverted","macros(KMLClick_Toggle)",$_ico); if (getpref(BOOL,"kmeleon.plugins.macros.kmlclick.checkbutton")) checkbutton("KMLClick","macros(KMLClick_Toggle)",$_KMLClick_status); } _KMLClick_BuildMenu { # in Tools menu above mouse gestures setmenu("Settings", popup, "Left click diverted","Mouse &Accelerators"); setmenu("Left click diverted", macro, "Open links in new page", "KMLClick_Toggle"); setmenu("Left click diverted", macro, "New page in background", "KMLClick_Toggle_backfront"); setmenu("Left click diverted", macro, "Button remains pressed", "KMLClick_Toggle_checkbutton"); } _KMLClick_BuildButton { $_KMLClick_TTip = "Left mouse click diverted" ; addtoolbar("KMLClick") ; addbutton("KMLClick", "macros(KMLClick_Toggle)", "Left click diverted", $_KMLClick_TTip); &_KMLClick_SyncButton; } _KMLClick_InitPref { $_KMLClick_frontback=getpref(STRING,"kmeleon.plugins.macros.kmlclick.diverted.backfront"); # Set default prefs at first install. Keep user prefs between sessions if ($_KMLClick_frontback=="") { setpref(BOOL,"kmeleon.plugins.macros.kmlclick.diverted", false); setpref(BOOL,"kmeleon.plugins.macros.kmlclick.checkbutton", false); setpref(STRING,"kmeleon.plugins.macros.kmlclick.diverted.backfront","front"); } $_KMLClick_frontback=getpref(STRING,"kmeleon.plugins.macros.kmlclick.diverted.backfront"); $_KMLClick_status=getpref(BOOL,"kmeleon.plugins.macros.kmlclick.diverted"); $_KMLClick_status==true ? setaccel("LButton", "macros(KMLClick_Click)") : 0; } ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $OnInit=$OnInit."_KMLClick_BuildMenu;_KMLClick_InitPref;"; $OnSetup=$OnSetup."_KMLClick_BuildButton;"; $macroModules=$macroModules."KMLClick;";