K-Meleon

KMeleonWiki > Resources > MacroLibrary > KmmClearLastSession

Submitted by: desga2



Notes:

Updated: 2008/09/11 In memory of all victims of terrorism in the world.
Added support to K-Meleon 1.5
Added Clear Last Session on Start or Clear Last Session on Exit menu options.

This code it's a good example for how to detect what K-Meleon version are using the user and macro code works correctly.

This is a privacy option to clear last browsing session on start or on exit K-M browser. With this code two new options can be checked in menu:
In 1.1.X versions:
Tools -> Privacy -> Clear Last Session on Start
Tools -> Privacy -> Clear Last Session on Exit

In 1.5 versions:
Tools -> Privacy -> Clear Data -> Clear Last Session on Start
Tools -> Privacy -> Clear Data -> Clear Last Session on Exit




Open your User Macro Folder (Edit > Configuration > User-Defined Macros) or your Macro Folder (Edit > Configuration > Macros) and create the following text file(s):

ClearLastSession.kmm

# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# ---------- Clear Last Session -----------------------------------------------
#
# Dependencies        : $kSessions
# Resources        : -
# Preferences        : -
#
# -----------------------------------------------------------------------------

$CLSession_Pref_S="kmeleon.plugins.macros.sessions.ClearLast";
$CLSession_Pref_X="kmeleon.plugins.macros.sessions.ClearLast.exit";
$VersionCheker_Pref="general.useragent.vendorSub";
$CLSession_menu_S=_("Clear Last Session on &Start");
$CLSession_menu_X=_("Clear Last Session on E&xit");

Clear_LastSession_S{
menuchecked=(getpref(BOOL,$CLSession_Pref_S)==true);
togglepref(BOOL,$CLSession_Pref_S);
getpref(BOOL,$CLSession_Pref_S)==true?setpref(BOOL,$CLSession_Pref_X,"false"):0;
}

Clear_LastSession_X{
menuchecked=(getpref(BOOL,$CLSession_Pref_X)==true);
togglepref(BOOL,$CLSession_Pref_X);
getpref(BOOL,$CLSession_Pref_X)==true?setpref(BOOL,$CLSession_Pref_S,"false"):0;
}

# ----- PRIVATE

_Clear_Session_S{
$_CLS_prefv=getpref(BOOL,$CLSession_Pref_S);
$_KMVersion=="1.5"?$_CLS_prefv==true?&_Clear_Session_15:0:0;
$_CLS_prefv==true?delpref("kmeleon.plugins.macros.groups.last"):0;
$_CLS_prefv==true?delpref("kmeleon.plugins.macros.groups.temp"):0;
}

_Clear_Session_X{
$_CLS_prefv=getpref(BOOL,$CLSession_Pref_X);
$_KMVersion=="1.5"?$_CLS_prefv==true?&_Clear_Session_15:0:0;
$_CLS_prefv==true?delpref("kmeleon.plugins.macros.groups.last"):0;
$_CLS_prefv==true?delpref("kmeleon.plugins.macros.groups.temp"):0;
}

_Clear_Session_15{
$_Selected_Session="kmeleon.plugins.sessions2.Last Session.";
$_LS_windows=getpref(INT,$_Selected_Session."count");
while($_LS_windows!=0){ delpref($_Selected_Session."window".($_LS_windows-1)); &_CLS_DeleteSession_15; $_LS_windows=$_LS_windows-1; }
delpref($_Selected_Session."count");
$_Selected_Session="kmeleon.plugins.sessions2.Previous Session.";
$_LS_windows=getpref(INT,$_Selected_Session."count");
while($_LS_windows!=0){ delpref($_Selected_Session."window".($_LS_windows-1)); &_CLS_DeleteSession_15; $_LS_windows=$_LS_windows-1; }
delpref($_Selected_Session."count");
}

_CLS_DeleteSession_15{
$_LS_tabs=getpref(INT,$_Selected_Session."window".($_LS_windows-1).".count");
while($_LS_tabs!=0){ delpref($_Selected_Session."window".($_LS_windows-1).".tab".($_LS_tabs-1)); $_LS_tabs=$_LS_tabs-1; }
delpref($_Selected_Session."window".($_LS_windows-1).".count");
}

_Sessions_BuildMenu{
$_KMVersion=substr(getpref(STRING, $VersionCheker_Pref), 0, 3);
$_KMVersion=="1.5"?$kSessions==true?&_Sessions_BuildMenu_15:0:0;
$kSessions==true?setmenu("kPrivacy",macro,$CLSession_menu_S,"Clear_LastSession_S"):0;
$kSessions==true?setmenu("kPrivacy",macro,$CLSession_menu_X,"Clear_LastSession_X"):0;
}

_Sessions_BuildMenu_15{
setmenu("&Clear Data",separator,-1);
setmenu("&Clear Data",macro,$CLSession_menu_S,"Clear_LastSession_S",-1);
setmenu("&Clear Data",macro,$CLSession_menu_X,"Clear_LastSession_X",-1);
}

$OnInit=$OnInit."_Sessions_BuildMenu;_Clear_Session_S;";
$OnQuit=$OnQuit."_Clear_Session_X;";

# -----------------------------------------------------------------------------
$macroModules=$macroModules."Clear_Last_Session;";


Comments & Questions

K-Meleon

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