require "preferenceGUI\\locals"; -- Undo closed tab -- for tab version only -- Install -- Put this on lua folder and add `require "undo"' to macros.lua. require "compat" require "hook" require "setmenu" -- needs setmenu.modify local max = km.getpref(TYPE_INT, "kmeleon.maximum.undo") if max < 1 then max = 1; end data = {} function undo_menu(m) local h,i={} for i=1, #data do h[i]={data[i].title, "luamacro(undo("..i.."))"} end if m then setmenu.modify("&Edit", 0, _UNDO, h) else setmenu.append("&Edit", 0, _UNDO, h) end end hook.add(StartupHook, undo_menu) local function OnCloseTab() local title, url = GetDocInfo() while #data >= max do table.remove(data) end if url~="about:blank" then table.insert(data, 1, {url = url, title = title}) undo_menu(true) end end hook.add(CloseTabHook, OnCloseTab) function undo(arg) local n = tonumber(arg) if data[n] then NavigateTo(data[n].url,OPEN_NEWTAB) end end