Полезная информация

Mozilla Россия — свежие версии программ Mozilla, а также масса полезной информации по каждому продукту.

№12629-03-2024 21:25:27

vending_machine
Участник
 
Группа: Members
Зарегистрирован: 10-01-2020
Сообщений: 549
UA: Firefox 115.0

Re: [CB]Undo Close Tabs

¿ Можно ли в этой замечательной кнопке сделать так, чтобы она не запоминала определённый сайт ? (открывающийся по клику в другом приложении)

Отсутствует

 

№12730-03-2024 13:40:23

Alex_one
Участник
 
Группа: Members
Зарегистрирован: 27-09-2015
Сообщений: 151
UA: Firefox 115.0

Re: [CB]Undo Close Tabs

Здравствуйте.
А на [firefox] 115.9.1esr, версия 0.3.3.3 - 04.09.2021 уже не работает?
Custom Buttons 0.0.7.0.0.32.

Отсутствует

 

№12830-03-2024 13:57:34

VORON
Участник
 
Группа: Members
Зарегистрирован: 03-04-2013
Сообщений: 158
UA: Firefox 124.0

Re: [CB]Undo Close Tabs

Alex_one
Вот это - работает

скрытый текст

Выделить код

Код:

// http://infocatcher.ucoz.net/js/cb/undoCloseTabs.js
// https://forum.mozilla-russia.org/viewtopic.php?id=56267
// https://github.com/Infocatcher/Custom_Buttons/tree/master/Undo_Close_Tabs

// Undo Close Tabs button for Custom Buttons
// (code for "initialization" section)

// (c) Infocatcher 2009-2021
// version 0.3.3.3 - 2021-09-04

var options = {
	menuTemplate: [
		"closedWindows",
		"separator",
		"restoreClosedWindows",
		"clearClosedWindows",
		"separator",
		"closedTabs",
		"separator",
		"restoreClosedTabs",
		"clearClosedTabs",
		"separator",
		"clearAll",
		"separator",
		"restoreLastSession",
		"separator",
		"buttonMenu"
	],
	showInTabContextMenu: false,
	/*
	menuTemplateTabContext: [ // like menuTemplate
		"closedTabs",
		"separator",
		"restoreClosedTabs",
		"clearClosedTabs"
	],
	*/
	windowItemTemplate: "(%count) %title",
	windowSelectedTabPrefix: "*",
	buttonTipTemplate: ["header", "title", "url", "closedAt"],
	itemTipTemplate: ["title", "url", "closedAt"],
	hideRestoreAllForSingleEntry: false,
	allowDeleteEntries: true,
	accesskeys: { // Empty string ("") to disable or string with possible values ("0123...", "abcd...")
		closedTabs: "",
		closedWindows: ""
	},
	accesskeySeparator: " ", // <accesskey><separator><label>
	openMenuOnMouseover: false,
	useMenu: false,
	rightClickToUndoCloseTab: false // Useful with "useMenu: true"
};

function _localize(sid) {
	var strings = {
		en: {
			restoreTab: "Restore the most recently closed tab",

			restoreAllTabs: "Restore all tabs",
			restoreAllTabsAccesskey: "t",
			clearTabsHistory: "Clear history of closed tabs",
			clearTabsHistoryAccesskey: "b",

			restoreAllWindows: "Restore all windows",
			restoreAllWindowsAccesskey: "w",
			clearWindowsHistory: "Clear history of closed windows",
			clearWindowsHistoryAccesskey: "d",

			clearAllHistory: "Clear all history",
			clearAllHistoryAccesskey: "C",

			restoreLastSession: "Restore last session",
			restoreLastSessionAccesskey: "s",

			deleteUndoEntry: "Delete",

			buttonMenu: "Button menu",
			buttonMenuAccesskey: "m",

			tabContextMenu: "Recently Closed Tabs",
			tabContextMenuAccesskey: "y",

			itemTip: "%ago ago, %date",
			day: "d"
		},
		ru: {
			restoreTab: "Восстановить последнюю закрытую вкладку",

			restoreAllTabs: "Восстановить все вкладки",
			restoreAllTabsAccesskey: "л",
			clearTabsHistory: "Очистить историю закрытых вкладок",
			clearTabsHistoryAccesskey: "д",

			restoreAllWindows: "Восстановить все окна",
			restoreAllWindowsAccesskey: "о",
			clearWindowsHistory: "Очистить историю закрытых окон",
			clearWindowsHistoryAccesskey: "н",

			clearAllHistory: "Очистить всю историю",
			clearAllHistoryAccesskey: "ч",

			restoreLastSession: "Восстановить последнюю сессию",
			restoreLastSessionAccesskey: "с",

			deleteUndoEntry: "Удалить",

			buttonMenu: "Меню кнопки",
			buttonMenuAccesskey: "М",

			tabContextMenu: "Недавно закрытые вкладки",
			tabContextMenuAccesskey: "о",

			itemTip: "%ago назад, %date",
			day: "д"
		}
	};
	var locale = (function() {
		if("Services" in window && "locale" in Services) {
			var locales = Services.locale.requestedLocales // Firefox 64+
				|| Services.locale.getRequestedLocales && Services.locale.getRequestedLocales();
			if(locales)
				return locales[0];
		}
		var prefs = "Services" in window && Services.prefs
			|| Components.classes["@mozilla.org/preferences-service;1"]
				.getService(Components.interfaces.nsIPrefBranch);
		function pref(name, type) {
			return prefs.getPrefType(name) != prefs.PREF_INVALID ? prefs["get" + type + "Pref"](name) : undefined;
		}
		if(!pref("intl.locale.matchOS", "Bool")) { // Also see https://bugzilla.mozilla.org/show_bug.cgi?id=1414390
			var locale = pref("general.useragent.locale", "Char");
			if(locale && locale.substr(0, 9) != "chrome://")
				return locale;
		}
		return Components.classes["@mozilla.org/chrome/chrome-registry;1"]
			.getService(Components.interfaces.nsIXULChromeRegistry)
			.getSelectedLocale("global");
	})().match(/^[a-z]*/)[0];
	_localize = function(sid) {
		return strings[locale] && strings[locale][sid] || strings.en[sid] || sid;
	};
	return _localize.apply(this, arguments);
}

var JSON = "JSON" in window
	? {
		parse: function(arg) {
			return typeof arg == "string"
				? (JSON = window.JSON).parse(arg)
				: (this.parse = function(obj) {
					return obj;
				}) && arg;
		}
	}
	: "nsIJSON" in Components.interfaces
		? {
			parse: function(s) {
				return Components.classes["@mozilla.org/dom/json;1"]
					.createInstance(Components.interfaces.nsIJSON)
					.decode(s);
			}
		}
		: {
			parse: function(s) {
				return Components.utils.evalInSandbox("(" + s + ")", new Components.utils.Sandbox("about:blank"));
			}
		};

this.onclick = function(e) {
	if(e.target != this)
		return;
	if(e.button == 1 || e.button == 0 && (e.ctrlKey || e.shiftKey || e.altKey || e.metaKey))
		this.undoCloseTabsList.clearAllLists();
	else if(
		e.button == 0
		|| e.button == 2 && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey
			&& this.undoCloseTabsList.options.rightClickToUndoCloseTab
	) {
		if(
			e.button == 0 && !this.undoCloseTabsList.options.useMenu
			|| e.button == 2 && this.undoCloseTabsList.options.rightClickToUndoCloseTab
		) {
			if(this.undoCloseTabsList.closedTabCount)
				this.undoCloseTabsList.undoCloseTab();
			else
				this.undoCloseTabsList.drawUndoList() && this.undoCloseTabsList.showMenu(e);
		}
		// Allow use "command" section only from hotkey:
		e.preventDefault();
		e.stopPropagation();
	}
};
if(!this.hasOwnProperty("defaultContextId"))
	this.defaultContextId = this.getAttribute("context") || "custombuttons-contextpopup";
this.onmousedown = function(e) {
	if(e.target != this)
		return;
	if(this.undoCloseTabsList.options.useMenu) {
		if(e.button == 0)
			this.undoCloseTabsList.drawUndoList();
	}
	else if(e.button == 2) {
		var showCbMenu = e.ctrlKey || e.shiftKey || e.altKey || e.metaKey || !this.undoCloseTabsList.drawUndoList();
		this.setAttribute(
			"context",
			showCbMenu
				? this.defaultContextId
				: this.undoCloseTabsList.mpId
		);
	}
};
this.onmouseover = function(e) {
	if(e.target != this)
		return;
	if(!this.disabled)
		this.undoCloseTabsList.updUI();
	this.undoCloseTabsList.options.useMenu && Array.prototype.some.call(
		this.parentNode.getElementsByTagName("*"),
		function(node) {
			if(
				node != this
				&& node.namespaceURI == xulns
				// See https://github.com/Infocatcher/Custom_Buttons/issues/28
				//&& node.boxObject
				//&& node.boxObject instanceof Components.interfaces.nsIMenuBoxObject
				&& "open" in node
				&& node.open
				&& node.getElementsByTagName("menupopup").length
				&& this.undoCloseTabsList.drawUndoList()
			) {
				node.open = false;
				this.open = true;
				return true;
			}
			return false;
		},
		this
	);
	if(
		this.undoCloseTabsList.options.openMenuOnMouseover
		&& this.undoCloseTabsList.drawUndoList()
	)
		this.undoCloseTabsList.openMenu();
};

this.undoCloseTabsList = {
	button: this,
	options: options,
	mpId: this.id + "-context",
	cmId: this.id + "-contextSub",
	tcmId: this.id + "-tabContextMenu",
	tipId: this.id + "-tooltip",
	errPrefix: "[Custom Buttons :: Undo Close Tabs List]: ",
	get mp() {
		var btn = this.button;
		var mp = btn.getElementsByTagName("menupopup");
		mp = mp.length && mp[0];
		mp && mp.parentNode.removeChild(mp);
		mp = this.createElement("menupopup", {
			id: this.mpId,
			onclick: "this.parentNode.undoCloseTabsList.checkForMiddleClick(event);",
			onpopupshowing: "if(event.target == this) document.popupNode = this.parentNode;",
			onpopuphidden: "if(event.target == this) document.popupNode = null;"
		});
		if(this.cm)
			mp.setAttribute("context", this.cmId);
		var tb = btn.parentNode;
		if(
			this.options.useMenu
			&& tb.getAttribute("orient") == "vertical"
		) {
			// https://addons.mozilla.org/firefox/addon/vertical-toolbar/
			var isRight = tb.parentNode.getAttribute("placement") == "right";
			mp.setAttribute("position", isRight ? "start_before" : "end_before");
		}
		delete this.mp;
		return this.mp = btn.appendChild(mp);
	},
	get useCentextMenu() {
		delete this.useCentextMenu;
		return this.useCentextMenu = this.options.allowDeleteEntries
			&& ("forgetClosedTab" in this.ss || "forgetClosedWindow" in this.ss);
	},
	get cm() {
		delete this.cm;
		if(!this.useCentextMenu)
			return this.cm = null;
		var cm = document.getElementById(this.cmId);
		cm && cm.parentNode.removeChild(cm);
		cm = this.createElement("menupopup", {
			id: this.cmId,
			onpopupshowing: "return this.undoCloseTabsList.canDeleteUndoEntry(this.triggerNode || document.popupNode);"
		});
		var mi = this.createElement("menuitem", {
			oncommand: "this.parentNode.undoCloseTabsList.deleteUndoEntry(this.parentNode.triggerNode || document.popupNode);",
			label: _localize("deleteUndoEntry"),
			closemenu: "single"
		});
		cm.appendChild(mi);
		cm.undoCloseTabsList = this;
		return this.cm = document.getElementById("mainPopupSet").appendChild(cm);
	},
	get cbMenu() {
		var cbPopup = document.getElementById(this.button.defaultContextId);
		if(!cbPopup) {
			Components.utils.reportError(this.errPrefix + "cb menu not found");
			return this.cbMenu = null;
		}
		cbPopup = cbPopup.cloneNode(true);
		var id = "-" + this.button.id.match(/\d*$/)[0] + "-cloned";
		cbPopup.id += id;
		Array.prototype.slice.call(cbPopup.getElementsByAttribute("id", "*")).forEach(function(node) {
			node.id += id;
		});
		var menu = this.createElement("menu", {
			label: _localize("buttonMenu"),
			accesskey: _localize("buttonMenuAccesskey")
		});
		menu.appendChild(cbPopup);
		cbPopup.setAttribute(
			"onpopupshowing",
			'\
			var btn = document.popupNode = this.parentNode.parentNode.parentNode\n\
				.undoCloseTabsList.button;\n\
			custombutton.setContextMenuVisibility(btn);'
		);
		delete this.cbMenu;
		return this.cbMenu = menu;
	},
	get ss() {
		delete this.ss;
		return this.ss = "nsISessionStore" in Components.interfaces
			? (
				Components.classes["@mozilla.org/browser/sessionstore;1"]
				|| Components.classes["@mozilla.org/suite/sessionstore;1"]
			).getService(Components.interfaces.nsISessionStore)
			: SessionStore; // Firefox 61+ https://bugzilla.mozilla.org/show_bug.cgi?id=1450559
	},
	get appInfo() {
		delete this.appInfo;
		return this.appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
			.getService(Components.interfaces.nsIXULAppInfo);
	},
	get appVersion() {
		delete this.appVersion;
		return this.appVersion = parseFloat(this.appInfo.version);
	},
	get platformVersion() {
		delete this.platformVersion;
		return this.platformVersion = parseFloat(this.appInfo.platformVersion);
	},
	get appName() {
		delete this.appName;
		return this.appName = this.appInfo.name;
	},

	init: function() {
		window.addEventListener("TabClose",       this, false);
		window.addEventListener("SSTabRestoring", this, false);
		window.addEventListener("unload",         this, false);
		if(this.appName == "SeaMonkey") // No SSTab* events in SeaMonkey
			window.addEventListener("TabOpen", this, false);
		setTimeout(function(_this) {
			_this.mp.addEventListener("DOMMenuItemActive",   _this, false);
			_this.mp.addEventListener("DOMMenuItemInactive", _this, false);
			_this.initTooltip();
		}, 50, this);
		this.addPbExitObserver(true);
		this.updUIGlobal();
		if(this.options.showInTabContextMenu) setTimeout(function(_this) {
			_this.initTabContext();
		}, 100, this);
	},
	initTabContext: function() {
		var origMi = this.tabContextUndoClose;
		if(!origMi) {
			LOG("Can't find \"Undo Close Tab\" item in tab context menu");
			return;
		}
		var menu = document.getElementById(this.tcmId);
		menu && menu.parentNode.removeChild(menu); // For SeaMonkey
		menu = this.createElement("menu", {
			id: this.tcmId,
			label: _localize("tabContextMenu"),
			accesskey: _localize("tabContextMenuAccesskey"),
			tooltip: this.tipId,
			popupsinherittooltip: "true"
		});
		menu.undoCloseTabsList = this;
		menu.onclick = function(e) {
			if(e.target != this)
				return;
			if(e.button == 1 || e.button == 0 && (e.ctrlKey || e.shiftKey || e.altKey || e.metaKey)) {
				if(this.undoCloseTabsList.closedTabCount) {
					this.undoCloseTabsList.undoCloseTab();
					closeMenus(this);
				}
			}
		};
		var origMp = this.mp;
		var mp = origMp.cloneNode(true);
		mp.id = this.button.id + "-tabContext";
		var _this = this;
		function drawUndoList() {
			var ok = false;
			var opts = _this.options;
			var origTemplate = opts.menuTemplate;
			opts.menuTemplate = opts.menuTemplateTabContext || origTemplate;
			_this.mp = mp;
			try {
				ok = _this.drawUndoList();
			}
			catch(e) {
				Components.utils.reportError(e);
			}
			opts.menuTemplate = origTemplate;
			_this.mp = origMp;
			return ok;
		}
		function updMenu() {
			if(drawUndoList())
				menu.removeAttribute("disabled");
			else
				menu.setAttribute("disabled", "true");
		}
		mp._updatePopup = function(e) {
			if(e.target != this)
				return;
			document.popupNode = _this.button;
			drawUndoList();
		};
		mp.setAttribute("onpopupshowing", "this._updatePopup(event);");
		mp.onclick = function(e) {
			_this.checkForMiddleClick(e, updMenu);
		};
		menu.appendChild(mp);
		addEventListener("popupshown", function(e) {
			if(e.target == e.currentTarget)
				setTimeout(updMenu, 0); // Pseudo async
		}, false, origMi.parentNode);
		addEventListener("DOMMenuItemActive",   this, false, mp);
		addEventListener("DOMMenuItemInactive", this, false, mp);
		origMi.parentNode.insertBefore(menu, origMi.nextSibling);
		origMi.setAttribute("hidden", "true");
	},
	initTooltip: function() {
		var tip = document.getElementById(this.tipId);
		tip && tip.parentNode.removeChild(tip);
		tip = this.tip = this.createElement("tooltip", {
			id: this.tipId,
			orient: "vertical",
			onpopupshowing: "return this.undoCloseTabsList.updTooltip(this, this.triggerNode || document.tooltipNode);",
			onpopuphiding: "this.cancelUpdateTimer();"
		});
		tip.undoCloseTabsList = this;
		tip._updateTimer = 0;
		tip.initUpdateTimer = function(fn, context) {
			if(this._updateTimer)
				clearInterval(this._updateTimer);
			this._updateTimer = setInterval(function() {
				fn.call(context);
			}, 1000);
		};
		tip.cancelUpdateTimer = function() {
			if(this._updateTimer) {
				clearInterval(this._updateTimer);
				this._updateTimer = 0;
			}
		};
		var btn = this.button;
		btn.removeAttribute("tooltiptext");
		btn.setAttribute("tooltip", this.tipId);
		btn.setAttribute("popupsinherittooltip", "true");
		document.getElementById("mainPopupSet").appendChild(tip);
		if(this.appVersion >= 61 && "getAnonymousElementByAttribute" in document) {
			var label = document.getAnonymousElementByAttribute(tip, "class", "tooltip-label");
			label && label.remove();
		}
	},
	_hasPbExitObserver: false,
	addPbExitObserver: function(add) {
		if(add == this._hasPbExitObserver || !("Services" in window))
			return;
		this._hasPbExitObserver = add;
		if(add)
			Services.obs.addObserver(this, "last-pb-context-exited", false);
		else
			Services.obs.removeObserver(this, "last-pb-context-exited");
	},
	destroy: function() {
		window.removeEventListener("TabClose",       this, false);
		window.removeEventListener("SSTabRestoring", this, false);
		window.removeEventListener("unload",         this, false);
		if(this.appName == "SeaMonkey")
			window.removeEventListener("TabOpen", this, false);
		this.mp.removeEventListener("DOMMenuItemActive",   this, false);
		this.mp.removeEventListener("DOMMenuItemInactive", this, false);
		this.addPbExitObserver(false);
		var menu = document.getElementById(this.tcmId);
		if(menu) {
			menu.parentNode.removeChild(menu);
			this.tabContextUndoClose.removeAttribute("hidden");
		}
		var tip = this.tip;
		tip && tip.parentNode && tip.parentNode.removeChild(tip);
	},
	handleEvent: function(e) {
		switch(e.type) {
			case "TabClose":
			case "SSTabRestoring":
			case "TabOpen":
				setTimeout(function(_this) {
					_this.updUI();
				}, 0, this);
			break;
			case "DOMMenuItemActive":
			case "DOMMenuItemInactive":
				if(!("XULBrowserWindow" in window))
					break;
				XULBrowserWindow.setOverLink(
					e.type == "DOMMenuItemActive"
						? (e.target.getAttribute("cb_urlDecoded") || "")
							.replace(/ \n/g, ", ")
						: "",
					null
				);
			break;
			case "unload":
				this.updUIGlobal();
				this.destroy();
		}
	},
	observe: function(subject, topic, data) {
		if(topic == "last-pb-context-exited") {
			setTimeout(function(_this) {
				_this.updUI();
			}, 25, this);
		}
	},

	createElement: function(name, attrs) {
		var node = document.createElementNS(xulns, name);
		if(attrs) for(var attrName in attrs) if(attrs.hasOwnProperty(attrName))
			node.setAttribute(attrName, attrs[attrName]);
		return node;
	},
	get tabContextUndoClose() {
		return document.getElementById("context_undoCloseTab")
			|| document.getElementById("tabContextUndoCloseTab") // Firefox 2.0
			|| document.getAnonymousElementByAttribute(gBrowser, "tbattr", "tabbrowser-undoclosetab"); // SeaMonkey
	},
	get closedWindowCount() {
		if(!("getClosedWindowCount" in this.ss)) {
			delete this.closedWindowCount;
			return this.closedWindowCount = 0;
		}
		this.__defineGetter__("closedWindowCount", function() {
			return this.ss.getClosedWindowCount();
		});
		return this.closedWindowCount;
	},
	get closedTabCount() {
		return this.ss.getClosedTabCount(window);
	},
	undoCloseTab: function(i) {
		if("undoCloseTab" in window) // Firefox 2.0+
			undoCloseTab(i);
		else // SeaMonkey
			gBrowser.undoCloseTab(i);
	},
	clearUndoTabsList: function() {
		var closedTabCount = this.closedTabCount;
		if(!closedTabCount)
			return;
		if("forgetClosedTab" in this.ss) // Gecko 1.9.2+
			while(closedTabCount--)
				this.ss.forgetClosedTab(window, 0);
		else {
			// Doesn't work in SeaMonkey
			const pName = "browser.sessionstore.max_tabs_undo";
			let val = cbu.getPrefs(pName);
			cbu.setPrefs(pName, 0);
			cbu.setPrefs(pName, val);
		}
		this.updUIGlobal();
	},
	clearUndoWindowsList: function() {
		var closedWindowCount = this.closedWindowCount;
		if(!closedWindowCount)
			return;
		if("forgetClosedWindow" in this.ss) // Gecko 1.9.2+
			while(closedWindowCount--)
				this.ss.forgetClosedWindow(0);
		else
			this.ss.setWindowState(window, '{"windows":[{}],"_closedWindows":[]}', false);
		this.updUIGlobal();
	},
	clearAllLists: function() {
		this.clearUndoTabsList();
		this.clearUndoWindowsList();
	},
	canDeleteUndoEntry: function(mi) {
		switch(mi.getAttribute("cb_type")) {
			case "tab":    return "forgetClosedTab"    in this.ss;
			case "window": return "forgetClosedWindow" in this.ss;
		}
		return false;
	},
	deleteUndoEntry: function(mi) {
		var i = +mi.getAttribute("cb_index");
		if(mi.getAttribute("cb_type") == "window") {
			this.ss.forgetClosedWindow(i);
			this.updUIGlobal();
		}
		else {
			this.ss.forgetClosedTab(window, i);
			this.updUI();
		}
		this.drawUndoList();
	},
	showMenu: function(e, isContext, mp) {
		var btn = this.button;
		document.popupNode = btn.ownerDocument.popupNode = btn;
		if(!mp)
			mp = this.mp;
		if("openPopupAtScreen" in mp)
			mp.openPopupAtScreen(e.screenX, e.screenY, isContext);
		else
			mp.showPopup(btn, e.screenX, e.screenY, isContext ? "context" : "popup", null, null);
	},
	openMenu: function() {
		var mp = this.mp;
		if("openPopup" in mp)
			mp.openPopup(this.button, "after_start");
		else
			mp.showPopup(this.button, -1, -1, "popup", "bottomleft", "topleft");
	},
	drawUndoList: function() {
		var mp = this.mp;

		var wc = this.closedWindowCount;
		var tc = this.closedTabCount;
		var ss = this.ss;
		var canRestoreLastSession = "restoreLastSession" in ss && ss.canRestoreLastSession
		if(!wc && !tc && !canRestoreLastSession) {
			mp.textContent = "";
			mp.hidePopup();
			return false;
		}

		this._undoWindowItems = wc && JSON.parse(ss.getClosedWindowData());
		this._undoTabItems    = tc && JSON.parse(ss.getClosedTabData(window));
		var df = document.createDocumentFragment();

		this.options.menuTemplate.forEach(function(sid, indx, arr) {
			switch(sid) {
				case "closedWindows":
					wc && this.addUndoWindowsList(df);
				break;
				case "restoreClosedWindows":
					wc > this.options.hideRestoreAllForSingleEntry
					&& df.appendChild(this.createElement("menuitem", {
						label: _localize("restoreAllWindows"),
						accesskey: _localize("restoreAllWindowsAccesskey"),
						oncommand: "for(var i = 0; i < " + this._undoWindowItems.length + "; ++i) undoCloseWindow();"
					}));
				break;
				case "clearClosedWindows":
					wc && df.appendChild(this.createElement("menuitem", {
						label: _localize("clearWindowsHistory"),
						accesskey: _localize("clearWindowsHistoryAccesskey"),
						oncommand: "this.parentNode.parentNode.undoCloseTabsList.clearUndoWindowsList();"
					}));
				break;
				case "closedTabs":
					tc && this.addUndoTabsList(df);
				break;
				case "restoreClosedTabs":
					tc > this.options.hideRestoreAllForSingleEntry
					&& df.appendChild(this.createElement("menuitem", {
						label: _localize("restoreAllTabs"),
						accesskey: _localize("restoreAllTabsAccesskey"),
						oncommand: "for(var i = 0; i < " + this._undoTabItems.length + "; ++i) this.parentNode.parentNode.undoCloseTabsList.undoCloseTab();"
					}));
				break;
				case "clearClosedTabs":
					tc && df.appendChild(this.createElement("menuitem", {
						label: _localize("clearTabsHistory"),
						accesskey: _localize("clearTabsHistoryAccesskey"),
						oncommand: "this.parentNode.parentNode.undoCloseTabsList.clearUndoTabsList();"
					}));
				break;
				case "clearAll":
					(
						wc && tc
						|| wc && arr.indexOf("clearClosedWindows") == -1
						|| tc && arr.indexOf("clearClosedTabs") == -1
					)
					&& df.appendChild(this.createElement("menuitem", {
						label: _localize("clearAllHistory"),
						accesskey: _localize("clearAllHistoryAccesskey"),
						oncommand: "this.parentNode.parentNode.undoCloseTabsList.clearAllLists();"
					}));
				break;
				case "restoreLastSession": // Gecko 2.0+
					canRestoreLastSession && df.appendChild(this.createElement("menuitem", {
						label: _localize("restoreLastSession"),
						accesskey: _localize("restoreLastSessionAccesskey"),
						oncommand: "this.parentNode.parentNode.undoCloseTabsList.ss.restoreLastSession();"
					}));
				break;
				case "buttonMenu":
					let cbMenu = this.cbMenu;
					if(cbMenu)
						df.appendChild(cbMenu);
				break;
				case "separator":
					if(df.hasChildNodes() && df.lastChild.localName != "menuseparator")
						df.appendChild(document.createElementNS(xulns, "menuseparator"));
				break;
				default:
					Components.utils.reportError(this.errPrefix + 'Invalid template entry: "' + sid + '"');
			}
		}, this);

		while(df.hasChildNodes() && df.lastChild.localName == "menuseparator")
			df.removeChild(df.lastChild);

		this._undoWindowItems = this._undoTabItems = null;

		mp.textContent = "";
		if(!df.hasChildNodes()) {
			mp.hidePopup();
			return false;
		}
		mp.appendChild(df);
		return true;
	},
	addUndoWindowsList: function(undoPopup) {
		// Based on code from chrome://browser/content/browser.js
		// Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.3a1pre) Gecko/20090824 Minefield/3.7a1pre

		var keys = this.options.accesskeys.closedWindows;
		this._undoWindowItems.forEach(function(undoItem, i) {
			var tabs = undoItem.tabs;
			var [key, keyPrefix] = this.getKey(keys, i);
			var title = undoItem.title;
			var selected = undoItem.selected;
			var selectedTab = tabs[selected && selected - 1];
			var urls = [];
			tabs.forEach(function(tab) {
				if(!tab.entries || !tab.entries.length) // Can be [] for about:blank
					return;
				var url = this.convertURI(tab.entries[tab.index - 1].url, 120);
				var selectedPrefix = tab == selectedTab && tabs.length > 1
					? this.options.windowSelectedTabPrefix
					: "";
				urls.push(selectedPrefix + url);
			}, this);
			var url = urls.join(" \n");
			var mi = this.createElement("menuitem", {
				label: keyPrefix + this.options.windowItemTemplate
					.replace("%title", title)
					.replace("%count", tabs.length),
				accesskey: key,
				"class": "menuitem-iconic bookmark-item menuitem-with-favicon",
				oncommand: "undoCloseWindow(" + i + ");",
				cb_url: url,
				cb_urlDecoded: this.convertURI(url),
				cb_closedAt: undoItem.closedAt || 0,
				cb_index: i,
				cb_type: "window"
			});
			if(this.cm)
				mi.setAttribute("context", this.cmId);
			var icon = selectedTab.image || selectedTab.attributes && selectedTab.attributes.image;
			if(icon)
				mi.setAttribute("image", this.cachedIcon(icon));
			if(i == 0)
				mi.setAttribute("key", "key_undoCloseWindow");
			undoPopup.appendChild(mi);
		}, this);
	},
	addUndoTabsList: function(undoPopup) {
		// Based on code from chrome://browser/content/browser.js
		// Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.3a1pre) Gecko/20090824 Minefield/3.7a1pre

		var keys = this.options.accesskeys.closedTabs;
		this._undoTabItems.forEach(function(undoItem, i) {
			var state = undoItem.state;
			var [key, keyPrefix] = this.getKey(keys, i);
			var title = undoItem.title;
			var url = state && state.entries && state.entries[state.index - 1].url || "";
			var mi = this.createElement("menuitem", {
				label: keyPrefix + title,
				accesskey: key,
				class: "menuitem-iconic bookmark-item menuitem-with-favicon",
				oncommand: "this.parentNode.parentNode.undoCloseTabsList.undoCloseTab(" + i + ");",
				cb_url: url,
				cb_urlDecoded: this.convertURI(url),
				cb_closedAt: undoItem.closedAt || 0,
				cb_index: i,
				cb_type: "tab"
			});
			if(
				state
				&& "attributes" in state
				&& "privateTab-isPrivate" in state.attributes
			) // https://addons.mozilla.org/addon/private-tab/
				mi.setAttribute("privateTab-isPrivate", "true");
			if(this.cm)
				mi.setAttribute("context", this.cmId);
			var image = undoItem.image // Firefox
				|| state && state.attributes && state.attributes.image // SeaMonkey
				|| state && state.xultab
					&& /(?:^| )image=(\S+)/.test(state.xultab)
					&& decodeURI(RegExp.$1); // Only Firefox 2.0 ?
			if(image)
				mi.setAttribute("image", this.cachedIcon(image));
			if(i == 0)
				mi.setAttribute("key", "key_undoCloseTab");
			undoPopup.appendChild(mi);
		}, this);
	},
	getKey: function(keys, i) {
		var key = keys && keys.charAt(i % keys.length);
		var keyPrefix = keys && (key + this.options.accesskeySeparator);
		return [key, keyPrefix];
	},
	checkForMiddleClick: function(e, upd) {
		var mi = e.target;
		if(
			"doCommand" in mi
			&& e.button == 1
			&& mi.parentNode == e.currentTarget
		) {
			mi.doCommand();
			if(upd)
				upd();
			else
				this.drawUndoList();
		}
	},
	crop: function(s, crop) {
		if(crop == undefined)
			crop = 500;
		if(s.length <= crop)
			return s;
		var start = Math.round(crop*0.6);
		return s.substr(0, start) + "…" + s.substr(start - crop);
	},
	convertURI: function(uri, crop) {
		if(!uri || uri.indexOf("\n") != -1)
			return uri;
		uri = this.losslessDecodeURI(uri);
		return this.crop(uri, crop);
	},
	losslessDecodeURI: function(uri) {
		if(uri) try {
			return this._losslessDecodeURI(uri);
		}
		catch(e) {
			Components.utils.reportError(e);
		}
		return uri;
	},
	get _losslessDecodeURI() {
		var ldu;
		if("losslessDecodeURI" in window)
			ldu = losslessDecodeURI;
		else if("UrlbarInput" in window) // Firefox 75+
			ldu = Components.utils.import("resource:///modules/UrlbarInput.jsm", {}).losslessDecodeURI;
		delete this._losslessDecodeURI;
		return this._losslessDecodeURI = ldu
			? function(uri) {
				return ldu(makeURI(uri));
			}
			: decodeURI;
	},
	cachedIcon: function(src) {
		src = src.replace(/[&#]-moz-resolution=\d+,\d+$/, ""); // Firefox 22+
		if(
			!/^https?:/.test(src)
			// IDN, see https://bugzilla.mozilla.org/show_bug.cgi?id=311045
			|| /^https?:\/\/[^.:\/]+\.[^a-z0-9-]+(?:\/|$)/.test(src) && this.platformVersion < 46
			|| this.appName == "SeaMonkey" && this.appVersion <= 2
			|| this.appName == "Firefox"   && this.appVersion <= 3.5
		)
			return src;
		return "moz-anno:favicon:" + src; // https://bugzilla.mozilla.org/show_bug.cgi?id=467828
	},
	updUI: function() {
		var tabsCount = this.closedTabCount;
		var dis = !tabsCount && !this.closedWindowCount;
		if(
			dis
			&& this.options.useMenu
			&& this.options.menuTemplate.indexOf("restoreLastSession") != -1
			&& "restoreLastSession" in this.ss && this.ss.canRestoreLastSession
		)
			dis = false;
		this.button.disabled = dis;
	},
	updTooltip: function(tip, tn) {
		var template, header, title, url, closedAt;
		if(tn == this.button) {
			template = this.options.buttonTipTemplate;
			header = _localize("restoreTab");
			let undoTabItems = JSON.parse(this.ss.getClosedTabData(window));
			if(undoTabItems.length) {
				let lastItem = undoTabItems[0];
				title = lastItem.title;
				url = lastItem.state && lastItem.state.entries
					&& lastItem.state.entries[lastItem.state.index - 1].url;
				closedAt = lastItem.closedAt || 0;
			}
		}
		else if(tn.hasAttribute("cb_index")) {
			template = this.options.itemTipTemplate;
			title = tn.getAttribute("label");
			url = tn.getAttribute("cb_url");
			closedAt = +tn.getAttribute("cb_closedAt");
		}
		else {
			return false;
		}

		var tipData = this.getTooltipData(template, header, title, url, closedAt);
		tip.textContent = "";
		tip.appendChild(tipData);
		if(closedAt && template.indexOf("closedAt") != -1) {
			tip.initUpdateTimer(function() {
				var tipData = this.getTooltipData(template, header, title, url, closedAt);
				if(tipData.textContent != tip.textContent) {
					tip.textContent = "";
					tip.appendChild(tipData);
				}
			}, this);
		}
		return tip.hasChildNodes();
	},
	getTooltipData: function(template, header, title, url, closedAt) {
		var df = document.createDocumentFragment();
		var hasHeader = header && template.indexOf("header") != -1;
		function item(key, val) {
			var lbl = document.createElementNS(xulns, "label");
			lbl.className = "cb-" + key + " tooltip-label";
			lbl.textContent = val;
			lbl.setAttribute("maxwidth", "450"); // Trick to restore right border for long lines
			if(key == "closedAt" || hasHeader && key != "header")
				lbl.style.color = "grayText";
			return df.appendChild(lbl);
		}
		template.forEach(function(key) {
			switch(key) {
				case "header":
					if(header)
						item(key, header);
				break;
				case "title":
					if(title && title != url)
						item(key, title);
				break;
				case "url":
					if(url)
						item(key, this.convertURI(url));
				break;
				case "closedAt":
					if(!closedAt)
						break;
					let dt = Math.round(Math.max(0, Date.now() - closedAt)/1000);
					let days = Math.floor(dt/24/3600);
					dt -= days*24*3600;
					let d = new Date((dt + new Date(dt).getTimezoneOffset()*60)*1000);
					let m = d.getMinutes();
					let ts = d.getHours() + ":" + (m > 9 ? m : "0" + m);
					if(days)
						ts = days + _localize("day") + " " + ts;
					let tsTip = _localize("itemTip")
						.replace("%ago", ts)
						.replace("%date", new Date(closedAt).toLocaleString());
					item(key, tsTip);
			}
		}, this);
		return df;
	},
	get wm() {
		delete this.wm;
		return this.wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
			.getService(Components.interfaces.nsIWindowMediator);
	},
	updUIGlobal: function() {
		var isSeaMonkey = this.appName == "SeaMonkey";
		var ws = this.wm.getEnumerator(isSeaMonkey ? null : "navigator:browser");
		const id = this.button.id;
		while(ws.hasMoreElements()) {
			let win = ws.getNext();
			if(isSeaMonkey && !this.isBrowserWindow(win))
				continue;
			let btn = win.document.getElementById(id);
			if(btn && "undoCloseTabsList" in btn) {
				let ucl = btn.undoCloseTabsList;
				ucl.ensureSessionsInitialized(ucl.updUI, ucl);
			}
		}
	},
	isBrowserWindow: function(win) {
		var loc = window.location.href;
		return loc == "chrome://browser/content/browser.xul"
			|| loc == "chrome://navigator/content/navigator.xul";
	},
	ensureSessionsInitialized: function(callback, context) {
		var _this = this;
		var stopTime = Date.now() + 3e3;
		(function ensureInitialized() {
			try {
				_this.ss.getClosedTabCount(window);
				callback.call(context);
				return;
			}
			catch(e) {
				if(Date.now() > stopTime) {
					Components.utils.reportError(
						_this.errPrefix
						+ "Can't initialize: nsISessionStore.getClosedTabCount() failed"
					);
					Components.utils.reportError(e);
					return;
				}
			}
			setTimeout(ensureInitialized, 50);
		})();
	}
};

if(!this.undoCloseTabsList.options.useMenu && this.undoCloseTabsList.useCentextMenu) {
	this.oncontextmenu = function(e) {
		if(
			e.target != this
			|| e.ctrlKey || e.shiftKey || e.altKey || e.metaKey
			|| !this.undoCloseTabsList.mp.hasChildNodes()
		)
			return;
		e.preventDefault();
		this.undoCloseTabsList.showMenu(e); // Show menu without "context" flag
	};
}
if(this.undoCloseTabsList.options.rightClickToUndoCloseTab) {
	this.oncontextmenu = function(e) {
		if(e.target == this && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey)
			e.preventDefault();
	};
}

this.disabled = true;
setTimeout(function(_this) {
	_this.undoCloseTabsList.init();
}, 0, this);

//===================
// Styles
// Used icons from Undo Closed Tabs Button extension

// Styles can't override hardcoded icon
if( // Remove icon only if nsIStyleSheetService works on-the-fly (Firefox 3.0+)
	!Components.ID("{41d979dc-ea03-4235-86ff-1e3c090c5630}")
		.equals(Components.interfaces.nsIStyleSheetService)
) {
	let icon = this.icon
		|| this.ownerDocument.getAnonymousElementByAttribute(this, "class", "toolbarbutton-icon");
	if(icon)
		icon.src = "";
	else
		this.image = "";
}

var cssStr = '\
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");\n\
	@-moz-document url("%windowURL%") {\n\
		%button% {\n\
			list-style-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAEEUlEQVRIS9XVbWxTVRgA4Pfce3tv27t2bbNuXbfCBuyzAZ2MEdkkLH5gJvEH8TOZEo0JFdgmbgjTgEHUGQXGMJEMmDJMiNvQjS9BJhH8MY3IfsB0rnTraCcbm13b2+/1fni2xAVuxOHAH57+adNz3uee9z3vuQj+44FmG79VksglAIoMgBhCSLpdnFkBkiQxl2OQgRdbJhjoKkQofM+ALklSGSNwf1iAjbXNZ3MdI+MB+7vPF989IEnoZwBVQhCWBgVhW13b+WX5KXpFR7fDe/ntZ8wYiONUiXLojlKEU4LGANgRDpZHBH7r9iPnilZaM4jKFTlQ/P5XvHV+6o5si7HzuWUL+hzngSstRfxf0DSwa9cHa3GgWgmQTv4UNMMggyWTMuYtYepOXCKfKMiGZ4tyQEMDjPrDcGVoDI780As3/AGhJIVs2vTk6pqkJAhOFn8KaG1tpV1u53h5+RpGr7s1/uTxCIgk6g/EiaqmM2i5NRseL7SCgwMg8Wo9A5CsBLjPADDki8CbbRdgQiI631n/2NOFANwUUF9frxPECVf1628gn893Sx55IIhxBavcffIi1fO7H15atRJiAoD8XBI4UmYCwOIkCdY3fyuyrGrHZ+UldXJAwoDn5hThQESYpNXXQpJuw4HTiuzM+fBAfu7UFIQ/0wN/nfydrEKwSCdARfMZftVSa6kcEPx+v0NeA7wlKowYXX+AT604+DWTmT4XcufhFsN6r9MJ/gAHiVotpBmNoNNoIctAw8Xf7FKMjx2TA7zX6/3p7860SBCKEGJSBrj4PIyozMkm0KhZsDv7hTUP5Xt+HfFpuvqGVBZTKizEuOePEYiL0V/kQJzjuG9u1zS8RDAhRFv6/FFr5YFTaopicJGRt932yDmJQLQ3JpY9+lEHVZCTB6PecTAmEMNyIIZr8MU/3U8iSSo5RGfZPZGFFftPaU0a9dgxW+mXBEGQtJJ5xbq1hUo3mdENzxjYyoq65UAUA5/MdAGKiFQHSGbB1WEPDZGIq3COYRQD1I/XPJttn39PKRlWYpUgfvraU2/JgXAwGHxvRkAUEd6JAteYJAUhioNLwaigLN1z8sNQLA5mQyK//YWHr8zRaV9EjY2NikDAuwkQ2oL7IIRH9UzATf9PPuBUS4gIKY92u/Zf5zhixaKsAa1BXzOhhrNoz96d21JNaavT0tO9xQ+W5GDg5X8BTE/lCSIBUcqW3kGX3XW1Jz7sdtVXrn31EGpo2Nm0bl1VHt7maTw7Eo1GL8wGwPcOiRSKMpIgUpzOAd2JjqOdNTW1B1HDx7ttlRs2mnCDHZ5NYPkalmXnut3uxe3tbZeqqzd/h/bt21tgs1WocYP13AtAr9cnDg4Omo8fb7leVbXFdUfvg7uB///An8idyhRIYoVPAAAAAElFTkSuQmCC") !important;\n\
		}\n\
		%button%:hover {\n\
			list-style-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAECUlEQVRIS9XVe2xTVRgA8O/ce3tv310fa8P6AOoapwznYtXFzchQJNEYNTHEODSaYLK4jsEaGcQnEpAQu8r+WLJMMmOMIQXnNgeKYTJjfBGzMEGTztVubcGmD9q1t+263t7r2Qxka8DhwD88//SP2/P97vd95zsXwX+80ErjC4JAjE4BvWEN5BFCwvXirAjAwWkfgIVjwczK4Sc7QtlbBpwRBLG+ADVcDnbu+fjUHZMX4+mJA00NNw8IAvoZQKIEsLOp4pv7PaMP2jRKanjclzi/99kKDBSuVaobKhEuCYoCyKIZaMjOcW+89clIXe1qA9H80Hp4uqu/UGszvlNl1J/eVF/pjY9CurERcVcyugq4XAdf5gXowP2SL00XAUkzSGteSxuq7LIDw2Miu9UET9y7DhgSwHcpAhN/RuHrC34QeJ57wED17nryqQ6dDtj5jBYAj8dDB4L+WNNzz0uUStWS+PPHI4so5EtzRNuRL9Hday1QX22D6RkOSLxbShGgZAgwKSiYjsTgo2/GQCGTfbXP8egWO0BqAXC73WVFfi7gbN+Fkskkv1jggCAui2Ri1/BZ6pfpGGy+7x7IFnjA2f69rvziSDopBUY5Cd1ffMtXmfX7+rY2vFsKCBiILwbwfiJL0tIpVihz9J4UlWvL4TaTaWnwRZaMJkFOzMFnP5zjmhprG0uB4szMzGTpkcMImQFG7csUV7X2nmA0ZRow6w2Amw/BSARmZ3MgFotBi8srk0iAERHweygkVBoUg6UAl0gkzl7rTPMEIcogxuBPcVbHByckKrkKJIwYwtFw8cUN1bFfLyaU33uDEp1KDQatDkLRCNy+SnGhFCikUqlT1xsaTiCYDKLNE+n8ndt7Tkp5QKhcKkoMtTwyUgREx7LcY5tdg5TNtBoSbBos5ZJLpUAe9+DoP91PHEmKWUTbJpP59Y7uIYVBKY0NNm/8lCAIkqBE22re9lB6rR7FUwl45fH7x0qBWQx0L3cB8oiUpkmm0h9JiIRsNlBrUkcxQI14w7udx34kxIwE9wLxfW3P7CkFsizL7l8W4HnEk6RovvlksTiLgwvJXEG6sXP4YJ4rQoVGxe3d+vC41ax8AfX09IhS7OXXEBDteA4yeDmXAxY9n3/BhUnApvjoOX9vPJODhnXWKbVWsyMlhdOo8/1Dr1tMa7YYjRWpurp6KwZe+hfA1b/iAyAHmvZ4g0Ff0PtbLhzwH25pbulDne5DPa2OnXfhNAeLON1CofDdSgB875Akw2zCKZn8f0xKhz4fGH21veMIch9+b9uO7U4LHrAPVxK4dI9MJrMGAoHqgYHj405nxxnU1eWqaW1tV+ABO38rALVaXRYK+Q39/Z5wW9vuwA19D24G/v8DfwHJNM8naEZRUgAAAABJRU5ErkJggg==") !important;\n\
		}\n\
		%button%[disabled="true"] {\n\
			list-style-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADCklEQVRIS9WVz0sbQRTHZ3Y32awxYkOIMaQQjBJ026zVVLCeCpX2H2jpqaceSjGnUpBcKj0IpVA81UtLT4VCoYdepJcapBYKGjfNbwNqTGJsbGKi5pdmd/s2tEVCjBrroQMLw8x77/Pem+/MYnTOA59zfHQmwPj4+AWCIG5OTk6+OyrRpgFOp7MTgn6pVCpdLS0t9MTExH49SFMACNaFMZ7v6enRRSKRiiRJnbCWbQgAI8LjWbyBMaFtdC7r67GLwWD4CQRnLBYL4XK5yoIgbKpUqkB7e9u3oSHrlMViz/2J8bcCnl/8TJCUmVJQW0cB0ls/W91u3gqDNBqNVTNoEcrlcmhnZwdtJDdEiqSEUql0zeFwLMj7VYDf728t7xdTV/oHFeBQrAdIJpPkzMwMA5ljnU5XNwfoAgI7tLKyUhJF0T42NuavApaWltolJEQBQGWz2Xw971gsRvM8r+nr68NKpbKhulOplBSNRldBYWwtgNze3o4d5b28vKxdW1vTQRWEQqFoCIEqCtC26VoAARV4GnkCxJRIJExms5mEgeLxuJDP5wmKokSNRkNotVosw/f29hDYLdQCMABcx91ukKYV2mAxGAykDBgZGflUKBQYCHoVMlebTCYMypLh8VoA2t3d/XAcQN4Ph8P2TCbTC1NxeHj4rbwGFYzOuma1jIphoCKUTqdjtQAJAK9PApBtoF3Xi8WimeO4N78Bt+fm5vRqtZqGivIHBwePawEiaPr5SQFVncPNBHmK8hza4giFQx0KSlGB4D/0en13LUAAgPM0gMO2cKhTcA40yNMN79Moy7IZ7PV6OyrC/iuMkZ2zDSgB8KBZADwXz4KhgIAkKQECe2SzDS5ij8c9beg03tK0tpUZhtHANb93BsAU+KvyhXwlHl+f7+cG7uPvPv7FZZazQv9eQi+Fcrm82SyApmk9nIkK/B8GAr6vNlv/U+wL+O6yvawR1PC+2cCH/QBAwlNyJxTyhViW+4gjEa+lu/sSA0ar/wIgCwu+rmAwmIN3K9rUD+c0ifz/gF/LJ4uAUJQHTwAAAABJRU5ErkJggg==") !important;\n\
		}\n\
		toolbar[iconsize="small"] %button% {\n\
			list-style-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACPElEQVQ4T2NkIBL8//+fEQj+oytnJEY/UDPXzPOPTdINZQ+jG0LQgPvv/wvsvf9k54FzN432X39S9rQ3oR/ZUrgBvb29akxMf7mQJcWVNYTeCWvOfvrijVK9nymDRevqKwqsfxdYiLDNqUgP+whSCzZg4sS+dkYmxlx2NrYfMAM4efiYXonr8Z27/4q52NeGQZiLlYGd4Q/D9iuPGDafu/3/zZevvocrwraCDZgwoWd/QECwtbi4xD8QHxRS178xsPq2LmfKC/FlEBAUYfgDFORlZWCQ52FgUOP5zVCz9sjfiw/eKMENCAwMMeXl5XsMc8FPJhbOjv235A5fe8zoZWvLwMTIxPD45UsGPm5uBiVxQQZN7u8MnVtPXUN2gbGAgOAJpDBg/MrIKtCy/bLRsVtPmXi4uBj+/fn2+9vPvyycHJyMLgZaDAcvXPoFN8A/IMhIUEBoLUoIA+Ps4382qfotZ112nL3JVOyieyjdQYfXuGWtgbCgCOOnzx//IrvAgJ9fYDKWdMH4mYlduX/HOa0AHamD3Jyc5v5TtptzsrMzeBmrXWKcNGkS399/Pw8GBoTIA71QgSNhwaL7/9zjdzN6d10wdDdR/5XrbWbNOHvOjA18fHwmTo6ubECQQChlcnBzR5y9/yT4wcVTb1+/fW7DuGjR3EXR0QlfgMn16N+/fy8TMoCJiUkCiK0PHNqvduXSuTrGNWtWugcHh737+PHjHUKaYfL8/Pyip04dV7tw4dBhgnmBkKEUGwAAgK/XtUYSNDQAAAAASUVORK5CYII=") !important;\n\
		}\n\
		toolbar[iconsize="small"] %button%:hover {\n\
			list-style-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACRElEQVQ4T2NkIBr8Z2RgYPyPrhwoSBj8//+fbfXt11phqqIXGRhRDSFoAFAzz8KLzzdvP3nZ+titFwWPe+OnIVsJN6BnSo88ww8GTmRJBRUV/jeSuvOOXL6nVeJuxBA3Z+cZWfY/M0x1BZc3+Pp+A6kFGzBxYm8T0GnFrKwsP2AGsHPyMH2RNebdfukxc6KLOYMAFzvDq3fvGC49fMFw+dGL/z9+/nQ7UBm+B2zAhIk9+3x9A2ylJKX/gfigkLr9jZHVt305Y4i9JQMbJy/Dn3//GbhZmRiEuVgYWP9+ZVh19MLfHz9/y0MMmNCz39cvwEJQQOgBzAU/mdg4m3dflTty7TGjkYYm2KmvP3xg4OLgYBDm42H48/09w/UnLy8hG2AuLCRyFCkMGL8ysAo0brtoeOzmEyZ2NjYGFsY/v7///sfCzMTCKCEiyvDo+dNfcAP8/AJNhYSEV6GEMCMj0BA2yaqNZ1x3nr/FlO+kfSTbSY/bqHmtAQ8PH+OPH9/+ohggKCjUhyVVMH5hYlfs3XFeO1BH8hAHB4d50NTt5pzs7AyuhioXGWfO7OD/9p35EDAQFcVExYuxJat///6BLWJiYvo/59jtjN5dF418zDV/ZbpZWDDOnTtzI7+AoLGDvSM3KytbFKF0ycHNHXnx/tPgW+dPvnn99qk948LF8+bFRMV/Aqa4Y9+/f79G0AAODjGgUywOHdivefHipUbGVetWOYUGhr778OEDPAoJGSIgICB87Ngh5bNnL54gmBcIGUaxAQAqY9puYCzN/wAAAABJRU5ErkJggg==") !important;\n\
		}\n\
		toolbar[iconsize="small"] %button%[disabled="true"] {\n\
			list-style-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAB70lEQVQ4T2NkoBAwEqu/vLzcjpOT81pDQ8MbZD1EGVBZWZn579+/qUxMTBXt7e1dGAbcv3+f4/2n9z6M//7zoLvo7NlzXh8+fPQTFxdnfwEEvPy8R+RlpWd4evruBakFu+DCpfNLONg4/NjZ2X4jG3D16jWup0+fsRsZGTGysLAwvH79muH9+/cMQHMY2NjY8jMzMyfBDNivrKhs+f8/wy+YAb9+/WJcs2YNj66uLgMvLy+Kw75//85w6dKl74yMjNZwAxQVlEz//f13D1nlgwcPBG/evCmloqLCBFQMth1oMwMfHx/Dx48f/z99+vQssgHGDP8ZjqCHwd27d+UfP36szs7ODvLGO2BAcgNdwCEhIcH46NGjt8gGGP3/938VtmgFBrIB0N8mcnJyB1VVVbkOHjxgzMnJxfT169cnCAPklQyApk/AlS6ePXumJSQk9ACoxuHKlStmQPonUG0e4+XLl8X//v29V0lJWQoYKaWEEtaXL1/SgX43AQbJWhMT01DGq9ev7ODm4tKWEJdi+/PnTxwhA4CpMfz161e+79+/e/f7919Pxtu3b85RUlJ5+////8PAwLlPyAAODg5BoPONXr16YfDmzbtWxseP79vLyCgAY+j9Q0KaYfJAVwgCA1DpzZs3p4nKC/gMptgAAO1G2FJifkXnAAAAAElFTkSuQmCC") !important;\n\
		}\n\
	}'
	.replace(/%windowURL%/g, window.location.href)
	.replace(/%button%/g, "#" + this.id);
var cssURI = this.cssURI = Components.classes["@mozilla.org/network/io-service;1"]
	.getService(Components.interfaces.nsIIOService)
	.newURI("data:text/css," + encodeURIComponent(cssStr), null, null);
var sss = this.sss = Components.classes["@mozilla.org/content/style-sheet-service;1"]
	.getService(Components.interfaces.nsIStyleSheetService);
if(!sss.sheetRegistered(cssURI, sss.USER_SHEET))
	sss.loadAndRegisterSheet(cssURI, sss.USER_SHEET);


this.onDestroy = function(reason) {
	this.undoCloseTabsList.destroy();
	if(reason == "destructor") // May happens before "unload"
		this.undoCloseTabsList.updUIGlobal();
	if(reason == "update" || reason == "delete") {
		let sss = this.sss;
		let cssURI = this.cssURI;
		if(sss.sheetRegistered(cssURI, sss.USER_SHEET))
			sss.unregisterSheet(cssURI, sss.USER_SHEET);
	}
};
if(this.undoCloseTabsList.options.useMenu) {
	this.type = "menu";
	this.orient = "horizontal";
}

Отсутствует

 

№12930-03-2024 14:06:51

Alex_one
Участник
 
Группа: Members
Зарегистрирован: 27-09-2015
Сообщений: 151
UA: Firefox 115.0

Re: [CB]Undo Close Tabs

VORON пишет

Вот это - работает

В Инициализацию - верно ведь?
Не хочет и всё тут. Значок неактивный.

Отсутствует

 

№13030-03-2024 14:42:03

VORON
Участник
 
Группа: Members
Зарегистрирован: 03-04-2013
Сообщений: 158
UA: Firefox 124.0

Re: [CB]Undo Close Tabs

Alex_one
Да, в инициализацию
А попробую мою,тоже не будет работать?

скрытый текст

Выделить код

Код:

custombutton://%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0D%0A%3Ccustombutton%20xmlns%3Acb%3D%22http%3A//xsms.nm.ru/custombuttons/%22%3E%0A%20%20%3Cname%3EUndo%20Close%20Tab%3C/name%3E%0A%20%20%3Cimage%3E%3C%21%5BCDATA%5Bdata%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABZVBMVEX////w8PD09PTx8fHw8PCPkIvv7++LjIfw8PDu7u6ZmZXv7+/29vbw8PD///+Txdt8lJ2RkY2Sk4+bzeJcnLsbcp6LjIcwf6bg4N/m//+XyuDf7/+LvNGmr68ufqbg4N9OhaLm8PJvrstCjrPg4N9Rk7Q8hqfk8PRoqMc5h60vgKk9ia/f4N7w8PDi7/ZgpMOLtMny9fYmeaIqfaff4N6hpKLv7+/h8PVwqcTB1N3L3ebv7+9trMqLjIeOj4rf39719vbM7PaMt81hpMPL7fmbnJeoqaXr6+tin774+/vF2t+lq6qKlI+hop38/Pz7+/v5+fn9/f29vruLjIeqq6f7+/v5+fnGxsSLjId5rcfg8vw4ibN8ud3n8vgacZ2extrA5//4+/wacp4yha8ZcZ18wuyIxuthrNc5irdvt+KRzvO62ep+w+7N6PeY1/+U1v+h2/9am7sbcp4keaXm8/ovgq07jLe+yJo8AAAAWXRSTlMAES5KZr+CMJ7X7Lr4ZwHdD4f0yftxJtP6Cj4Q/EIe9HPg/tXy/kvL/fr++fGfuf3Bzv787+6DptCRyLvRDs/u+P3O+TSw5Or8ovXiHqKWW0aBpyVHNSZMDw1FfDAAAACvSURBVHhehchTcwRBAIXRXmewtG3btm0jtn9/elPZmpqnnKd7P0DgADK5glyUQpH4b0pYkJo730t1PADxBSiKhlVvT4v11myBgSHD8Vz+cP388rr7rGlg0CIIojccrx5v7u4fjDCYMAxLWm1f33bHcuWEwXUBuT3eS58/cBuEIcQ8iURj8cT7RwqkM1n6LzabXtgUS6BcqdLO6o1mC7Q7XepZrz8YgtGYQphMZ+BfP976HHRDoNUhAAAAAElFTkSuQmCC%5D%5D%3E%3C/image%3E%0A%20%20%3Cmode%3E0%3C/mode%3E%0A%20%20%3Cinitcode%3E%3C%21%5BCDATA%5B//%20http%3A//infocatcher.ucoz.net/js/cb/undoCloseTabs.js%0A//%20https%3A//forum.mozilla-russia.org/viewtopic.php%3Fid%3D56267%0A//%20https%3A//github.com/Infocatcher/Custom_Buttons/tree/master/Undo_Close_Tabs%0A%0A//%20Undo%20Close%20Tabs%20button%20for%20Custom%20Buttons%0A//%20%28code%20for%20%22initialization%22%20section%29%0A%0A//%20%28c%29%20Infocatcher%202009-2021%0A//%20version%200.3.3.3%20-%202021-09-04%0A%0Avar%20options%20%3D%20%7B%0A%09menuTemplate%3A%20%5B%0A%09%09%22closedWindows%22%2C%0A%09%09%22separator%22%2C%0A%09%09%22restoreClosedWindows%22%2C%0A%09%09%22clearClosedWindows%22%2C%0A%09%09%22separator%22%2C%0A%09%09%22closedTabs%22%2C%0A%09%09%22separator%22%2C%0A%09%09%22restoreClosedTabs%22%2C%0A%09%09%22clearClosedTabs%22%2C%0A%09%09%22separator%22%2C%0A%09%09%22clearAll%22%2C%0A%09%09%22separator%22%2C%0A%09%09%22restoreLastSession%22%2C%0A%09%09%22separator%22%2C%0A%09%09%22buttonMenu%22%0A%09%5D%2C%0A%09showInTabContextMenu%3A%20false%2C%0A%09/*%0A%09menuTemplateTabContext%3A%20%5B%20//%20like%20menuTemplate%0A%09%09%22closedTabs%22%2C%0A%09%09%22separator%22%2C%0A%09%09%22restoreClosedTabs%22%2C%0A%09%09%22clearClosedTabs%22%0A%09%5D%2C%0A%09*/%0A%09windowItemTemplate%3A%20%22%28%25count%29%20%25title%22%2C%0A%09windowSelectedTabPrefix%3A%20%22*%22%2C%0A%09buttonTipTemplate%3A%20%5B%22header%22%2C%20%22title%22%2C%20%22url%22%2C%20%22closedAt%22%5D%2C%0A%09itemTipTemplate%3A%20%5B%22title%22%2C%20%22url%22%2C%20%22closedAt%22%5D%2C%0A%09hideRestoreAllForSingleEntry%3A%20false%2C%0A%09allowDeleteEntries%3A%20true%2C%0A%09accesskeys%3A%20%7B%20//%20Empty%20string%20%28%22%22%29%20to%20disable%20or%20string%20with%20possible%20values%20%28%220123...%22%2C%20%22abcd...%22%29%0A%09%09closedTabs%3A%20%22%22%2C%0A%09%09closedWindows%3A%20%22%22%0A%09%7D%2C%0A%09accesskeySeparator%3A%20%22%20%22%2C%20//%20%3Caccesskey%3E%3Cseparator%3E%3Clabel%3E%0A%09openMenuOnMouseover%3A%20false%2C%0A%09useMenu%3A%20false%2C%0A%09rightClickToUndoCloseTab%3A%20false%20//%20Useful%20with%20%22useMenu%3A%20true%22%0A%7D%3B%0A%0Afunction%20_localize%28sid%29%20%7B%0A%09var%20strings%20%3D%20%7B%0A%09%09en%3A%20%7B%0A%09%09%09restoreTab%3A%20%22Restore%20the%20most%20recently%20closed%20tab%22%2C%0A%0A%09%09%09restoreAllTabs%3A%20%22Restore%20all%20tabs%22%2C%0A%09%09%09restoreAllTabsAccesskey%3A%20%22t%22%2C%0A%09%09%09clearTabsHistory%3A%20%22Clear%20history%20of%20closed%20tabs%22%2C%0A%09%09%09clearTabsHistoryAccesskey%3A%20%22b%22%2C%0A%0A%09%09%09restoreAllWindows%3A%20%22Restore%20all%20windows%22%2C%0A%09%09%09restoreAllWindowsAccesskey%3A%20%22w%22%2C%0A%09%09%09clearWindowsHistory%3A%20%22Clear%20history%20of%20closed%20windows%22%2C%0A%09%09%09clearWindowsHistoryAccesskey%3A%20%22d%22%2C%0A%0A%09%09%09clearAllHistory%3A%20%22Clear%20all%20history%22%2C%0A%09%09%09clearAllHistoryAccesskey%3A%20%22C%22%2C%0A%0A%09%09%09restoreLastSession%3A%20%22Restore%20last%20session%22%2C%0A%09%09%09restoreLastSessionAccesskey%3A%20%22s%22%2C%0A%0A%09%09%09deleteUndoEntry%3A%20%22Delete%22%2C%0A%0A%09%09%09buttonMenu%3A%20%22Button%20menu%22%2C%0A%09%09%09buttonMenuAccesskey%3A%20%22m%22%2C%0A%0A%09%09%09tabContextMenu%3A%20%22Recently%20Closed%20Tabs%22%2C%0A%09%09%09tabContextMenuAccesskey%3A%20%22y%22%2C%0A%0A%09%09%09itemTip%3A%20%22%25ago%20ago%2C%20%25date%22%2C%0A%09%09%09day%3A%20%22d%22%0A%09%09%7D%2C%0A%09%09ru%3A%20%7B%0A%09%09%09restoreTab%3A%20%22%u0412%u043E%u0441%u0441%u0442%u0430%u043D%u043E%u0432%u0438%u0442%u044C%20%u043F%u043E%u0441%u043B%u0435%u0434%u043D%u044E%u044E%20%u0437%u0430%u043A%u0440%u044B%u0442%u0443%u044E%20%u0432%u043A%u043B%u0430%u0434%u043A%u0443%22%2C%0A%0A%09%09%09restoreAllTabs%3A%20%22%u0412%u043E%u0441%u0441%u0442%u0430%u043D%u043E%u0432%u0438%u0442%u044C%20%u0432%u0441%u0435%20%u0432%u043A%u043B%u0430%u0434%u043A%u0438%22%2C%0A%09%09%09restoreAllTabsAccesskey%3A%20%22%u043B%22%2C%0A%09%09%09clearTabsHistory%3A%20%22%u041E%u0447%u0438%u0441%u0442%u0438%u0442%u044C%20%u0438%u0441%u0442%u043E%u0440%u0438%u044E%20%u0437%u0430%u043A%u0440%u044B%u0442%u044B%u0445%20%u0432%u043A%u043B%u0430%u0434%u043E%u043A%22%2C%0A%09%09%09clearTabsHistoryAccesskey%3A%20%22%u0434%22%2C%0A%0A%09%09%09restoreAllWindows%3A%20%22%u0412%u043E%u0441%u0441%u0442%u0430%u043D%u043E%u0432%u0438%u0442%u044C%20%u0432%u0441%u0435%20%u043E%u043A%u043D%u0430%22%2C%0A%09%09%09restoreAllWindowsAccesskey%3A%20%22%u043E%22%2C%0A%09%09%09clearWindowsHistory%3A%20%22%u041E%u0447%u0438%u0441%u0442%u0438%u0442%u044C%20%u0438%u0441%u0442%u043E%u0440%u0438%u044E%20%u0437%u0430%u043A%u0440%u044B%u0442%u044B%u0445%20%u043E%u043A%u043E%u043D%22%2C%0A%09%09%09clearWindowsHistoryAccesskey%3A%20%22%u043D%22%2C%0A%0A%09%09%09clearAllHistory%3A%20%22%u041E%u0447%u0438%u0441%u0442%u0438%u0442%u044C%20%u0432%u0441%u044E%20%u0438%u0441%u0442%u043E%u0440%u0438%u044E%22%2C%0A%09%09%09clearAllHistoryAccesskey%3A%20%22%u0447%22%2C%0A%0A%09%09%09restoreLastSession%3A%20%22%u0412%u043E%u0441%u0441%u0442%u0430%u043D%u043E%u0432%u0438%u0442%u044C%20%u043F%u043E%u0441%u043B%u0435%u0434%u043D%u044E%u044E%20%u0441%u0435%u0441%u0441%u0438%u044E%22%2C%0A%09%09%09restoreLastSessionAccesskey%3A%20%22%u0441%22%2C%0A%0A%09%09%09deleteUndoEntry%3A%20%22%u0423%u0434%u0430%u043B%u0438%u0442%u044C%22%2C%0A%0A%09%09%09buttonMenu%3A%20%22%u041C%u0435%u043D%u044E%20%u043A%u043D%u043E%u043F%u043A%u0438%22%2C%0A%09%09%09buttonMenuAccesskey%3A%20%22%u041C%22%2C%0A%0A%09%09%09tabContextMenu%3A%20%22%u041D%u0435%u0434%u0430%u0432%u043D%u043E%20%u0437%u0430%u043A%u0440%u044B%u0442%u044B%u0435%20%u0432%u043A%u043B%u0430%u0434%u043A%u0438%22%2C%0A%09%09%09tabContextMenuAccesskey%3A%20%22%u043E%22%2C%0A%0A%09%09%09itemTip%3A%20%22%25ago%20%u043D%u0430%u0437%u0430%u0434%2C%20%25date%22%2C%0A%09%09%09day%3A%20%22%u0434%22%0A%09%09%7D%0A%09%7D%3B%0A%09var%20locale%20%3D%20%28function%28%29%20%7B%0A%09%09if%28%22Services%22%20in%20window%20%26%26%20%22locale%22%20in%20Services%29%20%7B%0A%09%09%09var%20locales%20%3D%20Services.locale.requestedLocales%20//%20Firefox%2064+%0A%09%09%09%09%7C%7C%20Services.locale.getRequestedLocales%20%26%26%20Services.locale.getRequestedLocales%28%29%3B%0A%09%09%09if%28locales%29%0A%09%09%09%09return%20locales%5B0%5D%3B%0A%09%09%7D%0A%09%09var%20prefs%20%3D%20%22Services%22%20in%20window%20%26%26%20Services.prefs%0A%09%09%09%7C%7C%20Components.classes%5B%22@mozilla.org/preferences-service%3B1%22%5D%0A%09%09%09%09.getService%28Components.interfaces.nsIPrefBranch%29%3B%0A%09%09function%20pref%28name%2C%20type%29%20%7B%0A%09%09%09return%20prefs.getPrefType%28name%29%20%21%3D%20prefs.PREF_INVALID%20%3F%20prefs%5B%22get%22%20+%20type%20+%20%22Pref%22%5D%28name%29%20%3A%20undefined%3B%0A%09%09%7D%0A%09%09if%28%21pref%28%22intl.locale.matchOS%22%2C%20%22Bool%22%29%29%20%7B%20//%20Also%20see%20https%3A//bugzilla.mozilla.org/show_bug.cgi%3Fid%3D1414390%0A%09%09%09var%20locale%20%3D%20pref%28%22general.useragent.locale%22%2C%20%22Char%22%29%3B%0A%09%09%09if%28locale%20%26%26%20locale.substr%280%2C%209%29%20%21%3D%20%22chrome%3A//%22%29%0A%09%09%09%09return%20locale%3B%0A%09%09%7D%0A%09%09return%20Components.classes%5B%22@mozilla.org/chrome/chrome-registry%3B1%22%5D%0A%09%09%09.getService%28Components.interfaces.nsIXULChromeRegistry%29%0A%09%09%09.getSelectedLocale%28%22global%22%29%3B%0A%09%7D%29%28%29.match%28/%5E%5Ba-z%5D*/%29%5B0%5D%3B%0A%09_localize%20%3D%20function%28sid%29%20%7B%0A%09%09return%20strings%5Blocale%5D%20%26%26%20strings%5Blocale%5D%5Bsid%5D%20%7C%7C%20strings.en%5Bsid%5D%20%7C%7C%20sid%3B%0A%09%7D%3B%0A%09return%20_localize.apply%28this%2C%20arguments%29%3B%0A%7D%0A%0Avar%20JSON%20%3D%20%22JSON%22%20in%20window%0A%09%3F%20%7B%0A%09%09parse%3A%20function%28arg%29%20%7B%0A%09%09%09return%20typeof%20arg%20%3D%3D%20%22string%22%0A%09%09%09%09%3F%20%28JSON%20%3D%20window.JSON%29.parse%28arg%29%0A%09%09%09%09%3A%20%28this.parse%20%3D%20function%28obj%29%20%7B%0A%09%09%09%09%09return%20obj%3B%0A%09%09%09%09%7D%29%20%26%26%20arg%3B%0A%09%09%7D%0A%09%7D%0A%09%3A%20%22nsIJSON%22%20in%20Components.interfaces%0A%09%09%3F%20%7B%0A%09%09%09parse%3A%20function%28s%29%20%7B%0A%09%09%09%09return%20Components.classes%5B%22@mozilla.org/dom/json%3B1%22%5D%0A%09%09%09%09%09.createInstance%28Components.interfaces.nsIJSON%29%0A%09%09%09%09%09.decode%28s%29%3B%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%3A%20%7B%0A%09%09%09parse%3A%20function%28s%29%20%7B%0A%09%09%09%09return%20Components.utils.evalInSandbox%28%22%28%22%20+%20s%20+%20%22%29%22%2C%20new%20Components.utils.Sandbox%28%22about%3Ablank%22%29%29%3B%0A%09%09%09%7D%0A%09%09%7D%3B%0A%0Athis.onclick%20%3D%20function%28e%29%20%7B%0A%09if%28e.target%20%21%3D%20this%29%0A%09%09return%3B%0A%09if%28e.button%20%3D%3D%201%20%7C%7C%20e.button%20%3D%3D%200%20%26%26%20%28e.ctrlKey%20%7C%7C%20e.shiftKey%20%7C%7C%20e.altKey%20%7C%7C%20e.metaKey%29%29%0A%09%09this.undoCloseTabsList.clearAllLists%28%29%3B%0A%09else%20if%28%0A%09%09e.button%20%3D%3D%200%0A%09%09%7C%7C%20e.button%20%3D%3D%202%20%26%26%20%21e.ctrlKey%20%26%26%20%21e.shiftKey%20%26%26%20%21e.altKey%20%26%26%20%21e.metaKey%0A%09%09%09%26%26%20this.undoCloseTabsList.options.rightClickToUndoCloseTab%0A%09%29%20%7B%0A%09%09if%28%0A%09%09%09e.button%20%3D%3D%200%20%26%26%20%21this.undoCloseTabsList.options.useMenu%0A%09%09%09%7C%7C%20e.button%20%3D%3D%202%20%26%26%20this.undoCloseTabsList.options.rightClickToUndoCloseTab%0A%09%09%29%20%7B%0A%09%09%09if%28this.undoCloseTabsList.closedTabCount%29%0A%09%09%09%09this.undoCloseTabsList.undoCloseTab%28%29%3B%0A%09%09%09else%0A%09%09%09%09this.undoCloseTabsList.drawUndoList%28%29%20%26%26%20this.undoCloseTabsList.showMenu%28e%29%3B%0A%09%09%7D%0A%09%09//%20Allow%20use%20%22command%22%20section%20only%20from%20hotkey%3A%0A%09%09e.preventDefault%28%29%3B%0A%09%09e.stopPropagation%28%29%3B%0A%09%7D%0A%7D%3B%0Aif%28%21this.hasOwnProperty%28%22defaultContextId%22%29%29%0A%09this.defaultContextId%20%3D%20this.getAttribute%28%22context%22%29%20%7C%7C%20%22custombuttons-contextpopup%22%3B%0Athis.onmousedown%20%3D%20function%28e%29%20%7B%0A%09if%28e.target%20%21%3D%20this%29%0A%09%09return%3B%0A%09if%28this.undoCloseTabsList.options.useMenu%29%20%7B%0A%09%09if%28e.button%20%3D%3D%200%29%0A%09%09%09this.undoCloseTabsList.drawUndoList%28%29%3B%0A%09%7D%0A%09else%20if%28e.button%20%3D%3D%202%29%20%7B%0A%09%09var%20showCbMenu%20%3D%20e.ctrlKey%20%7C%7C%20e.shiftKey%20%7C%7C%20e.altKey%20%7C%7C%20e.metaKey%20%7C%7C%20%21this.undoCloseTabsList.drawUndoList%28%29%3B%0A%09%09this.setAttribute%28%0A%09%09%09%22context%22%2C%0A%09%09%09showCbMenu%0A%09%09%09%09%3F%20this.defaultContextId%0A%09%09%09%09%3A%20this.undoCloseTabsList.mpId%0A%09%09%29%3B%0A%09%7D%0A%7D%3B%0Athis.onmouseover%20%3D%20function%28e%29%20%7B%0A%09if%28e.target%20%21%3D%20this%29%0A%09%09return%3B%0A%09if%28%21this.disabled%29%0A%09%09this.undoCloseTabsList.updUI%28%29%3B%0A%09this.undoCloseTabsList.options.useMenu%20%26%26%20Array.prototype.some.call%28%0A%09%09this.parentNode.getElementsByTagName%28%22*%22%29%2C%0A%09%09function%28node%29%20%7B%0A%09%09%09if%28%0A%09%09%09%09node%20%21%3D%20this%0A%09%09%09%09%26%26%20node.namespaceURI%20%3D%3D%20xulns%0A%09%09%09%09//%20See%20https%3A//github.com/Infocatcher/Custom_Buttons/issues/28%0A%09%09%09%09//%26%26%20node.boxObject%0A%09%09%09%09//%26%26%20node.boxObject%20instanceof%20Components.interfaces.nsIMenuBoxObject%0A%09%09%09%09%26%26%20%22open%22%20in%20node%0A%09%09%09%09%26%26%20node.open%0A%09%09%09%09%26%26%20node.getElementsByTagName%28%22menupopup%22%29.length%0A%09%09%09%09%26%26%20this.undoCloseTabsList.drawUndoList%28%29%0A%09%09%09%29%20%7B%0A%09%09%09%09node.open%20%3D%20false%3B%0A%09%09%09%09this.open%20%3D%20true%3B%0A%09%09%09%09return%20true%3B%0A%09%09%09%7D%0A%09%09%09return%20false%3B%0A%09%09%7D%2C%0A%09%09this%0A%09%29%3B%0A%09if%28%0A%09%09this.undoCloseTabsList.options.openMenuOnMouseover%0A%09%09%26%26%20this.undoCloseTabsList.drawUndoList%28%29%0A%09%29%0A%09%09this.undoCloseTabsList.openMenu%28%29%3B%0A%7D%3B%0A%0Athis.undoCloseTabsList%20%3D%20%7B%0A%09button%3A%20this%2C%0A%09options%3A%20options%2C%0A%09mpId%3A%20this.id%20+%20%22-context%22%2C%0A%09cmId%3A%20this.id%20+%20%22-contextSub%22%2C%0A%09tcmId%3A%20this.id%20+%20%22-tabContextMenu%22%2C%0A%09tipId%3A%20this.id%20+%20%22-tooltip%22%2C%0A%09errPrefix%3A%20%22%5BCustom%20Buttons%20%3A%3A%20Undo%20Close%20Tabs%20List%5D%3A%20%22%2C%0A%09get%20mp%28%29%20%7B%0A%09%09var%20btn%20%3D%20this.button%3B%0A%09%09var%20mp%20%3D%20btn.getElementsByTagName%28%22menupopup%22%29%3B%0A%09%09mp%20%3D%20mp.length%20%26%26%20mp%5B0%5D%3B%0A%09%09mp%20%26%26%20mp.parentNode.removeChild%28mp%29%3B%0A%09%09mp%20%3D%20this.createElement%28%22menupopup%22%2C%20%7B%0A%09%09%09id%3A%20this.mpId%2C%0A%09%09%09onclick%3A%20%22this.parentNode.undoCloseTabsList.checkForMiddleClick%28event%29%3B%22%2C%0A%09%09%09onpopupshowing%3A%20%22if%28event.target%20%3D%3D%20this%29%20document.popupNode%20%3D%20this.parentNode%3B%22%2C%0A%09%09%09onpopuphidden%3A%20%22if%28event.target%20%3D%3D%20this%29%20document.popupNode%20%3D%20null%3B%22%0A%09%09%7D%29%3B%0A%09%09if%28this.cm%29%0A%09%09%09mp.setAttribute%28%22context%22%2C%20this.cmId%29%3B%0A%09%09var%20tb%20%3D%20btn.parentNode%3B%0A%09%09if%28%0A%09%09%09this.options.useMenu%0A%09%09%09%26%26%20tb.getAttribute%28%22orient%22%29%20%3D%3D%20%22vertical%22%0A%09%09%29%20%7B%0A%09%09%09//%20https%3A//addons.mozilla.org/firefox/addon/vertical-toolbar/%0A%09%09%09var%20isRight%20%3D%20tb.parentNode.getAttribute%28%22placement%22%29%20%3D%3D%20%22right%22%3B%0A%09%09%09mp.setAttribute%28%22position%22%2C%20isRight%20%3F%20%22start_before%22%20%3A%20%22end_before%22%29%3B%0A%09%09%7D%0A%09%09delete%20this.mp%3B%0A%09%09return%20this.mp%20%3D%20btn.appendChild%28mp%29%3B%0A%09%7D%2C%0A%09get%20useCentextMenu%28%29%20%7B%0A%09%09delete%20this.useCentextMenu%3B%0A%09%09return%20this.useCentextMenu%20%3D%20this.options.allowDeleteEntries%0A%09%09%09%26%26%20%28%22forgetClosedTab%22%20in%20this.ss%20%7C%7C%20%22forgetClosedWindow%22%20in%20this.ss%29%3B%0A%09%7D%2C%0A%09get%20cm%28%29%20%7B%0A%09%09delete%20this.cm%3B%0A%09%09if%28%21this.useCentextMenu%29%0A%09%09%09return%20this.cm%20%3D%20null%3B%0A%09%09var%20cm%20%3D%20document.getElementById%28this.cmId%29%3B%0A%09%09cm%20%26%26%20cm.parentNode.removeChild%28cm%29%3B%0A%09%09cm%20%3D%20this.createElement%28%22menupopup%22%2C%20%7B%0A%09%09%09id%3A%20this.cmId%2C%0A%09%09%09onpopupshowing%3A%20%22return%20this.undoCloseTabsList.canDeleteUndoEntry%28this.triggerNode%20%7C%7C%20document.popupNode%29%3B%22%0A%09%09%7D%29%3B%0A%09%09var%20mi%20%3D%20this.createElement%28%22menuitem%22%2C%20%7B%0A%09%09%09oncommand%3A%20%22this.parentNode.undoCloseTabsList.deleteUndoEntry%28this.parentNode.triggerNode%20%7C%7C%20document.popupNode%29%3B%22%2C%0A%09%09%09label%3A%20_localize%28%22deleteUndoEntry%22%29%2C%0A%09%09%09closemenu%3A%20%22single%22%0A%09%09%7D%29%3B%0A%09%09cm.appendChild%28mi%29%3B%0A%09%09cm.undoCloseTabsList%20%3D%20this%3B%0A%09%09return%20this.cm%20%3D%20document.getElementById%28%22mainPopupSet%22%29.appendChild%28cm%29%3B%0A%09%7D%2C%0A%09get%20cbMenu%28%29%20%7B%0A%09%09var%20cbPopup%20%3D%20document.getElementById%28this.button.defaultContextId%29%3B%0A%09%09if%28%21cbPopup%29%20%7B%0A%09%09%09Components.utils.reportError%28this.errPrefix%20+%20%22cb%20menu%20not%20found%22%29%3B%0A%09%09%09return%20this.cbMenu%20%3D%20null%3B%0A%09%09%7D%0A%09%09cbPopup%20%3D%20cbPopup.cloneNode%28true%29%3B%0A%09%09var%20id%20%3D%20%22-%22%20+%20this.button.id.match%28/%5Cd*%24/%29%5B0%5D%20+%20%22-cloned%22%3B%0A%09%09cbPopup.id%20+%3D%20id%3B%0A%09%09Array.prototype.slice.call%28cbPopup.getElementsByAttribute%28%22id%22%2C%20%22*%22%29%29.forEach%28function%28node%29%20%7B%0A%09%09%09node.id%20+%3D%20id%3B%0A%09%09%7D%29%3B%0A%09%09var%20menu%20%3D%20this.createElement%28%22menu%22%2C%20%7B%0A%09%09%09label%3A%20_localize%28%22buttonMenu%22%29%2C%0A%09%09%09accesskey%3A%20_localize%28%22buttonMenuAccesskey%22%29%0A%09%09%7D%29%3B%0A%09%09menu.appendChild%28cbPopup%29%3B%0A%09%09cbPopup.setAttribute%28%0A%09%09%09%22onpopupshowing%22%2C%0A%09%09%09%27%5C%0A%09%09%09var%20btn%20%3D%20document.popupNode%20%3D%20this.parentNode.parentNode.parentNode%5Cn%5C%0A%09%09%09%09.undoCloseTabsList.button%3B%5Cn%5C%0A%09%09%09custombutton.setContextMenuVisibility%28btn%29%3B%27%0A%09%09%29%3B%0A%09%09delete%20this.cbMenu%3B%0A%09%09return%20this.cbMenu%20%3D%20menu%3B%0A%09%7D%2C%0A%09get%20ss%28%29%20%7B%0A%09%09delete%20this.ss%3B%0A%09%09return%20this.ss%20%3D%20%22nsISessionStore%22%20in%20Components.interfaces%0A%09%09%09%3F%20%28%0A%09%09%09%09Components.classes%5B%22@mozilla.org/browser/sessionstore%3B1%22%5D%0A%09%09%09%09%7C%7C%20Components.classes%5B%22@mozilla.org/suite/sessionstore%3B1%22%5D%0A%09%09%09%29.getService%28Components.interfaces.nsISessionStore%29%0A%09%09%09%3A%20SessionStore%3B%20//%20Firefox%2061+%20https%3A//bugzilla.mozilla.org/show_bug.cgi%3Fid%3D1450559%0A%09%7D%2C%0A%09get%20appInfo%28%29%20%7B%0A%09%09delete%20this.appInfo%3B%0A%09%09return%20this.appInfo%20%3D%20Components.classes%5B%22@mozilla.org/xre/app-info%3B1%22%5D%0A%09%09%09.getService%28Components.interfaces.nsIXULAppInfo%29%3B%0A%09%7D%2C%0A%09get%20appVersion%28%29%20%7B%0A%09%09delete%20this.appVersion%3B%0A%09%09return%20this.appVersion%20%3D%20parseFloat%28this.appInfo.version%29%3B%0A%09%7D%2C%0A%09get%20platformVersion%28%29%20%7B%0A%09%09delete%20this.platformVersion%3B%0A%09%09return%20this.platformVersion%20%3D%20parseFloat%28this.appInfo.platformVersion%29%3B%0A%09%7D%2C%0A%09get%20appName%28%29%20%7B%0A%09%09delete%20this.appName%3B%0A%09%09return%20this.appName%20%3D%20this.appInfo.name%3B%0A%09%7D%2C%0A%0A%09init%3A%20function%28%29%20%7B%0A%09%09window.addEventListener%28%22TabClose%22%2C%20%20%20%20%20%20%20this%2C%20false%29%3B%0A%09%09window.addEventListener%28%22SSTabRestoring%22%2C%20this%2C%20false%29%3B%0A%09%09window.addEventListener%28%22unload%22%2C%20%20%20%20%20%20%20%20%20this%2C%20false%29%3B%0A%09%09if%28this.appName%20%3D%3D%20%22SeaMonkey%22%29%20//%20No%20SSTab*%20events%20in%20SeaMonkey%0A%09%09%09window.addEventListener%28%22TabOpen%22%2C%20this%2C%20false%29%3B%0A%09%09setTimeout%28function%28_this%29%20%7B%0A%09%09%09_this.mp.addEventListener%28%22DOMMenuItemActive%22%2C%20%20%20_this%2C%20false%29%3B%0A%09%09%09_this.mp.addEventListener%28%22DOMMenuItemInactive%22%2C%20_this%2C%20false%29%3B%0A%09%09%09_this.initTooltip%28%29%3B%0A%09%09%7D%2C%2050%2C%20this%29%3B%0A%09%09this.addPbExitObserver%28true%29%3B%0A%09%09this.updUIGlobal%28%29%3B%0A%09%09if%28this.options.showInTabContextMenu%29%20setTimeout%28function%28_this%29%20%7B%0A%09%09%09_this.initTabContext%28%29%3B%0A%09%09%7D%2C%20100%2C%20this%29%3B%0A%09%7D%2C%0A%09initTabContext%3A%20function%28%29%20%7B%0A%09%09var%20origMi%20%3D%20this.tabContextUndoClose%3B%0A%09%09if%28%21origMi%29%20%7B%0A%09%09%09LOG%28%22Can%27t%20find%20%5C%22Undo%20Close%20Tab%5C%22%20item%20in%20tab%20context%20menu%22%29%3B%0A%09%09%09return%3B%0A%09%09%7D%0A%09%09var%20menu%20%3D%20document.getElementById%28this.tcmId%29%3B%0A%09%09menu%20%26%26%20menu.parentNode.removeChild%28menu%29%3B%20//%20For%20SeaMonkey%0A%09%09menu%20%3D%20this.createElement%28%22menu%22%2C%20%7B%0A%09%09%09id%3A%20this.tcmId%2C%0A%09%09%09label%3A%20_localize%28%22tabContextMenu%22%29%2C%0A%09%09%09accesskey%3A%20_localize%28%22tabContextMenuAccesskey%22%29%2C%0A%09%09%09tooltip%3A%20this.tipId%2C%0A%09%09%09popupsinherittooltip%3A%20%22true%22%0A%09%09%7D%29%3B%0A%09%09menu.undoCloseTabsList%20%3D%20this%3B%0A%09%09menu.onclick%20%3D%20function%28e%29%20%7B%0A%09%09%09if%28e.target%20%21%3D%20this%29%0A%09%09%09%09return%3B%0A%09%09%09if%28e.button%20%3D%3D%201%20%7C%7C%20e.button%20%3D%3D%200%20%26%26%20%28e.ctrlKey%20%7C%7C%20e.shiftKey%20%7C%7C%20e.altKey%20%7C%7C%20e.metaKey%29%29%20%7B%0A%09%09%09%09if%28this.undoCloseTabsList.closedTabCount%29%20%7B%0A%09%09%09%09%09this.undoCloseTabsList.undoCloseTab%28%29%3B%0A%09%09%09%09%09closeMenus%28this%29%3B%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%3B%0A%09%09var%20origMp%20%3D%20this.mp%3B%0A%09%09var%20mp%20%3D%20origMp.cloneNode%28true%29%3B%0A%09%09mp.id%20%3D%20this.button.id%20+%20%22-tabContext%22%3B%0A%09%09var%20_this%20%3D%20this%3B%0A%09%09function%20drawUndoList%28%29%20%7B%0A%09%09%09var%20ok%20%3D%20false%3B%0A%09%09%09var%20opts%20%3D%20_this.options%3B%0A%09%09%09var%20origTemplate%20%3D%20opts.menuTemplate%3B%0A%09%09%09opts.menuTemplate%20%3D%20opts.menuTemplateTabContext%20%7C%7C%20origTemplate%3B%0A%09%09%09_this.mp%20%3D%20mp%3B%0A%09%09%09try%20%7B%0A%09%09%09%09ok%20%3D%20_this.drawUndoList%28%29%3B%0A%09%09%09%7D%0A%09%09%09catch%28e%29%20%7B%0A%09%09%09%09Components.utils.reportError%28e%29%3B%0A%09%09%09%7D%0A%09%09%09opts.menuTemplate%20%3D%20origTemplate%3B%0A%09%09%09_this.mp%20%3D%20origMp%3B%0A%09%09%09return%20ok%3B%0A%09%09%7D%0A%09%09function%20updMenu%28%29%20%7B%0A%09%09%09if%28drawUndoList%28%29%29%0A%09%09%09%09menu.removeAttribute%28%22disabled%22%29%3B%0A%09%09%09else%0A%09%09%09%09menu.setAttribute%28%22disabled%22%2C%20%22true%22%29%3B%0A%09%09%7D%0A%09%09mp._updatePopup%20%3D%20function%28e%29%20%7B%0A%09%09%09if%28e.target%20%21%3D%20this%29%0A%09%09%09%09return%3B%0A%09%09%09document.popupNode%20%3D%20_this.button%3B%0A%09%09%09drawUndoList%28%29%3B%0A%09%09%7D%3B%0A%09%09mp.setAttribute%28%22onpopupshowing%22%2C%20%22this._updatePopup%28event%29%3B%22%29%3B%0A%09%09mp.onclick%20%3D%20function%28e%29%20%7B%0A%09%09%09_this.checkForMiddleClick%28e%2C%20updMenu%29%3B%0A%09%09%7D%3B%0A%09%09menu.appendChild%28mp%29%3B%0A%09%09addEventListener%28%22popupshown%22%2C%20function%28e%29%20%7B%0A%09%09%09if%28e.target%20%3D%3D%20e.currentTarget%29%0A%09%09%09%09setTimeout%28updMenu%2C%200%29%3B%20//%20Pseudo%20async%0A%09%09%7D%2C%20false%2C%20origMi.parentNode%29%3B%0A%09%09addEventListener%28%22DOMMenuItemActive%22%2C%20%20%20this%2C%20false%2C%20mp%29%3B%0A%09%09addEventListener%28%22DOMMenuItemInactive%22%2C%20this%2C%20false%2C%20mp%29%3B%0A%09%09origMi.parentNode.insertBefore%28menu%2C%20origMi.nextSibling%29%3B%0A%09%09origMi.setAttribute%28%22hidden%22%2C%20%22true%22%29%3B%0A%09%7D%2C%0A%09initTooltip%3A%20function%28%29%20%7B%0A%09%09var%20tip%20%3D%20document.getElementById%28this.tipId%29%3B%0A%09%09tip%20%26%26%20tip.parentNode.removeChild%28tip%29%3B%0A%09%09tip%20%3D%20this.tip%20%3D%20this.createElement%28%22tooltip%22%2C%20%7B%0A%09%09%09id%3A%20this.tipId%2C%0A%09%09%09orient%3A%20%22vertical%22%2C%0A%09%09%09onpopupshowing%3A%20%22return%20this.undoCloseTabsList.updTooltip%28this%2C%20this.triggerNode%20%7C%7C%20document.tooltipNode%29%3B%22%2C%0A%09%09%09onpopuphiding%3A%20%22this.cancelUpdateTimer%28%29%3B%22%0A%09%09%7D%29%3B%0A%09%09tip.undoCloseTabsList%20%3D%20this%3B%0A%09%09tip._updateTimer%20%3D%200%3B%0A%09%09tip.initUpdateTimer%20%3D%20function%28fn%2C%20context%29%20%7B%0A%09%09%09if%28this._updateTimer%29%0A%09%09%09%09clearInterval%28this._updateTimer%29%3B%0A%09%09%09this._updateTimer%20%3D%20setInterval%28function%28%29%20%7B%0A%09%09%09%09fn.call%28context%29%3B%0A%09%09%09%7D%2C%201000%29%3B%0A%09%09%7D%3B%0A%09%09tip.cancelUpdateTimer%20%3D%20function%28%29%20%7B%0A%09%09%09if%28this._updateTimer%29%20%7B%0A%09%09%09%09clearInterval%28this._updateTimer%29%3B%0A%09%09%09%09this._updateTimer%20%3D%200%3B%0A%09%09%09%7D%0A%09%09%7D%3B%0A%09%09var%20btn%20%3D%20this.button%3B%0A%09%09btn.removeAttribute%28%22tooltiptext%22%29%3B%0A%09%09btn.setAttribute%28%22tooltip%22%2C%20this.tipId%29%3B%0A%09%09btn.setAttribute%28%22popupsinherittooltip%22%2C%20%22true%22%29%3B%0A%09%09document.getElementById%28%22mainPopupSet%22%29.appendChild%28tip%29%3B%0A%09%09if%28this.appVersion%20%3E%3D%2061%20%26%26%20%22getAnonymousElementByAttribute%22%20in%20document%29%20%7B%0A%09%09%09var%20label%20%3D%20document.getAnonymousElementByAttribute%28tip%2C%20%22class%22%2C%20%22tooltip-label%22%29%3B%0A%09%09%09label%20%26%26%20label.remove%28%29%3B%0A%09%09%7D%0A%09%7D%2C%0A%09_hasPbExitObserver%3A%20false%2C%0A%09addPbExitObserver%3A%20function%28add%29%20%7B%0A%09%09if%28add%20%3D%3D%20this._hasPbExitObserver%20%7C%7C%20%21%28%22Services%22%20in%20window%29%29%0A%09%09%09return%3B%0A%09%09this._hasPbExitObserver%20%3D%20add%3B%0A%09%09if%28add%29%0A%09%09%09Services.obs.addObserver%28this%2C%20%22last-pb-context-exited%22%2C%20false%29%3B%0A%09%09else%0A%09%09%09Services.obs.removeObserver%28this%2C%20%22last-pb-context-exited%22%29%3B%0A%09%7D%2C%0A%09destroy%3A%20function%28%29%20%7B%0A%09%09window.removeEventListener%28%22TabClose%22%2C%20%20%20%20%20%20%20this%2C%20false%29%3B%0A%09%09window.removeEventListener%28%22SSTabRestoring%22%2C%20this%2C%20false%29%3B%0A%09%09window.removeEventListener%28%22unload%22%2C%20%20%20%20%20%20%20%20%20this%2C%20false%29%3B%0A%09%09if%28this.appName%20%3D%3D%20%22SeaMonkey%22%29%0A%09%09%09window.removeEventListener%28%22TabOpen%22%2C%20this%2C%20false%29%3B%0A%09%09this.mp.removeEventListener%28%22DOMMenuItemActive%22%2C%20%20%20this%2C%20false%29%3B%0A%09%09this.mp.removeEventListener%28%22DOMMenuItemInactive%22%2C%20this%2C%20false%29%3B%0A%09%09this.addPbExitObserver%28false%29%3B%0A%09%09var%20menu%20%3D%20document.getElementById%28this.tcmId%29%3B%0A%09%09if%28menu%29%20%7B%0A%09%09%09menu.parentNode.removeChild%28menu%29%3B%0A%09%09%09this.tabContextUndoClose.removeAttribute%28%22hidden%22%29%3B%0A%09%09%7D%0A%09%09var%20tip%20%3D%20this.tip%3B%0A%09%09tip%20%26%26%20tip.parentNode%20%26%26%20tip.parentNode.removeChild%28tip%29%3B%0A%09%7D%2C%0A%09handleEvent%3A%20function%28e%29%20%7B%0A%09%09switch%28e.type%29%20%7B%0A%09%09%09case%20%22TabClose%22%3A%0A%09%09%09case%20%22SSTabRestoring%22%3A%0A%09%09%09case%20%22TabOpen%22%3A%0A%09%09%09%09setTimeout%28function%28_this%29%20%7B%0A%09%09%09%09%09_this.updUI%28%29%3B%0A%09%09%09%09%7D%2C%200%2C%20this%29%3B%0A%09%09%09break%3B%0A%09%09%09case%20%22DOMMenuItemActive%22%3A%0A%09%09%09case%20%22DOMMenuItemInactive%22%3A%0A%09%09%09%09if%28%21%28%22XULBrowserWindow%22%20in%20window%29%29%0A%09%09%09%09%09break%3B%0A%09%09%09%09XULBrowserWindow.setOverLink%28%0A%09%09%09%09%09e.type%20%3D%3D%20%22DOMMenuItemActive%22%0A%09%09%09%09%09%09%3F%20%28e.target.getAttribute%28%22cb_urlDecoded%22%29%20%7C%7C%20%22%22%29%0A%09%09%09%09%09%09%09.replace%28/%20%5Cn/g%2C%20%22%2C%20%22%29%0A%09%09%09%09%09%09%3A%20%22%22%2C%0A%09%09%09%09%09null%0A%09%09%09%09%29%3B%0A%09%09%09break%3B%0A%09%09%09case%20%22unload%22%3A%0A%09%09%09%09this.updUIGlobal%28%29%3B%0A%09%09%09%09this.destroy%28%29%3B%0A%09%09%7D%0A%09%7D%2C%0A%09observe%3A%20function%28subject%2C%20topic%2C%20data%29%20%7B%0A%09%09if%28topic%20%3D%3D%20%22last-pb-context-exited%22%29%20%7B%0A%09%09%09setTimeout%28function%28_this%29%20%7B%0A%09%09%09%09_this.updUI%28%29%3B%0A%09%09%09%7D%2C%2025%2C%20this%29%3B%0A%09%09%7D%0A%09%7D%2C%0A%0A%09createElement%3A%20function%28name%2C%20attrs%29%20%7B%0A%09%09var%20node%20%3D%20document.createElementNS%28xulns%2C%20name%29%3B%0A%09%09if%28attrs%29%20for%28var%20attrName%20in%20attrs%29%20if%28attrs.hasOwnProperty%28attrName%29%29%0A%09%09%09node.setAttribute%28attrName%2C%20attrs%5BattrName%5D%29%3B%0A%09%09return%20node%3B%0A%09%7D%2C%0A%09get%20tabContextUndoClose%28%29%20%7B%0A%09%09return%20document.getElementById%28%22context_undoCloseTab%22%29%0A%09%09%09%7C%7C%20document.getElementById%28%22tabContextUndoCloseTab%22%29%20//%20Firefox%202.0%0A%09%09%09%7C%7C%20document.getAnonymousElementByAttribute%28gBrowser%2C%20%22tbattr%22%2C%20%22tabbrowser-undoclosetab%22%29%3B%20//%20SeaMonkey%0A%09%7D%2C%0A%09get%20closedWindowCount%28%29%20%7B%0A%09%09if%28%21%28%22getClosedWindowCount%22%20in%20this.ss%29%29%20%7B%0A%09%09%09delete%20this.closedWindowCount%3B%0A%09%09%09return%20this.closedWindowCount%20%3D%200%3B%0A%09%09%7D%0A%09%09this.__defineGetter__%28%22closedWindowCount%22%2C%20function%28%29%20%7B%0A%09%09%09return%20this.ss.getClosedWindowCount%28%29%3B%0A%09%09%7D%29%3B%0A%09%09return%20this.closedWindowCount%3B%0A%09%7D%2C%0A%09get%20closedTabCount%28%29%20%7B%0A%09%09return%20this.ss.getClosedTabCount%28window%29%3B%0A%09%7D%2C%0A%09undoCloseTab%3A%20function%28i%29%20%7B%0A%09%09if%28%22undoCloseTab%22%20in%20window%29%20//%20Firefox%202.0+%0A%09%09%09undoCloseTab%28i%29%3B%0A%09%09else%20//%20SeaMonkey%0A%09%09%09gBrowser.undoCloseTab%28i%29%3B%0A%09%7D%2C%0A%09clearUndoTabsList%3A%20function%28%29%20%7B%0A%09%09var%20closedTabCount%20%3D%20this.closedTabCount%3B%0A%09%09if%28%21closedTabCount%29%0A%09%09%09return%3B%0A%09%09if%28%22forgetClosedTab%22%20in%20this.ss%29%20//%20Gecko%201.9.2+%0A%09%09%09while%28closedTabCount--%29%0A%09%09%09%09this.ss.forgetClosedTab%28window%2C%200%29%3B%0A%09%09else%20%7B%0A%09%09%09//%20Doesn%27t%20work%20in%20SeaMonkey%0A%09%09%09const%20pName%20%3D%20%22browser.sessionstore.max_tabs_undo%22%3B%0A%09%09%09let%20val%20%3D%20cbu.getPrefs%28pName%29%3B%0A%09%09%09cbu.setPrefs%28pName%2C%200%29%3B%0A%09%09%09cbu.setPrefs%28pName%2C%20val%29%3B%0A%09%09%7D%0A%09%09this.updUIGlobal%28%29%3B%0A%09%7D%2C%0A%09clearUndoWindowsList%3A%20function%28%29%20%7B%0A%09%09var%20closedWindowCount%20%3D%20this.closedWindowCount%3B%0A%09%09if%28%21closedWindowCount%29%0A%09%09%09return%3B%0A%09%09if%28%22forgetClosedWindow%22%20in%20this.ss%29%20//%20Gecko%201.9.2+%0A%09%09%09while%28closedWindowCount--%29%0A%09%09%09%09this.ss.forgetClosedWindow%280%29%3B%0A%09%09else%0A%09%09%09this.ss.setWindowState%28window%2C%20%27%7B%22windows%22%3A%5B%7B%7D%5D%2C%22_closedWindows%22%3A%5B%5D%7D%27%2C%20false%29%3B%0A%09%09this.updUIGlobal%28%29%3B%0A%09%7D%2C%0A%09clearAllLists%3A%20function%28%29%20%7B%0A%09%09this.clearUndoTabsList%28%29%3B%0A%09%09this.clearUndoWindowsList%28%29%3B%0A%09%7D%2C%0A%09canDeleteUndoEntry%3A%20function%28mi%29%20%7B%0A%09%09switch%28mi.getAttribute%28%22cb_type%22%29%29%20%7B%0A%09%09%09case%20%22tab%22%3A%20%20%20%20return%20%22forgetClosedTab%22%20%20%20%20in%20this.ss%3B%0A%09%09%09case%20%22window%22%3A%20return%20%22forgetClosedWindow%22%20in%20this.ss%3B%0A%09%09%7D%0A%09%09return%20false%3B%0A%09%7D%2C%0A%09deleteUndoEntry%3A%20function%28mi%29%20%7B%0A%09%09var%20i%20%3D%20+mi.getAttribute%28%22cb_index%22%29%3B%0A%09%09if%28mi.getAttribute%28%22cb_type%22%29%20%3D%3D%20%22window%22%29%20%7B%0A%09%09%09this.ss.forgetClosedWindow%28i%29%3B%0A%09%09%09this.updUIGlobal%28%29%3B%0A%09%09%7D%0A%09%09else%20%7B%0A%09%09%09this.ss.forgetClosedTab%28window%2C%20i%29%3B%0A%09%09%09this.updUI%28%29%3B%0A%09%09%7D%0A%09%09this.drawUndoList%28%29%3B%0A%09%7D%2C%0A%09showMenu%3A%20function%28e%2C%20isContext%2C%20mp%29%20%7B%0A%09%09var%20btn%20%3D%20this.button%3B%0A%09%09document.popupNode%20%3D%20btn.ownerDocument.popupNode%20%3D%20btn%3B%0A%09%09if%28%21mp%29%0A%09%09%09mp%20%3D%20this.mp%3B%0A%09%09if%28%22openPopupAtScreen%22%20in%20mp%29%0A%09%09%09mp.openPopupAtScreen%28e.screenX%2C%20e.screenY%2C%20isContext%29%3B%0A%09%09else%0A%09%09%09mp.showPopup%28btn%2C%20e.screenX%2C%20e.screenY%2C%20isContext%20%3F%20%22context%22%20%3A%20%22popup%22%2C%20null%2C%20null%29%3B%0A%09%7D%2C%0A%09openMenu%3A%20function%28%29%20%7B%0A%09%09var%20mp%20%3D%20this.mp%3B%0A%09%09if%28%22openPopup%22%20in%20mp%29%0A%09%09%09mp.openPopup%28this.button%2C%20%22after_start%22%29%3B%0A%09%09else%0A%09%09%09mp.showPopup%28this.button%2C%20-1%2C%20-1%2C%20%22popup%22%2C%20%22bottomleft%22%2C%20%22topleft%22%29%3B%0A%09%7D%2C%0A%09drawUndoList%3A%20function%28%29%20%7B%0A%09%09var%20mp%20%3D%20this.mp%3B%0A%0A%09%09var%20wc%20%3D%20this.closedWindowCount%3B%0A%09%09var%20tc%20%3D%20this.closedTabCount%3B%0A%09%09var%20ss%20%3D%20this.ss%3B%0A%09%09var%20canRestoreLastSession%20%3D%20%22restoreLastSession%22%20in%20ss%20%26%26%20ss.canRestoreLastSession%0A%09%09if%28%21wc%20%26%26%20%21tc%20%26%26%20%21canRestoreLastSession%29%20%7B%0A%09%09%09mp.textContent%20%3D%20%22%22%3B%0A%09%09%09mp.hidePopup%28%29%3B%0A%09%09%09return%20false%3B%0A%09%09%7D%0A%0A%09%09this._undoWindowItems%20%3D%20wc%20%26%26%20JSON.parse%28ss.getClosedWindowData%28%29%29%3B%0A%09%09this._undoTabItems%20%20%20%20%3D%20tc%20%26%26%20JSON.parse%28ss.getClosedTabData%28window%29%29%3B%0A%09%09var%20df%20%3D%20document.createDocumentFragment%28%29%3B%0A%0A%09%09this.options.menuTemplate.forEach%28function%28sid%2C%20indx%2C%20arr%29%20%7B%0A%09%09%09switch%28sid%29%20%7B%0A%09%09%09%09case%20%22closedWindows%22%3A%0A%09%09%09%09%09wc%20%26%26%20this.addUndoWindowsList%28df%29%3B%0A%09%09%09%09break%3B%0A%09%09%09%09case%20%22restoreClosedWindows%22%3A%0A%09%09%09%09%09wc%20%3E%20this.options.hideRestoreAllForSingleEntry%0A%09%09%09%09%09%26%26%20df.appendChild%28this.createElement%28%22menuitem%22%2C%20%7B%0A%09%09%09%09%09%09label%3A%20_localize%28%22restoreAllWindows%22%29%2C%0A%09%09%09%09%09%09accesskey%3A%20_localize%28%22restoreAllWindowsAccesskey%22%29%2C%0A%09%09%09%09%09%09oncommand%3A%20%22for%28var%20i%20%3D%200%3B%20i%20%3C%20%22%20+%20this._undoWindowItems.length%20+%20%22%3B%20++i%29%20undoCloseWindow%28%29%3B%22%0A%09%09%09%09%09%7D%29%29%3B%0A%09%09%09%09break%3B%0A%09%09%09%09case%20%22clearClosedWindows%22%3A%0A%09%09%09%09%09wc%20%26%26%20df.appendChild%28this.createElement%28%22menuitem%22%2C%20%7B%0A%09%09%09%09%09%09label%3A%20_localize%28%22clearWindowsHistory%22%29%2C%0A%09%09%09%09%09%09accesskey%3A%20_localize%28%22clearWindowsHistoryAccesskey%22%29%2C%0A%09%09%09%09%09%09oncommand%3A%20%22this.parentNode.parentNode.undoCloseTabsList.clearUndoWindowsList%28%29%3B%22%0A%09%09%09%09%09%7D%29%29%3B%0A%09%09%09%09break%3B%0A%09%09%09%09case%20%22closedTabs%22%3A%0A%09%09%09%09%09tc%20%26%26%20this.addUndoTabsList%28df%29%3B%0A%09%09%09%09break%3B%0A%09%09%09%09case%20%22restoreClosedTabs%22%3A%0A%09%09%09%09%09tc%20%3E%20this.options.hideRestoreAllForSingleEntry%0A%09%09%09%09%09%26%26%20df.appendChild%28this.createElement%28%22menuitem%22%2C%20%7B%0A%09%09%09%09%09%09label%3A%20_localize%28%22restoreAllTabs%22%29%2C%0A%09%09%09%09%09%09accesskey%3A%20_localize%28%22restoreAllTabsAccesskey%22%29%2C%0A%09%09%09%09%09%09oncommand%3A%20%22for%28var%20i%20%3D%200%3B%20i%20%3C%20%22%20+%20this._undoTabItems.length%20+%20%22%3B%20++i%29%20this.parentNode.parentNode.undoCloseTabsList.undoCloseTab%28%29%3B%22%0A%09%09%09%09%09%7D%29%29%3B%0A%09%09%09%09break%3B%0A%09%09%09%09case%20%22clearClosedTabs%22%3A%0A%09%09%09%09%09tc%20%26%26%20df.appendChild%28this.createElement%28%22menuitem%22%2C%20%7B%0A%09%09%09%09%09%09label%3A%20_localize%28%22clearTabsHistory%22%29%2C%0A%09%09%09%09%09%09accesskey%3A%20_localize%28%22clearTabsHistoryAccesskey%22%29%2C%0A%09%09%09%09%09%09oncommand%3A%20%22this.parentNode.parentNode.undoCloseTabsList.clearUndoTabsList%28%29%3B%22%0A%09%09%09%09%09%7D%29%29%3B%0A%09%09%09%09break%3B%0A%09%09%09%09case%20%22clearAll%22%3A%0A%09%09%09%09%09%28%0A%09%09%09%09%09%09wc%20%26%26%20tc%0A%09%09%09%09%09%09%7C%7C%20wc%20%26%26%20arr.indexOf%28%22clearClosedWindows%22%29%20%3D%3D%20-1%0A%09%09%09%09%09%09%7C%7C%20tc%20%26%26%20arr.indexOf%28%22clearClosedTabs%22%29%20%3D%3D%20-1%0A%09%09%09%09%09%29%0A%09%09%09%09%09%26%26%20df.appendChild%28this.createElement%28%22menuitem%22%2C%20%7B%0A%09%09%09%09%09%09label%3A%20_localize%28%22clearAllHistory%22%29%2C%0A%09%09%09%09%09%09accesskey%3A%20_localize%28%22clearAllHistoryAccesskey%22%29%2C%0A%09%09%09%09%09%09oncommand%3A%20%22this.parentNode.parentNode.undoCloseTabsList.clearAllLists%28%29%3B%22%0A%09%09%09%09%09%7D%29%29%3B%0A%09%09%09%09break%3B%0A%09%09%09%09case%20%22restoreLastSession%22%3A%20//%20Gecko%202.0+%0A%09%09%09%09%09canRestoreLastSession%20%26%26%20df.appendChild%28this.createElement%28%22menuitem%22%2C%20%7B%0A%09%09%09%09%09%09label%3A%20_localize%28%22restoreLastSession%22%29%2C%0A%09%09%09%09%09%09accesskey%3A%20_localize%28%22restoreLastSessionAccesskey%22%29%2C%0A%09%09%09%09%09%09oncommand%3A%20%22this.parentNode.parentNode.undoCloseTabsList.ss.restoreLastSession%28%29%3B%22%0A%09%09%09%09%09%7D%29%29%3B%0A%09%09%09%09break%3B%0A%09%09%09%09case%20%22buttonMenu%22%3A%0A%09%09%09%09%09let%20cbMenu%20%3D%20this.cbMenu%3B%0A%09%09%09%09%09if%28cbMenu%29%0A%09%09%09%09%09%09df.appendChild%28cbMenu%29%3B%0A%09%09%09%09break%3B%0A%09%09%09%09case%20%22separator%22%3A%0A%09%09%09%09%09if%28df.hasChildNodes%28%29%20%26%26%20df.lastChild.localName%20%21%3D%20%22menuseparator%22%29%0A%09%09%09%09%09%09df.appendChild%28document.createElementNS%28xulns%2C%20%22menuseparator%22%29%29%3B%0A%09%09%09%09break%3B%0A%09%09%09%09default%3A%0A%09%09%09%09%09Components.utils.reportError%28this.errPrefix%20+%20%27Invalid%20template%20entry%3A%20%22%27%20+%20sid%20+%20%27%22%27%29%3B%0A%09%09%09%7D%0A%09%09%7D%2C%20this%29%3B%0A%0A%09%09while%28df.hasChildNodes%28%29%20%26%26%20df.lastChild.localName%20%3D%3D%20%22menuseparator%22%29%0A%09%09%09df.removeChild%28df.lastChild%29%3B%0A%0A%09%09this._undoWindowItems%20%3D%20this._undoTabItems%20%3D%20null%3B%0A%0A%09%09mp.textContent%20%3D%20%22%22%3B%0A%09%09if%28%21df.hasChildNodes%28%29%29%20%7B%0A%09%09%09mp.hidePopup%28%29%3B%0A%09%09%09return%20false%3B%0A%09%09%7D%0A%09%09mp.appendChild%28df%29%3B%0A%09%09return%20true%3B%0A%09%7D%2C%0A%09addUndoWindowsList%3A%20function%28undoPopup%29%20%7B%0A%09%09//%20Based%20on%20code%20from%20chrome%3A//browser/content/browser.js%0A%09%09//%20Mozilla/5.0%20%28Windows%3B%20U%3B%20Windows%20NT%205.1%3B%20en-US%3B%20rv%3A1.9.3a1pre%29%20Gecko/20090824%20Minefield/3.7a1pre%0A%0A%09%09var%20keys%20%3D%20this.options.accesskeys.closedWindows%3B%0A%09%09this._undoWindowItems.forEach%28function%28undoItem%2C%20i%29%20%7B%0A%09%09%09var%20tabs%20%3D%20undoItem.tabs%3B%0A%09%09%09var%20%5Bkey%2C%20keyPrefix%5D%20%3D%20this.getKey%28keys%2C%20i%29%3B%0A%09%09%09var%20title%20%3D%20undoItem.title%3B%0A%09%09%09var%20selected%20%3D%20undoItem.selected%3B%0A%09%09%09var%20selectedTab%20%3D%20tabs%5Bselected%20%26%26%20selected%20-%201%5D%3B%0A%09%09%09var%20urls%20%3D%20%5B%5D%3B%0A%09%09%09tabs.forEach%28function%28tab%29%20%7B%0A%09%09%09%09if%28%21tab.entries%20%7C%7C%20%21tab.entries.length%29%20//%20Can%20be%20%5B%5D%20for%20about%3Ablank%0A%09%09%09%09%09return%3B%0A%09%09%09%09var%20url%20%3D%20this.convertURI%28tab.entries%5Btab.index%20-%201%5D.url%2C%20120%29%3B%0A%09%09%09%09var%20selectedPrefix%20%3D%20tab%20%3D%3D%20selectedTab%20%26%26%20tabs.length%20%3E%201%0A%09%09%09%09%09%3F%20this.options.windowSelectedTabPrefix%0A%09%09%09%09%09%3A%20%22%22%3B%0A%09%09%09%09urls.push%28selectedPrefix%20+%20url%29%3B%0A%09%09%09%7D%2C%20this%29%3B%0A%09%09%09var%20url%20%3D%20urls.join%28%22%20%5Cn%22%29%3B%0A%09%09%09var%20mi%20%3D%20this.createElement%28%22menuitem%22%2C%20%7B%0A%09%09%09%09label%3A%20keyPrefix%20+%20this.options.windowItemTemplate%0A%09%09%09%09%09.replace%28%22%25title%22%2C%20title%29%0A%09%09%09%09%09.replace%28%22%25count%22%2C%20tabs.length%29%2C%0A%09%09%09%09accesskey%3A%20key%2C%0A%09%09%09%09%22class%22%3A%20%22menuitem-iconic%20bookmark-item%20menuitem-with-favicon%22%2C%0A%09%09%09%09oncommand%3A%20%22undoCloseWindow%28%22%20+%20i%20+%20%22%29%3B%22%2C%0A%09%09%09%09cb_url%3A%20url%2C%0A%09%09%09%09cb_urlDecoded%3A%20this.convertURI%28url%29%2C%0A%09%09%09%09cb_closedAt%3A%20undoItem.closedAt%20%7C%7C%200%2C%0A%09%09%09%09cb_index%3A%20i%2C%0A%09%09%09%09cb_type%3A%20%22window%22%0A%09%09%09%7D%29%3B%0A%09%09%09if%28this.cm%29%0A%09%09%09%09mi.setAttribute%28%22context%22%2C%20this.cmId%29%3B%0A%09%09%09var%20icon%20%3D%20selectedTab.image%20%7C%7C%20selectedTab.attributes%20%26%26%20selectedTab.attributes.image%3B%0A%09%09%09if%28icon%29%0A%09%09%09%09mi.setAttribute%28%22image%22%2C%20this.cachedIcon%28icon%29%29%3B%0A%09%09%09if%28i%20%3D%3D%200%29%0A%09%09%09%09mi.setAttribute%28%22key%22%2C%20%22key_undoCloseWindow%22%29%3B%0A%09%09%09undoPopup.appendChild%28mi%29%3B%0A%09%09%7D%2C%20this%29%3B%0A%09%7D%2C%0A%09addUndoTabsList%3A%20function%28undoPopup%29%20%7B%0A%09%09//%20Based%20on%20code%20from%20chrome%3A//browser/content/browser.js%0A%09%09//%20Mozilla/5.0%20%28Windows%3B%20U%3B%20Windows%20NT%205.1%3B%20en-US%3B%20rv%3A1.9.3a1pre%29%20Gecko/20090824%20Minefield/3.7a1pre%0A%0A%09%09var%20keys%20%3D%20this.options.accesskeys.closedTabs%3B%0A%09%09this._undoTabItems.forEach%28function%28undoItem%2C%20i%29%20%7B%0A%09%09%09var%20state%20%3D%20undoItem.state%3B%0A%09%09%09var%20%5Bkey%2C%20keyPrefix%5D%20%3D%20this.getKey%28keys%2C%20i%29%3B%0A%09%09%09var%20title%20%3D%20undoItem.title%3B%0A%09%09%09var%20url%20%3D%20state%20%26%26%20state.entries%20%26%26%20state.entries%5Bstate.index%20-%201%5D.url%20%7C%7C%20%22%22%3B%0A%09%09%09var%20mi%20%3D%20this.createElement%28%22menuitem%22%2C%20%7B%0A%09%09%09%09label%3A%20keyPrefix%20+%20title%2C%0A%09%09%09%09accesskey%3A%20key%2C%0A%09%09%09%09class%3A%20%22menuitem-iconic%20bookmark-item%20menuitem-with-favicon%22%2C%0A%09%09%09%09oncommand%3A%20%22this.parentNode.parentNode.undoCloseTabsList.undoCloseTab%28%22%20+%20i%20+%20%22%29%3B%22%2C%0A%09%09%09%09cb_url%3A%20url%2C%0A%09%09%09%09cb_urlDecoded%3A%20this.convertURI%28url%29%2C%0A%09%09%09%09cb_closedAt%3A%20undoItem.closedAt%20%7C%7C%200%2C%0A%09%09%09%09cb_index%3A%20i%2C%0A%09%09%09%09cb_type%3A%20%22tab%22%0A%09%09%09%7D%29%3B%0A%09%09%09if%28%0A%09%09%09%09state%0A%09%09%09%09%26%26%20%22attributes%22%20in%20state%0A%09%09%09%09%26%26%20%22privateTab-isPrivate%22%20in%20state.attributes%0A%09%09%09%29%20//%20https%3A//addons.mozilla.org/addon/private-tab/%0A%09%09%09%09mi.setAttribute%28%22privateTab-isPrivate%22%2C%20%22true%22%29%3B%0A%09%09%09if%28this.cm%29%0A%09%09%09%09mi.setAttribute%28%22context%22%2C%20this.cmId%29%3B%0A%09%09%09var%20image%20%3D%20undoItem.image%20//%20Firefox%0A%09%09%09%09%7C%7C%20state%20%26%26%20state.attributes%20%26%26%20state.attributes.image%20//%20SeaMonkey%0A%09%09%09%09%7C%7C%20state%20%26%26%20state.xultab%0A%09%09%09%09%09%26%26%20/%28%3F%3A%5E%7C%20%29image%3D%28%5CS+%29/.test%28state.xultab%29%0A%09%09%09%09%09%26%26%20decodeURI%28RegExp.%241%29%3B%20//%20Only%20Firefox%202.0%20%3F%0A%09%09%09if%28image%29%0A%09%09%09%09mi.setAttribute%28%22image%22%2C%20this.cachedIcon%28image%29%29%3B%0A%09%09%09if%28i%20%3D%3D%200%29%0A%09%09%09%09mi.setAttribute%28%22key%22%2C%20%22key_undoCloseTab%22%29%3B%0A%09%09%09undoPopup.appendChild%28mi%29%3B%0A%09%09%7D%2C%20this%29%3B%0A%09%7D%2C%0A%09getKey%3A%20function%28keys%2C%20i%29%20%7B%0A%09%09var%20key%20%3D%20keys%20%26%26%20keys.charAt%28i%20%25%20keys.length%29%3B%0A%09%09var%20keyPrefix%20%3D%20keys%20%26%26%20%28key%20+%20this.options.accesskeySeparator%29%3B%0A%09%09return%20%5Bkey%2C%20keyPrefix%5D%3B%0A%09%7D%2C%0A%09checkForMiddleClick%3A%20function%28e%2C%20upd%29%20%7B%0A%09%09var%20mi%20%3D%20e.target%3B%0A%09%09if%28%0A%09%09%09%22doCommand%22%20in%20mi%0A%09%09%09%26%26%20e.button%20%3D%3D%201%0A%09%09%09%26%26%20mi.parentNode%20%3D%3D%20e.currentTarget%0A%09%09%29%20%7B%0A%09%09%09mi.doCommand%28%29%3B%0A%09%09%09if%28upd%29%0A%09%09%09%09upd%28%29%3B%0A%09%09%09else%0A%09%09%09%09this.drawUndoList%28%29%3B%0A%09%09%7D%0A%09%7D%2C%0A%09crop%3A%20function%28s%2C%20crop%29%20%7B%0A%09%09if%28crop%20%3D%3D%20undefined%29%0A%09%09%09crop%20%3D%20500%3B%0A%09%09if%28s.length%20%3C%3D%20crop%29%0A%09%09%09return%20s%3B%0A%09%09var%20start%20%3D%20Math.round%28crop*0.6%29%3B%0A%09%09return%20s.substr%280%2C%20start%29%20+%20%22%u2026%22%20+%20s.substr%28start%20-%20crop%29%3B%0A%09%7D%2C%0A%09convertURI%3A%20function%28uri%2C%20crop%29%20%7B%0A%09%09if%28%21uri%20%7C%7C%20uri.indexOf%28%22%5Cn%22%29%20%21%3D%20-1%29%0A%09%09%09return%20uri%3B%0A%09%09uri%20%3D%20this.losslessDecodeURI%28uri%29%3B%0A%09%09return%20this.crop%28uri%2C%20crop%29%3B%0A%09%7D%2C%0A%09losslessDecodeURI%3A%20function%28uri%29%20%7B%0A%09%09if%28uri%29%20try%20%7B%0A%09%09%09return%20this._losslessDecodeURI%28uri%29%3B%0A%09%09%7D%0A%09%09catch%28e%29%20%7B%0A%09%09%09Components.utils.reportError%28e%29%3B%0A%09%09%7D%0A%09%09return%20uri%3B%0A%09%7D%2C%0A%09get%20_losslessDecodeURI%28%29%20%7B%0A%09%09var%20ldu%3B%0A%09%09if%28%22losslessDecodeURI%22%20in%20window%29%0A%09%09%09ldu%20%3D%20losslessDecodeURI%3B%0A%09%09else%20if%28%22UrlbarInput%22%20in%20window%29%20//%20Firefox%2075+%0A%09%09%09ldu%20%3D%20Components.utils.import%28%22resource%3A///modules/UrlbarInput.jsm%22%2C%20%7B%7D%29.losslessDecodeURI%3B%0A%09%09delete%20this._losslessDecodeURI%3B%0A%09%09return%20this._losslessDecodeURI%20%3D%20ldu%0A%09%09%09%3F%20function%28uri%29%20%7B%0A%09%09%09%09return%20ldu%28makeURI%28uri%29%29%3B%0A%09%09%09%7D%0A%09%09%09%3A%20decodeURI%3B%0A%09%7D%2C%0A%09cachedIcon%3A%20function%28src%29%20%7B%0A%09%09src%20%3D%20src.replace%28/%5B%26%23%5D-moz-resolution%3D%5Cd+%2C%5Cd+%24/%2C%20%22%22%29%3B%20//%20Firefox%2022+%0A%09%09if%28%0A%09%09%09%21/%5Ehttps%3F%3A/.test%28src%29%0A%09%09%09//%20IDN%2C%20see%20https%3A//bugzilla.mozilla.org/show_bug.cgi%3Fid%3D311045%0A%09%09%09%7C%7C%20/%5Ehttps%3F%3A%5C/%5C/%5B%5E.%3A%5C/%5D+%5C.%5B%5Ea-z0-9-%5D+%28%3F%3A%5C/%7C%24%29/.test%28src%29%20%26%26%20this.platformVersion%20%3C%2046%0A%09%09%09%7C%7C%20this.appName%20%3D%3D%20%22SeaMonkey%22%20%26%26%20this.appVersion%20%3C%3D%202%0A%09%09%09%7C%7C%20this.appName%20%3D%3D%20%22Firefox%22%20%20%20%26%26%20this.appVersion%20%3C%3D%203.5%0A%09%09%29%0A%09%09%09return%20src%3B%0A%09%09return%20%22moz-anno%3Afavicon%3A%22%20+%20src%3B%20//%20https%3A//bugzilla.mozilla.org/show_bug.cgi%3Fid%3D467828%0A%09%7D%2C%0A%09updUI%3A%20function%28%29%20%7B%0A%09%09var%20tabsCount%20%3D%20this.closedTabCount%3B%0A%09%09var%20dis%20%3D%20%21tabsCount%20%26%26%20%21this.closedWindowCount%3B%0A%09%09if%28%0A%09%09%09dis%0A%09%09%09%26%26%20this.options.useMenu%0A%09%09%09%26%26%20this.options.menuTemplate.indexOf%28%22restoreLastSession%22%29%20%21%3D%20-1%0A%09%09%09%26%26%20%22restoreLastSession%22%20in%20this.ss%20%26%26%20this.ss.canRestoreLastSession%0A%09%09%29%0A%09%09%09dis%20%3D%20false%3B%0A%09%09this.button.disabled%20%3D%20dis%3B%0A%09%7D%2C%0A%09updTooltip%3A%20function%28tip%2C%20tn%29%20%7B%0A%09%09var%20template%2C%20header%2C%20title%2C%20url%2C%20closedAt%3B%0A%09%09if%28tn%20%3D%3D%20this.button%29%20%7B%0A%09%09%09template%20%3D%20this.options.buttonTipTemplate%3B%0A%09%09%09header%20%3D%20_localize%28%22restoreTab%22%29%3B%0A%09%09%09let%20undoTabItems%20%3D%20JSON.parse%28this.ss.getClosedTabData%28window%29%29%3B%0A%09%09%09if%28undoTabItems.length%29%20%7B%0A%09%09%09%09let%20lastItem%20%3D%20undoTabItems%5B0%5D%3B%0A%09%09%09%09title%20%3D%20lastItem.title%3B%0A%09%09%09%09url%20%3D%20lastItem.state%20%26%26%20lastItem.state.entries%0A%09%09%09%09%09%26%26%20lastItem.state.entries%5BlastItem.state.index%20-%201%5D.url%3B%0A%09%09%09%09closedAt%20%3D%20lastItem.closedAt%20%7C%7C%200%3B%0A%09%09%09%7D%0A%09%09%7D%0A%09%09else%20if%28tn.hasAttribute%28%22cb_index%22%29%29%20%7B%0A%09%09%09template%20%3D%20this.options.itemTipTemplate%3B%0A%09%09%09title%20%3D%20tn.getAttribute%28%22label%22%29%3B%0A%09%09%09url%20%3D%20tn.getAttribute%28%22cb_url%22%29%3B%0A%09%09%09closedAt%20%3D%20+tn.getAttribute%28%22cb_closedAt%22%29%3B%0A%09%09%7D%0A%09%09else%20%7B%0A%09%09%09return%20false%3B%0A%09%09%7D%0A%0A%09%09var%20tipData%20%3D%20this.getTooltipData%28template%2C%20header%2C%20title%2C%20url%2C%20closedAt%29%3B%0A%09%09tip.textContent%20%3D%20%22%22%3B%0A%09%09tip.appendChild%28tipData%29%3B%0A%09%09if%28closedAt%20%26%26%20template.indexOf%28%22closedAt%22%29%20%21%3D%20-1%29%20%7B%0A%09%09%09tip.initUpdateTimer%28function%28%29%20%7B%0A%09%09%09%09var%20tipData%20%3D%20this.getTooltipData%28template%2C%20header%2C%20title%2C%20url%2C%20closedAt%29%3B%0A%09%09%09%09if%28tipData.textContent%20%21%3D%20tip.textContent%29%20%7B%0A%09%09%09%09%09tip.textContent%20%3D%20%22%22%3B%0A%09%09%09%09%09tip.appendChild%28tipData%29%3B%0A%09%09%09%09%7D%0A%09%09%09%7D%2C%20this%29%3B%0A%09%09%7D%0A%09%09return%20tip.hasChildNodes%28%29%3B%0A%09%7D%2C%0A%09getTooltipData%3A%20function%28template%2C%20header%2C%20title%2C%20url%2C%20closedAt%29%20%7B%0A%09%09var%20df%20%3D%20document.createDocumentFragment%28%29%3B%0A%09%09var%20hasHeader%20%3D%20header%20%26%26%20template.indexOf%28%22header%22%29%20%21%3D%20-1%3B%0A%09%09function%20item%28key%2C%20val%29%20%7B%0A%09%09%09var%20lbl%20%3D%20document.createElementNS%28xulns%2C%20%22label%22%29%3B%0A%09%09%09lbl.className%20%3D%20%22cb-%22%20+%20key%20+%20%22%20tooltip-label%22%3B%0A%09%09%09lbl.textContent%20%3D%20val%3B%0A%09%09%09lbl.setAttribute%28%22maxwidth%22%2C%20%22450%22%29%3B%20//%20Trick%20to%20restore%20right%20border%20for%20long%20lines%0A%09%09%09if%28key%20%3D%3D%20%22closedAt%22%20%7C%7C%20hasHeader%20%26%26%20key%20%21%3D%20%22header%22%29%0A%09%09%09%09lbl.style.color%20%3D%20%22grayText%22%3B%0A%09%09%09return%20df.appendChild%28lbl%29%3B%0A%09%09%7D%0A%09%09template.forEach%28function%28key%29%20%7B%0A%09%09%09switch%28key%29%20%7B%0A%09%09%09%09case%20%22header%22%3A%0A%09%09%09%09%09if%28header%29%0A%09%09%09%09%09%09item%28key%2C%20header%29%3B%0A%09%09%09%09break%3B%0A%09%09%09%09case%20%22title%22%3A%0A%09%09%09%09%09if%28title%20%26%26%20title%20%21%3D%20url%29%0A%09%09%09%09%09%09item%28key%2C%20title%29%3B%0A%09%09%09%09break%3B%0A%09%09%09%09case%20%22url%22%3A%0A%09%09%09%09%09if%28url%29%0A%09%09%09%09%09%09item%28key%2C%20this.convertURI%28url%29%29%3B%0A%09%09%09%09break%3B%0A%09%09%09%09case%20%22closedAt%22%3A%0A%09%09%09%09%09if%28%21closedAt%29%0A%09%09%09%09%09%09break%3B%0A%09%09%09%09%09let%20dt%20%3D%20Math.round%28Math.max%280%2C%20Date.now%28%29%20-%20closedAt%29/1000%29%3B%0A%09%09%09%09%09let%20days%20%3D%20Math.floor%28dt/24/3600%29%3B%0A%09%09%09%09%09dt%20-%3D%20days*24*3600%3B%0A%09%09%09%09%09let%20d%20%3D%20new%20Date%28%28dt%20+%20new%20Date%28dt%29.getTimezoneOffset%28%29*60%29*1000%29%3B%0A%09%09%09%09%09let%20m%20%3D%20d.getMinutes%28%29%3B%0A%09%09%09%09%09let%20ts%20%3D%20d.getHours%28%29%20+%20%22%3A%22%20+%20%28m%20%3E%209%20%3F%20m%20%3A%20%220%22%20+%20m%29%3B%0A%09%09%09%09%09if%28days%29%0A%09%09%09%09%09%09ts%20%3D%20days%20+%20_localize%28%22day%22%29%20+%20%22%20%22%20+%20ts%3B%0A%09%09%09%09%09let%20tsTip%20%3D%20_localize%28%22itemTip%22%29%0A%09%09%09%09%09%09.replace%28%22%25ago%22%2C%20ts%29%0A%09%09%09%09%09%09.replace%28%22%25date%22%2C%20new%20Date%28closedAt%29.toLocaleString%28%29%29%3B%0A%09%09%09%09%09item%28key%2C%20tsTip%29%3B%0A%09%09%09%7D%0A%09%09%7D%2C%20this%29%3B%0A%09%09return%20df%3B%0A%09%7D%2C%0A%09get%20wm%28%29%20%7B%0A%09%09delete%20this.wm%3B%0A%09%09return%20this.wm%20%3D%20Components.classes%5B%22@mozilla.org/appshell/window-mediator%3B1%22%5D%0A%09%09%09.getService%28Components.interfaces.nsIWindowMediator%29%3B%0A%09%7D%2C%0A%09updUIGlobal%3A%20function%28%29%20%7B%0A%09%09var%20isSeaMonkey%20%3D%20this.appName%20%3D%3D%20%22SeaMonkey%22%3B%0A%09%09var%20ws%20%3D%20this.wm.getEnumerator%28isSeaMonkey%20%3F%20null%20%3A%20%22navigator%3Abrowser%22%29%3B%0A%09%09const%20id%20%3D%20this.button.id%3B%0A%09%09while%28ws.hasMoreElements%28%29%29%20%7B%0A%09%09%09let%20win%20%3D%20ws.getNext%28%29%3B%0A%09%09%09if%28isSeaMonkey%20%26%26%20%21this.isBrowserWindow%28win%29%29%0A%09%09%09%09continue%3B%0A%09%09%09let%20btn%20%3D%20win.document.getElementById%28id%29%3B%0A%09%09%09if%28btn%20%26%26%20%22undoCloseTabsList%22%20in%20btn%29%20%7B%0A%09%09%09%09let%20ucl%20%3D%20btn.undoCloseTabsList%3B%0A%09%09%09%09ucl.ensureSessionsInitialized%28ucl.updUI%2C%20ucl%29%3B%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%2C%0A%09isBrowserWindow%3A%20function%28win%29%20%7B%0A%09%09var%20loc%20%3D%20window.location.href%3B%0A%09%09return%20loc%20%3D%3D%20%22chrome%3A//browser/content/browser.xul%22%0A%09%09%09%7C%7C%20loc%20%3D%3D%20%22chrome%3A//navigator/content/navigator.xul%22%3B%0A%09%7D%2C%0A%09ensureSessionsInitialized%3A%20function%28callback%2C%20context%29%20%7B%0A%09%09var%20_this%20%3D%20this%3B%0A%09%09var%20stopTime%20%3D%20Date.now%28%29%20+%203e3%3B%0A%09%09%28function%20ensureInitialized%28%29%20%7B%0A%09%09%09try%20%7B%0A%09%09%09%09_this.ss.getClosedTabCount%28window%29%3B%0A%09%09%09%09callback.call%28context%29%3B%0A%09%09%09%09return%3B%0A%09%09%09%7D%0A%09%09%09catch%28e%29%20%7B%0A%09%09%09%09if%28Date.now%28%29%20%3E%20stopTime%29%20%7B%0A%09%09%09%09%09Components.utils.reportError%28%0A%09%09%09%09%09%09_this.errPrefix%0A%09%09%09%09%09%09+%20%22Can%27t%20initialize%3A%20nsISessionStore.getClosedTabCount%28%29%20failed%22%0A%09%09%09%09%09%29%3B%0A%09%09%09%09%09Components.utils.reportError%28e%29%3B%0A%09%09%09%09%09return%3B%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09setTimeout%28ensureInitialized%2C%2050%29%3B%0A%09%09%7D%29%28%29%3B%0A%09%7D%0A%7D%3B%0A%0Aif%28%21this.undoCloseTabsList.options.useMenu%20%26%26%20this.undoCloseTabsList.useCentextMenu%29%20%7B%0A%09this.oncontextmenu%20%3D%20function%28e%29%20%7B%0A%09%09if%28%0A%09%09%09e.target%20%21%3D%20this%0A%09%09%09%7C%7C%20e.ctrlKey%20%7C%7C%20e.shiftKey%20%7C%7C%20e.altKey%20%7C%7C%20e.metaKey%0A%09%09%09%7C%7C%20%21this.undoCloseTabsList.mp.hasChildNodes%28%29%0A%09%09%29%0A%09%09%09return%3B%0A%09%09e.preventDefault%28%29%3B%0A%09%09this.undoCloseTabsList.showMenu%28e%29%3B%20//%20Show%20menu%20without%20%22context%22%20flag%0A%09%7D%3B%0A%7D%0Aif%28this.undoCloseTabsList.options.rightClickToUndoCloseTab%29%20%7B%0A%09this.oncontextmenu%20%3D%20function%28e%29%20%7B%0A%09%09if%28e.target%20%3D%3D%20this%20%26%26%20%21e.ctrlKey%20%26%26%20%21e.shiftKey%20%26%26%20%21e.altKey%20%26%26%20%21e.metaKey%29%0A%09%09%09e.preventDefault%28%29%3B%0A%09%7D%3B%0A%7D%0A%0Athis.disabled%20%3D%20true%3B%0AsetTimeout%28function%28_this%29%20%7B%0A%09_this.undoCloseTabsList.init%28%29%3B%0A%7D%2C%200%2C%20this%29%3B%0A%0A//%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A//%20Styles%0A//%20Used%20icons%20from%20Undo%20Closed%20Tabs%20Button%20extension%0A%0A//%20Styles%20can%27t%20override%20hardcoded%20icon%0Aif%28%20//%20Remove%20icon%20only%20if%20nsIStyleSheetService%20works%20on-the-fly%20%28Firefox%203.0+%29%0A%09%21Components.ID%28%22%7B41d979dc-ea03-4235-86ff-1e3c090c5630%7D%22%29%0A%09%09.equals%28Components.interfaces.nsIStyleSheetService%29%0A%29%20%7B%0A%09let%20icon%20%3D%20this.icon%0A%09%09%7C%7C%20this.ownerDocument.getAnonymousElementByAttribute%28this%2C%20%22class%22%2C%20%22toolbarbutton-icon%22%29%3B%0A%09if%28icon%29%0A%09%09icon.src%20%3D%20%22%22%3B%0A%09else%0A%09%09this.image%20%3D%20%22%22%3B%0A%7D%0A%0Avar%20cssStr%20%3D%20%27%5C%0A@namespace%20url%28%22http%3A//www.mozilla.org/keymaster/gatekeeper/there.is.only.xul%22%29%3B%5Cn%5C%0A%09@-moz-document%20url%28%22%25windowURL%25%22%29%20%7B%5Cn%5C%0A%09%09%25button%25%20%7B%5Cn%5C%0A%09%09%09list-style-image%3A%20url%28%22data%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAEEUlEQVRIS9XVbWxTVRgA4Pfce3tv27t2bbNuXbfCBuyzAZ2MEdkkLH5gJvEH8TOZEo0JFdgmbgjTgEHUGQXGMJEMmDJMiNvQjS9BJhH8MY3IfsB0rnTraCcbm13b2+/1fni2xAVuxOHAH57+adNz3uee9z3vuQj+44FmG79VksglAIoMgBhCSLpdnFkBkiQxl2OQgRdbJhjoKkQofM+ALklSGSNwf1iAjbXNZ3MdI+MB+7vPF989IEnoZwBVQhCWBgVhW13b+WX5KXpFR7fDe/ntZ8wYiONUiXLojlKEU4LGANgRDpZHBH7r9iPnilZaM4jKFTlQ/P5XvHV+6o5si7HzuWUL+hzngSstRfxf0DSwa9cHa3GgWgmQTv4UNMMggyWTMuYtYepOXCKfKMiGZ4tyQEMDjPrDcGVoDI780As3/AGhJIVs2vTk6pqkJAhOFn8KaG1tpV1u53h5+RpGr7s1/uTxCIgk6g/EiaqmM2i5NRseL7SCgwMg8Wo9A5CsBLjPADDki8CbbRdgQiI631n/2NOFANwUUF9frxPECVf1628gn893Sx55IIhxBavcffIi1fO7H15atRJiAoD8XBI4UmYCwOIkCdY3fyuyrGrHZ+UldXJAwoDn5hThQESYpNXXQpJuw4HTiuzM+fBAfu7UFIQ/0wN/nfydrEKwSCdARfMZftVSa6kcEPx+v0NeA7wlKowYXX+AT604+DWTmT4XcufhFsN6r9MJ/gAHiVotpBmNoNNoIctAw8Xf7FKMjx2TA7zX6/3p7860SBCKEGJSBrj4PIyozMkm0KhZsDv7hTUP5Xt+HfFpuvqGVBZTKizEuOePEYiL0V/kQJzjuG9u1zS8RDAhRFv6/FFr5YFTaopicJGRt932yDmJQLQ3JpY9+lEHVZCTB6PecTAmEMNyIIZr8MU/3U8iSSo5RGfZPZGFFftPaU0a9dgxW+mXBEGQtJJ5xbq1hUo3mdENzxjYyoq65UAUA5/MdAGKiFQHSGbB1WEPDZGIq3COYRQD1I/XPJttn39PKRlWYpUgfvraU2/JgXAwGHxvRkAUEd6JAteYJAUhioNLwaigLN1z8sNQLA5mQyK//YWHr8zRaV9EjY2NikDAuwkQ2oL7IIRH9UzATf9PPuBUS4gIKY92u/Zf5zhixaKsAa1BXzOhhrNoz96d21JNaavT0tO9xQ+W5GDg5X8BTE/lCSIBUcqW3kGX3XW1Jz7sdtVXrn31EGpo2Nm0bl1VHt7maTw7Eo1GL8wGwPcOiRSKMpIgUpzOAd2JjqOdNTW1B1HDx7ttlRs2mnCDHZ5NYPkalmXnut3uxe3tbZeqqzd/h/bt21tgs1WocYP13AtAr9cnDg4Omo8fb7leVbXFdUfvg7uB///An8idyhRIYoVPAAAAAElFTkSuQmCC%22%29%20%21important%3B%5Cn%5C%0A%09%09%7D%5Cn%5C%0A%09%09%25button%25%3Ahover%20%7B%5Cn%5C%0A%09%09%09list-style-image%3A%20url%28%22data%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAECUlEQVRIS9XVe2xTVRgA8O/ce3tv310fa8P6AOoapwznYtXFzchQJNEYNTHEODSaYLK4jsEaGcQnEpAQu8r+WLJMMmOMIQXnNgeKYTJjfBGzMEGTztVubcGmD9q1t+263t7r2Qxka8DhwD88//SP2/P97vd95zsXwX+80ErjC4JAjE4BvWEN5BFCwvXirAjAwWkfgIVjwczK4Sc7QtlbBpwRBLG+ADVcDnbu+fjUHZMX4+mJA00NNw8IAvoZQKIEsLOp4pv7PaMP2jRKanjclzi/99kKDBSuVaobKhEuCYoCyKIZaMjOcW+89clIXe1qA9H80Hp4uqu/UGszvlNl1J/eVF/pjY9CurERcVcyugq4XAdf5gXowP2SL00XAUkzSGteSxuq7LIDw2Miu9UET9y7DhgSwHcpAhN/RuHrC34QeJ57wED17nryqQ6dDtj5jBYAj8dDB4L+WNNzz0uUStWS+PPHI4so5EtzRNuRL9Hday1QX22D6RkOSLxbShGgZAgwKSiYjsTgo2/GQCGTfbXP8egWO0BqAXC73WVFfi7gbN+Fkskkv1jggCAui2Ri1/BZ6pfpGGy+7x7IFnjA2f69rvziSDopBUY5Cd1ffMtXmfX7+rY2vFsKCBiILwbwfiJL0tIpVihz9J4UlWvL4TaTaWnwRZaMJkFOzMFnP5zjmhprG0uB4szMzGTpkcMImQFG7csUV7X2nmA0ZRow6w2Amw/BSARmZ3MgFotBi8srk0iAERHweygkVBoUg6UAl0gkzl7rTPMEIcogxuBPcVbHByckKrkKJIwYwtFw8cUN1bFfLyaU33uDEp1KDQatDkLRCNy+SnGhFCikUqlT1xsaTiCYDKLNE+n8ndt7Tkp5QKhcKkoMtTwyUgREx7LcY5tdg5TNtBoSbBos5ZJLpUAe9+DoP91PHEmKWUTbJpP59Y7uIYVBKY0NNm/8lCAIkqBE22re9lB6rR7FUwl45fH7x0qBWQx0L3cB8oiUpkmm0h9JiIRsNlBrUkcxQI14w7udx34kxIwE9wLxfW3P7CkFsizL7l8W4HnEk6RovvlksTiLgwvJXEG6sXP4YJ4rQoVGxe3d+vC41ax8AfX09IhS7OXXEBDteA4yeDmXAxY9n3/BhUnApvjoOX9vPJODhnXWKbVWsyMlhdOo8/1Dr1tMa7YYjRWpurp6KwZe+hfA1b/iAyAHmvZ4g0Ff0PtbLhzwH25pbulDne5DPa2OnXfhNAeLON1CofDdSgB875Akw2zCKZn8f0xKhz4fGH21veMIch9+b9uO7U4LHrAPVxK4dI9MJrMGAoHqgYHj405nxxnU1eWqaW1tV+ABO38rALVaXRYK+Q39/Z5wW9vuwA19D24G/v8DfwHJNM8naEZRUgAAAABJRU5ErkJggg%3D%3D%22%29%20%21important%3B%5Cn%5C%0A%09%09%7D%5Cn%5C%0A%09%09%25button%25%5Bdisabled%3D%22true%22%5D%20%7B%5Cn%5C%0A%09%09%09list-style-image%3A%20url%28%22data%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADCklEQVRIS9WVz0sbQRTHZ3Y32awxYkOIMaQQjBJ026zVVLCeCpX2H2jpqaceSjGnUpBcKj0IpVA81UtLT4VCoYdepJcapBYKGjfNbwNqTGJsbGKi5pdmd/s2tEVCjBrroQMLw8x77/Pem+/MYnTOA59zfHQmwPj4+AWCIG5OTk6+OyrRpgFOp7MTgn6pVCpdLS0t9MTExH49SFMACNaFMZ7v6enRRSKRiiRJnbCWbQgAI8LjWbyBMaFtdC7r67GLwWD4CQRnLBYL4XK5yoIgbKpUqkB7e9u3oSHrlMViz/2J8bcCnl/8TJCUmVJQW0cB0ls/W91u3gqDNBqNVTNoEcrlcmhnZwdtJDdEiqSEUql0zeFwLMj7VYDf728t7xdTV/oHFeBQrAdIJpPkzMwMA5ljnU5XNwfoAgI7tLKyUhJF0T42NuavApaWltolJEQBQGWz2Xw971gsRvM8r+nr68NKpbKhulOplBSNRldBYWwtgNze3o4d5b28vKxdW1vTQRWEQqFoCIEqCtC26VoAARV4GnkCxJRIJExms5mEgeLxuJDP5wmKokSNRkNotVosw/f29hDYLdQCMABcx91ukKYV2mAxGAykDBgZGflUKBQYCHoVMlebTCYMypLh8VoA2t3d/XAcQN4Ph8P2TCbTC1NxeHj4rbwGFYzOuma1jIphoCKUTqdjtQAJAK9PApBtoF3Xi8WimeO4N78Bt+fm5vRqtZqGivIHBwePawEiaPr5SQFVncPNBHmK8hza4giFQx0KSlGB4D/0en13LUAAgPM0gMO2cKhTcA40yNMN79Moy7IZ7PV6OyrC/iuMkZ2zDSgB8KBZADwXz4KhgIAkKQECe2SzDS5ij8c9beg03tK0tpUZhtHANb93BsAU+KvyhXwlHl+f7+cG7uPvPv7FZZazQv9eQi+Fcrm82SyApmk9nIkK/B8GAr6vNlv/U+wL+O6yvawR1PC+2cCH/QBAwlNyJxTyhViW+4gjEa+lu/sSA0ar/wIgCwu+rmAwmIN3K9rUD+c0ifz/gF/LJ4uAUJQHTwAAAABJRU5ErkJggg%3D%3D%22%29%20%21important%3B%5Cn%5C%0A%09%09%7D%5Cn%5C%0A%09%09toolbar%5Biconsize%3D%22small%22%5D%20%25button%25%20%7B%5Cn%5C%0A%09%09%09list-style-image%3A%20url%28%22data%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACPElEQVQ4T2NkIBL8//+fEQj+oytnJEY/UDPXzPOPTdINZQ+jG0LQgPvv/wvsvf9k54FzN432X39S9rQ3oR/ZUrgBvb29akxMf7mQJcWVNYTeCWvOfvrijVK9nymDRevqKwqsfxdYiLDNqUgP+whSCzZg4sS+dkYmxlx2NrYfMAM4efiYXonr8Z27/4q52NeGQZiLlYGd4Q/D9iuPGDafu/3/zZevvocrwraCDZgwoWd/QECwtbi4xD8QHxRS178xsPq2LmfKC/FlEBAUYfgDFORlZWCQ52FgUOP5zVCz9sjfiw/eKMENCAwMMeXl5XsMc8FPJhbOjv235A5fe8zoZWvLwMTIxPD45UsGPm5uBiVxQQZN7u8MnVtPXUN2gbGAgOAJpDBg/MrIKtCy/bLRsVtPmXi4uBj+/fn2+9vPvyycHJyMLgZaDAcvXPoFN8A/IMhIUEBoLUoIA+Ps4382qfotZ112nL3JVOyieyjdQYfXuGWtgbCgCOOnzx//IrvAgJ9fYDKWdMH4mYlduX/HOa0AHamD3Jyc5v5TtptzsrMzeBmrXWKcNGkS399/Pw8GBoTIA71QgSNhwaL7/9zjdzN6d10wdDdR/5XrbWbNOHvOjA18fHwmTo6ubECQQChlcnBzR5y9/yT4wcVTb1+/fW7DuGjR3EXR0QlfgMn16N+/fy8TMoCJiUkCiK0PHNqvduXSuTrGNWtWugcHh737+PHjHUKaYfL8/Pyip04dV7tw4dBhgnmBkKEUGwAAgK/XtUYSNDQAAAAASUVORK5CYII%3D%22%29%20%21important%3B%5Cn%5C%0A%09%09%7D%5Cn%5C%0A%09%09toolbar%5Biconsize%3D%22small%22%5D%20%25button%25%3Ahover%20%7B%5Cn%5C%0A%09%09%09list-style-image%3A%20url%28%22data%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACRElEQVQ4T2NkIBr8Z2RgYPyPrhwoSBj8//+fbfXt11phqqIXGRhRDSFoAFAzz8KLzzdvP3nZ+titFwWPe+OnIVsJN6BnSo88ww8GTmRJBRUV/jeSuvOOXL6nVeJuxBA3Z+cZWfY/M0x1BZc3+Pp+A6kFGzBxYm8T0GnFrKwsP2AGsHPyMH2RNebdfukxc6KLOYMAFzvDq3fvGC49fMFw+dGL/z9+/nQ7UBm+B2zAhIk9+3x9A2ylJKX/gfigkLr9jZHVt305Y4i9JQMbJy/Dn3//GbhZmRiEuVgYWP9+ZVh19MLfHz9/y0MMmNCz39cvwEJQQOgBzAU/mdg4m3dflTty7TGjkYYm2KmvP3xg4OLgYBDm42H48/09w/UnLy8hG2AuLCRyFCkMGL8ysAo0brtoeOzmEyZ2NjYGFsY/v7///sfCzMTCKCEiyvDo+dNfcAP8/AJNhYSEV6GEMCMj0BA2yaqNZ1x3nr/FlO+kfSTbSY/bqHmtAQ8PH+OPH9/+ohggKCjUhyVVMH5hYlfs3XFeO1BH8hAHB4d50NTt5pzs7AyuhioXGWfO7OD/9p35EDAQFcVExYuxJat///6BLWJiYvo/59jtjN5dF418zDV/ZbpZWDDOnTtzI7+AoLGDvSM3KytbFKF0ycHNHXnx/tPgW+dPvnn99qk948LF8+bFRMV/Aqa4Y9+/f79G0AAODjGgUywOHdivefHipUbGVetWOYUGhr778OEDPAoJGSIgICB87Ngh5bNnL54gmBcIGUaxAQAqY9puYCzN/wAAAABJRU5ErkJggg%3D%3D%22%29%20%21important%3B%5Cn%5C%0A%09%09%7D%5Cn%5C%0A%09%09toolbar%5Biconsize%3D%22small%22%5D%20%25button%25%5Bdisabled%3D%22true%22%5D%20%7B%5Cn%5C%0A%09%09%09list-style-image%3A%20url%28%22data%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAB70lEQVQ4T2NkoBAwEqu/vLzcjpOT81pDQ8MbZD1EGVBZWZn579+/qUxMTBXt7e1dGAbcv3+f4/2n9z6M//7zoLvo7NlzXh8+fPQTFxdnfwEEvPy8R+RlpWd4evruBakFu+DCpfNLONg4/NjZ2X4jG3D16jWup0+fsRsZGTGysLAwvH79muH9+/cMQHMY2NjY8jMzMyfBDNivrKhs+f8/wy+YAb9+/WJcs2YNj66uLgMvLy+Kw75//85w6dKl74yMjNZwAxQVlEz//f13D1nlgwcPBG/evCmloqLCBFQMth1oMwMfHx/Dx48f/z99+vQssgHGDP8ZjqCHwd27d+UfP36szs7ODvLGO2BAcgNdwCEhIcH46NGjt8gGGP3/938VtmgFBrIB0N8mcnJyB1VVVbkOHjxgzMnJxfT169cnCAPklQyApk/AlS6ePXumJSQk9ACoxuHKlStmQPonUG0e4+XLl8X//v29V0lJWQoYKaWEEtaXL1/SgX43AQbJWhMT01DGq9ev7ODm4tKWEJdi+/PnTxwhA4CpMfz161e+79+/e/f7919Pxtu3b85RUlJ5+////8PAwLlPyAAODg5BoPONXr16YfDmzbtWxseP79vLyCgAY+j9Q0KaYfJAVwgCA1DpzZs3p4nKC/gMptgAAO1G2FJifkXnAAAAAElFTkSuQmCC%22%29%20%21important%3B%5Cn%5C%0A%09%09%7D%5Cn%5C%0A%09%7D%27%0A%09.replace%28/%25windowURL%25/g%2C%20window.location.href%29%0A%09.replace%28/%25button%25/g%2C%20%22%23%22%20+%20this.id%29%3B%0Avar%20cssURI%20%3D%20this.cssURI%20%3D%20Components.classes%5B%22@mozilla.org/network/io-service%3B1%22%5D%0A%09.getService%28Components.interfaces.nsIIOService%29%0A%09.newURI%28%22data%3Atext/css%2C%22%20+%20encodeURIComponent%28cssStr%29%2C%20null%2C%20null%29%3B%0Avar%20sss%20%3D%20this.sss%20%3D%20Components.classes%5B%22@mozilla.org/content/style-sheet-service%3B1%22%5D%0A%09.getService%28Components.interfaces.nsIStyleSheetService%29%3B%0Aif%28%21sss.sheetRegistered%28cssURI%2C%20sss.USER_SHEET%29%29%0A%09sss.loadAndRegisterSheet%28cssURI%2C%20sss.USER_SHEET%29%3B%0A%0A%0Athis.onDestroy%20%3D%20function%28reason%29%20%7B%0A%09this.undoCloseTabsList.destroy%28%29%3B%0A%09if%28reason%20%3D%3D%20%22destructor%22%29%20//%20May%20happens%20before%20%22unload%22%0A%09%09this.undoCloseTabsList.updUIGlobal%28%29%3B%0A%09if%28reason%20%3D%3D%20%22update%22%20%7C%7C%20reason%20%3D%3D%20%22delete%22%29%20%7B%0A%09%09let%20sss%20%3D%20this.sss%3B%0A%09%09let%20cssURI%20%3D%20this.cssURI%3B%0A%09%09if%28sss.sheetRegistered%28cssURI%2C%20sss.USER_SHEET%29%29%0A%09%09%09sss.unregisterSheet%28cssURI%2C%20sss.USER_SHEET%29%3B%0A%09%7D%0A%7D%3B%0Aif%28this.undoCloseTabsList.options.useMenu%29%20%7B%0A%09this.type%20%3D%20%22menu%22%3B%0A%09this.orient%20%3D%20%22horizontal%22%3B%0A%7D%5D%5D%3E%3C/initcode%3E%0A%20%20%3Ccode%3E%3C%21%5BCDATA%5Bif%28%21event.target%29%20//%20Button%27s%20hotkey%20pressed%0A%09this.undoCloseTabsList.drawUndoList%28%29%20%26%26%20this.undoCloseTabsList.openMenu%28%29%3B%5D%5D%3E%3C/code%3E%0A%20%20%3Caccelkey%3E%3C%21%5BCDATA%5B%5D%5D%3E%3C/accelkey%3E%0A%20%20%3Chelp%3E%3C%21%5BCDATA%5B%5D%5D%3E%3C/help%3E%0A%20%20%3Cattributes/%3E%0A%3C/custombutton%3E

Отсутствует

 

№13131-03-2024 16:16:48

Alex_one
Участник
 
Группа: Members
Зарегистрирован: 27-09-2015
Сообщений: 151
UA: Firefox 115.0

Re: [CB]Undo Close Tabs

VORON пишет

А попробуй мою, тоже не будет работать?

Нет, тоже не работает. Так же значок неактивный. :(
На сайт последнее время тяжело зайти.

Отсутствует

 

№13231-03-2024 16:30:33

Jurgens
Эйяфьядлайёкюдль
 
Группа: Members
Зарегистрирован: 25-06-2010
Сообщений: 190
UA: Firefox 115.0

Re: [CB]Undo Close Tabs

Alex_one пишет

Нет, тоже не работает. Так же значок неактивный.

Подтверждаю.
Хоть и не пользуюсь этой кнопкой (перешёл на альтернативный вариант "Журнал" - "Недавно закрытые вкладки"), но таки проверил - не работает ни один из двух выложенных выше кодов.

Отредактировано Jurgens (31-03-2024 16:34:40)

Отсутствует

 

№13331-03-2024 16:33:59

Alex_one
Участник
 
Группа: Members
Зарегистрирован: 27-09-2015
Сообщений: 151
UA: Firefox 115.0

Re: [CB]Undo Close Tabs

Jurgens пишет

перешёл на альтернативный

На что?
Понятно.

Отредактировано Alex_one (31-03-2024 16:35:15)

Отсутствует

 

№13431-03-2024 16:34:51

vending_machine
Участник
 
Группа: Members
Зарегистрирован: 10-01-2020
Сообщений: 549
UA: Firefox 115.0

Re: [CB]Undo Close Tabs

Alex_one пишет

Не хочет и всё тут.

при закрытом Firefox, папку startupCache
из Локального каталога профиля — у д о л и т ь :dumb:

Отсутствует

 

№13531-03-2024 16:39:13

Jurgens
Эйяфьядлайёкюдль
 
Группа: Members
Зарегистрирован: 25-06-2010
Сообщений: 190
UA: Firefox 115.0

Re: [CB]Undo Close Tabs

Alex_one пишет
Jurgens пишет

перешёл на альтернативный

На что?
Понятно.

Как по мне - вполне приемлемо, да и количество вкладок можно сделать побольше.
2024-03-31_163517.png

Отсутствует

 

№13631-03-2024 16:43:21

Alex_one
Участник
 
Группа: Members
Зарегистрирован: 27-09-2015
Сообщений: 151
UA: Firefox 115.0

Re: [CB]Undo Close Tabs

vending_machine пишет

у д о л и т ь

Само собой, но для этого использую скрипт.

скрытый текст
31-03-2024-163938.jpg

Отсутствует

 

№13731-03-2024 20:30:04

ifln
Участник
 
Группа: Members
Зарегистрирован: 20-09-2013
Сообщений: 235
UA: Firefox 115.0

Re: [CB]Undo Close Tabs

Alex_one пишет

А на [firefox] 115.9.1esr, версия 0.3.3.3 - 04.09.2021 уже не работает?

У меня предыдущая версия работает. Но там я что-то редактировал.

скрытый текст

Выделить код

Код:

// http://infocatcher.ucoz.net/js/cb/undoCloseTabs.js
// https://forum.mozilla-russia.org/viewtopic.php?id=56267
// https://github.com/Infocatcher/Custom_Buttons/tree/master/Undo_Close_Tabs

// Undo Close Tabs button for Custom Buttons
// (code for "initialization" section)

// (c) Infocatcher 2009-2015, 2017-2020
// version 0.3.3.2 - 2020-03-14

var options = {
	menuTemplate: [
		"closedWindows",
		"separator",
		"restoreClosedWindows",
		"clearClosedWindows",
		"separator",
		"closedTabs",
		"separator",
		"restoreClosedTabs",
		"clearClosedTabs",
		"separator",
		"clearAll",
		"separator",
		"restoreLastSession",
		"separator",
		"buttonMenu"
	],
	showInTabContextMenu: false,
	/*
	menuTemplateTabContext: [ // like menuTemplate
		"closedTabs",
		"separator",
		"restoreClosedTabs",
		"clearClosedTabs"
	],
	*/
	windowItemTemplate: "(%count) %title",
	windowSelectedTabPrefix: "*",
	buttonTipTemplate: ["header", "title", "url", "closedAt"],
	itemTipTemplate: ["title", "url", "closedAt"],
	hideRestoreAllForSingleEntry: false,
	allowDeleteEntries: true,
	accesskeys: { // Empty string ("") to disable or string with possible values ("0123...", "abcd...")
		closedTabs: "",
		closedWindows: ""
	},
	accesskeySeparator: " ", // <accesskey><separator><label>
	openMenuOnMouseover: false,
	useMenu: false,
	rightClickToUndoCloseTab: false // Useful with "useMenu: true"
};

function _localize(sid) {
	var strings = {
		en: {
			restoreTab: "Restore the most recently closed tab",

			restoreAllTabs: "Restore all tabs",
			restoreAllTabsAccesskey: "t",
			clearTabsHistory: "Clear history of closed tabs",
			clearTabsHistoryAccesskey: "b",

			restoreAllWindows: "Restore all windows",
			restoreAllWindowsAccesskey: "w",
			clearWindowsHistory: "Clear history of closed windows",
			clearWindowsHistoryAccesskey: "d",

			clearAllHistory: "Clear all history",
			clearAllHistoryAccesskey: "C",

			restoreLastSession: "Restore last session",
			restoreLastSessionAccesskey: "s",

			deleteUndoEntry: "Delete",

			buttonMenu: "Button menu",
			buttonMenuAccesskey: "m",

			tabContextMenu: "Recently Closed Tabs",
			tabContextMenuAccesskey: "y",

			itemTip: "%ago ago, %date",
			day: "d"
		},
		ru: {
			restoreTab: "Восстановить последнюю закрытую вкладку",

			restoreAllTabs: "Восстановить все вкладки",
			restoreAllTabsAccesskey: "л",
			clearTabsHistory: "Очистить историю закрытых вкладок",
			clearTabsHistoryAccesskey: "д",

			restoreAllWindows: "Восстановить все окна",
			restoreAllWindowsAccesskey: "о",
			clearWindowsHistory: "Очистить историю закрытых окон",
			clearWindowsHistoryAccesskey: "н",

			clearAllHistory: "Очистить всю историю",
			clearAllHistoryAccesskey: "ч",

			restoreLastSession: "Восстановить последнюю сессию",
			restoreLastSessionAccesskey: "с",

			deleteUndoEntry: "Удалить",

			buttonMenu: "Меню кнопки",
			buttonMenuAccesskey: "М",

			tabContextMenu: "Недавно закрытые вкладки",
			tabContextMenuAccesskey: "о",

			itemTip: "%ago назад, %date",
			day: "д"
		}
	};
	var locale = (function() {
		if("Services" in window && "locale" in Services) {
			var locales = Services.locale.requestedLocales // Firefox 64+
				|| Services.locale.getRequestedLocales && Services.locale.getRequestedLocales();
			if(locales)
				return locales[0];
		}
		var prefs = "Services" in window && Services.prefs
			|| Components.classes["@mozilla.org/preferences-service;1"]
				.getService(Components.interfaces.nsIPrefBranch);
		function pref(name, type) {
			return prefs.getPrefType(name) != prefs.PREF_INVALID ? prefs["get" + type + "Pref"](name) : undefined;
		}
		if(!pref("intl.locale.matchOS", "Bool")) { // Also see https://bugzilla.mozilla.org/show_bug.cgi?id=1414390
			var locale = pref("general.useragent.locale", "Char");
			if(locale && locale.substr(0, 9) != "chrome://")
				return locale;
		}
		return Components.classes["@mozilla.org/chrome/chrome-registry;1"]
			.getService(Components.interfaces.nsIXULChromeRegistry)
			.getSelectedLocale("global");
	})().match(/^[a-z]*/)[0];
	_localize = function(sid) {
		return strings[locale] && strings[locale][sid] || strings.en[sid] || sid;
	};
	return _localize.apply(this, arguments);
}

var JSON = "JSON" in window
	//? window.JSON
	? {
		parse: function(arg) {
			return typeof arg == "string"
				? (JSON = window.JSON).parse(arg)
				: (this.parse = function(obj) {
					return obj;
				}) && arg;
		}
	}
		: {
			parse: function(s) {
				return Components.utils.evalInSandbox("(" + s + ")", new Components.utils.Sandbox("about:blank"));
			}
		};

this.onclick = function(e) {
	if(e.target != this)
		return;
	if(e.button == 1 || e.button == 0 && (e.ctrlKey || e.shiftKey || e.altKey || e.metaKey))
		this.undoCloseTabsList.clearAllLists();
	else if(
		e.button == 0
		|| e.button == 2 && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey
			&& this.undoCloseTabsList.options.rightClickToUndoCloseTab
	) {
		if(
			e.button == 0 && !this.undoCloseTabsList.options.useMenu
			|| e.button == 2 && this.undoCloseTabsList.options.rightClickToUndoCloseTab
		) {
			if(this.undoCloseTabsList.closedTabCount)
				this.undoCloseTabsList.undoCloseTab();
			else
				this.undoCloseTabsList.drawUndoList() && this.undoCloseTabsList.showMenu(e);
		}
		// Allow use "command" section only from hotkey:
		e.preventDefault();
		e.stopPropagation();
	}
};
if(!this.hasOwnProperty("defaultContextId"))
	this.defaultContextId = this.getAttribute("context") || "custombuttons-contextpopup";
this.onmousedown = function(e) {
	if(e.target != this)
		return;
	if(this.undoCloseTabsList.options.useMenu) {
		if(e.button == 0)
			this.undoCloseTabsList.drawUndoList();
	}
	else if(e.button == 2) {
		var showCbMenu = e.ctrlKey || e.shiftKey || e.altKey || e.metaKey || !this.undoCloseTabsList.drawUndoList();
		this.setAttribute(
			"context",
			showCbMenu
				? this.defaultContextId
				: this.undoCloseTabsList.mpId
		);
	}
};
this.onmouseover = function(e) {
	if(e.target != this)
		return;
	if(!this.disabled)
		this.undoCloseTabsList.updUI();
	this.undoCloseTabsList.options.useMenu && Array.prototype.some.call(
		this.parentNode.getElementsByTagName("*"),
		function(node) {
			if(
				node != this
				&& node.namespaceURI == xulns
				// See https://github.com/Infocatcher/Custom_Buttons/issues/28
				//&& node.boxObject
				//&& node.boxObject instanceof Components.interfaces.nsIMenuBoxObject
				&& "open" in node
				&& node.open
				&& node.getElementsByTagName("menupopup").length
				&& this.undoCloseTabsList.drawUndoList()
			) {
				node.open = false;
				this.open = true;
				return true;
			}
			return false;
		},
		this
	);
	if(
		this.undoCloseTabsList.options.openMenuOnMouseover
		&& this.undoCloseTabsList.drawUndoList()
	)
		this.undoCloseTabsList.openMenu();
};

this.undoCloseTabsList = {
	button: this,
	options: options,
	mpId: this.id + "-context",
	cmId: this.id + "-contextSub",
	tcmId: this.id + "-tabContextMenu",
	tipId: this.id + "-tooltip",
	errPrefix: "[Custom Buttons :: Undo Close Tabs List]: ",
	get mp() {
		var btn = this.button;
		var mp = btn.getElementsByTagName("menupopup");
		mp = mp.length && mp[0];
		mp && mp.parentNode.removeChild(mp);
		mp = this.createElement("menupopup", {
			id: this.mpId,
			onclick: "this.parentNode.undoCloseTabsList.checkForMiddleClick(event);",
			onpopupshowing: "if(event.target == this) document.popupNode = this.parentNode;",
			onpopuphidden: "if(event.target == this) document.popupNode = null;"
		});
		if(this.cm)
			mp.setAttribute("context", this.cmId);
		var tb = btn.parentNode;
		if(
			this.options.useMenu
			&& tb.getAttribute("orient") == "vertical"
		) {
			// https://addons.mozilla.org/firefox/addon/vertical-toolbar/
			var isRight = tb.parentNode.getAttribute("placement") == "right";
			mp.setAttribute("position", isRight ? "start_before" : "end_before");
		}
		delete this.mp;
		return this.mp = btn.appendChild(mp);
	},
	get useCentextMenu() {
		delete this.useCentextMenu;
		return this.useCentextMenu = this.options.allowDeleteEntries
			&& ("forgetClosedTab" in this.ss || "forgetClosedWindow" in this.ss);
	},
	get cm() {
		delete this.cm;
		if(!this.useCentextMenu)
			return this.cm = null;
		var cm = document.getElementById(this.cmId);
		cm && cm.parentNode.removeChild(cm);
		cm = this.createElement("menupopup", {
			id: this.cmId,
			onpopupshowing: "return this.undoCloseTabsList.canDeleteUndoEntry(this.triggerNode || document.popupNode);"
		});
		var mi = this.createElement("menuitem", {
			oncommand: "this.parentNode.undoCloseTabsList.deleteUndoEntry(this.parentNode.triggerNode || document.popupNode);",
			label: _localize("deleteUndoEntry"),
			closemenu: "single"
		});
		cm.appendChild(mi);
		cm.undoCloseTabsList = this;
		return this.cm = document.getElementById("mainPopupSet").appendChild(cm);
	},
	get cbMenu() {
		var cbPopup = document.getElementById(this.button.defaultContextId);
		if(!cbPopup) {
			Components.utils.reportError(this.errPrefix + "cb menu not found");
			return this.cbMenu = null;
		}
		cbPopup = cbPopup.cloneNode(true);
		var id = "-" + this.button.id.match(/\d*$/)[0] + "-cloned";
		cbPopup.id += id;
		Array.prototype.slice.call(cbPopup.getElementsByAttribute("id", "*")).forEach(function(node) {
			node.id += id;
		});
		var menu = this.createElement("menu", {
			label: _localize("buttonMenu"),
			accesskey: _localize("buttonMenuAccesskey")
		});
		menu.appendChild(cbPopup);
		cbPopup.setAttribute(
			"onpopupshowing",
			'\
			var btn = document.popupNode = this.parentNode.parentNode.parentNode\n\
				.undoCloseTabsList.button;\n\
			custombutton.setContextMenuVisibility(btn);'
		);
		delete this.cbMenu;
		return this.cbMenu = menu;
	},
	get ss() {
		delete this.ss;
		return this.ss = "nsISessionStore" in Components.interfaces
			? (
				Components.classes["@mozilla.org/browser/sessionstore;1"]
				|| Components.classes["@mozilla.org/suite/sessionstore;1"]
			).getService(Components.interfaces.nsISessionStore)
			: SessionStore; // Firefox 61+ https://bugzilla.mozilla.org/show_bug.cgi?id=1450559
	},
	get appInfo() {
		delete this.appInfo;
		return this.appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
			.getService(Components.interfaces.nsIXULAppInfo);
	},
	get appVersion() {
		delete this.appVersion;
		return this.appVersion = parseFloat(this.appInfo.version);
	},
	get appName() {
		delete this.appName;
		return this.appName = this.appInfo.name;
	},

	init: function() {
		window.addEventListener("TabClose",       this, false);
		window.addEventListener("SSTabRestoring", this, false);
		window.addEventListener("unload",         this, false);
		if(this.appName == "SeaMonkey") // No SSTab* events in SeaMonkey
			window.addEventListener("TabOpen", this, false);
		setTimeout(function(_this) {
			_this.mp.addEventListener("DOMMenuItemActive",   _this, false);
			_this.mp.addEventListener("DOMMenuItemInactive", _this, false);
			_this.initTooltip();
		}, 50, this);
		this.addPbExitObserver(true);
		this.updUIGlobal();
		if(this.options.showInTabContextMenu) setTimeout(function(_this) {
			_this.initTabContext();
		}, 100, this);
	},
	initTabContext: function() {
		var origMi = this.tabContextUndoClose;
		if(!origMi) {
			LOG("Can't find \"Undo Close Tab\" item in tab context menu");
			return;
		}
		var menu = document.getElementById(this.tcmId);
		menu && menu.parentNode.removeChild(menu); // For SeaMonkey
		menu = this.createElement("menu", {
			id: this.tcmId,
			label: _localize("tabContextMenu"),
			accesskey: _localize("tabContextMenuAccesskey"),
			tooltip: this.tipId,
			popupsinherittooltip: "true"
		});
		menu.undoCloseTabsList = this;
		menu.onclick = function(e) {
			if(e.target != this)
				return;
			if(e.button == 1 || e.button == 0 && (e.ctrlKey || e.shiftKey || e.altKey || e.metaKey)) {
				if(this.undoCloseTabsList.closedTabCount) {
					this.undoCloseTabsList.undoCloseTab();
					closeMenus(this);
				}
			}
		};
		var origMp = this.mp;
		var mp = origMp.cloneNode(true);
		mp.id = this.button.id + "-tabContext";
		var _this = this;
		function drawUndoList() {
			var ok = false;
			var opts = _this.options;
			var origTemplate = opts.menuTemplate;
			opts.menuTemplate = opts.menuTemplateTabContext || origTemplate;
			_this.mp = mp;
			try {
				ok = _this.drawUndoList();
			}
			catch(e) {
				Components.utils.reportError(e);
			}
			opts.menuTemplate = origTemplate;
			_this.mp = origMp;
			return ok;
		}
		function updMenu() {
			if(drawUndoList())
				menu.removeAttribute("disabled");
			else
				menu.setAttribute("disabled", "true");
		}
		mp._updatePopup = function(e) {
			if(e.target != this)
				return;
			document.popupNode = _this.button;
			drawUndoList();
		};
		mp.setAttribute("onpopupshowing", "this._updatePopup(event);");
		mp.onclick = function(e) {
			_this.checkForMiddleClick(e, updMenu);
		};
		menu.appendChild(mp);
		addEventListener("popupshown", function(e) {
			if(e.target == e.currentTarget)
				setTimeout(updMenu, 0); // Pseudo async
		}, false, origMi.parentNode);
		addEventListener("DOMMenuItemActive",   this, false, mp);
		addEventListener("DOMMenuItemInactive", this, false, mp);
		origMi.parentNode.insertBefore(menu, origMi.nextSibling);
		origMi.setAttribute("hidden", "true");
	},
	initTooltip: function() {
		var tip = document.getElementById(this.tipId);
		tip && tip.parentNode.removeChild(tip);
		tip = this.tip = this.createElement("tooltip", {
			id: this.tipId,
			orient: "vertical",
			onpopupshowing: "return this.undoCloseTabsList.updTooltip(this, document.tooltipNode);",
			onpopuphiding: "this.cancelUpdateTimer();"
		});
		tip.undoCloseTabsList = this;
		tip._updateTimer = 0;
		tip.initUpdateTimer = function(fn, context) {
			if(this._updateTimer)
				clearInterval(this._updateTimer);
			this._updateTimer = setInterval(function() {
				fn.call(context);
			}, 1000);
		};
		tip.cancelUpdateTimer = function() {
			if(this._updateTimer) {
				clearInterval(this._updateTimer);
				this._updateTimer = 0;
			}
		};
		var btn = this.button;
		btn.removeAttribute("tooltiptext");
		btn.setAttribute("tooltip", this.tipId);
		btn.setAttribute("popupsinherittooltip", "true");
		document.getElementById("mainPopupSet").appendChild(tip);
		if(this.appVersion >= 61 && "getAnonymousElementByAttribute" in document) {
			var label = document.getAnonymousElementByAttribute(tip, "class", "tooltip-label");
			label && label.remove();
		}
	},
	_hasPbExitObserver: false,
	addPbExitObserver: function(add) {
		if(add == this._hasPbExitObserver || !("Services" in window))
			return;
		this._hasPbExitObserver = add;
		if(add)
			Services.obs.addObserver(this, "last-pb-context-exited", false);
		else
			Services.obs.removeObserver(this, "last-pb-context-exited");
	},
	destroy: function() {
		window.removeEventListener("TabClose",       this, false);
		window.removeEventListener("SSTabRestoring", this, false);
		window.removeEventListener("unload",         this, false);
		if(this.appName == "SeaMonkey")
			window.removeEventListener("TabOpen", this, false);
		this.mp.removeEventListener("DOMMenuItemActive",   this, false);
		this.mp.removeEventListener("DOMMenuItemInactive", this, false);
		this.addPbExitObserver(false);
		var menu = document.getElementById(this.tcmId);
		if(menu) {
			menu.parentNode.removeChild(menu);
			this.tabContextUndoClose.removeAttribute("hidden");
		}
		var tip = this.tip;
		tip && tip.parentNode && tip.parentNode.removeChild(tip);
	},
	handleEvent: function(e) {
		switch(e.type) {
			case "TabClose":
			case "SSTabRestoring":
			case "TabOpen":
				setTimeout(function(_this) {
					_this.updUI();
				}, 0, this);
			break;
			case "DOMMenuItemActive":
			case "DOMMenuItemInactive":
				if(!("XULBrowserWindow" in window))
					break;
				XULBrowserWindow.setOverLink(
					e.type == "DOMMenuItemActive"
						? (e.target.getAttribute("cb_urlDecoded") || "")
							.replace(/ \n/g, ", ")
						: "",
					null
				);
			break;
			case "unload":
				this.updUIGlobal();
				this.destroy();
		}
	},
	observe: function(subject, topic, data) {
		if(topic == "last-pb-context-exited") {
			setTimeout(function(_this) {
				_this.updUI();
			}, 25, this);
		}
	},

	createElement: function(name, attrs) {
		var node = document.createElementNS(xulns, name);
		if(attrs) for(var attrName in attrs) if(attrs.hasOwnProperty(attrName))
			node.setAttribute(attrName, attrs[attrName]);
		return node;
	},
	get tabContextUndoClose() {
		return document.getElementById("context_undoCloseTab")
			|| document.getElementById("tabContextUndoCloseTab") // Firefox 2.0
			|| document.getAnonymousElementByAttribute(gBrowser, "tbattr", "tabbrowser-undoclosetab"); // SeaMonkey
	},
	get closedWindowCount() {
		if(!("getClosedWindowCount" in this.ss)) {
			delete this.closedWindowCount;
			return this.closedWindowCount = 0;
		}
		this.__defineGetter__("closedWindowCount", function() {
			return this.ss.getClosedWindowCount();
		});
		return this.closedWindowCount;
	},
	get closedTabCount() {
		return this.ss.getClosedTabCountForWindow(window);
	},
	undoCloseTab: function(i) {
		if("undoCloseTab" in window) // Firefox 2.0+
			undoCloseTab(i);
		else // SeaMonkey
			gBrowser.undoCloseTab(i);
	},
	clearUndoTabsList: function() {
		var closedTabCount = this.closedTabCount;
		if(!closedTabCount)
			return;
		if("forgetClosedTab" in this.ss) // Gecko 1.9.2+
			while(closedTabCount--)
				this.ss.forgetClosedTab(window, 0);
		else {
			// Doesn't work in SeaMonkey
			const pName = "browser.sessionstore.max_tabs_undo";
			let val = cbu.getPrefs(pName);
			cbu.setPrefs(pName, 0);
			cbu.setPrefs(pName, val);
		}
		this.updUIGlobal();
	},
	clearUndoWindowsList: function() {
		var closedWindowCount = this.closedWindowCount;
		if(!closedWindowCount)
			return;
		if("forgetClosedWindow" in this.ss) // Gecko 1.9.2+
			while(closedWindowCount--)
				this.ss.forgetClosedWindow(0);
		else
			this.ss.setWindowState(window, '{"windows":[{}],"_closedWindows":[]}', false);
		this.updUIGlobal();
	},
	clearAllLists: function() {
		this.clearUndoTabsList();
		this.clearUndoWindowsList();
	},
	canDeleteUndoEntry: function(mi) {
		switch(mi.getAttribute("cb_type")) {
			case "tab":    return "forgetClosedTab"    in this.ss;
			case "window": return "forgetClosedWindow" in this.ss;
		}
		return false;
	},
	deleteUndoEntry: function(mi) {
		var i = +mi.getAttribute("cb_index");
		if(mi.getAttribute("cb_type") == "window") {
			this.ss.forgetClosedWindow(i);
			this.updUIGlobal();
		}
		else {
			this.ss.forgetClosedTab(window, i);
			this.updUI();
		}
		this.drawUndoList();
	},
	showMenu: function(e, isContext, mp) {
		var btn = this.button;
		document.popupNode = btn.ownerDocument.popupNode = btn;
		if(!mp)
			mp = this.mp;
		if("openPopupAtScreen" in mp)
			mp.openPopupAtScreen(e.screenX, e.screenY, isContext);
		else
			mp.showPopup(btn, e.screenX, e.screenY, isContext ? "context" : "popup", null, null);
	},
	openMenu: function() {
		var mp = this.mp;
		if("openPopup" in mp)
			mp.openPopup(this.button, "after_start");
		else
			mp.showPopup(this.button, -1, -1, "popup", "bottomleft", "topleft");
	},
	drawUndoList: function() {
		var mp = this.mp;

		var wc = this.closedWindowCount;
		var tc = this.closedTabCount;
		var ss = this.ss;
		var canRestoreLastSession = "restoreLastSession" in ss && ss.canRestoreLastSession
		if(!wc && !tc && !canRestoreLastSession) {
			mp.textContent = "";
			mp.hidePopup();
			return false;
		}

		this._undoWindowItems = wc && JSON.parse(ss.getClosedWindowData());
		this._undoTabItems    = tc && JSON.parse(ss.getClosedTabDataForWindow(window));
		var df = document.createDocumentFragment();

		this.options.menuTemplate.forEach(function(sid, indx, arr) {
			switch(sid) {
				case "closedWindows":
					wc && this.addUndoWindowsList(df);
				break;
				case "restoreClosedWindows":
					wc > this.options.hideRestoreAllForSingleEntry
					&& df.appendChild(this.createElement("menuitem", {
						label: _localize("restoreAllWindows"),
						accesskey: _localize("restoreAllWindowsAccesskey"),
						oncommand: "for(var i = 0; i < " + this._undoWindowItems.length + "; ++i) undoCloseWindow();"
					}));
				break;
				case "clearClosedWindows":
					wc && df.appendChild(this.createElement("menuitem", {
						label: _localize("clearWindowsHistory"),
						accesskey: _localize("clearWindowsHistoryAccesskey"),
						oncommand: "this.parentNode.parentNode.undoCloseTabsList.clearUndoWindowsList();"
					}));
				break;
				case "closedTabs":
					tc && this.addUndoTabsList(df);
				break;
				case "restoreClosedTabs":
					tc > this.options.hideRestoreAllForSingleEntry
					&& df.appendChild(this.createElement("menuitem", {
						label: _localize("restoreAllTabs"),
						accesskey: _localize("restoreAllTabsAccesskey"),
						oncommand: "for(var i = 0; i < " + this._undoTabItems.length + "; ++i) this.parentNode.parentNode.undoCloseTabsList.undoCloseTab();"
					}));
				break;
				case "clearClosedTabs":
					tc && df.appendChild(this.createElement("menuitem", {
						label: _localize("clearTabsHistory"),
						accesskey: _localize("clearTabsHistoryAccesskey"),
						oncommand: "this.parentNode.parentNode.undoCloseTabsList.clearUndoTabsList();"
					}));
				break;
				case "clearAll":
					(
						wc && tc
						|| wc && arr.indexOf("clearClosedWindows") == -1
						|| tc && arr.indexOf("clearClosedTabs") == -1
					)
					&& df.appendChild(this.createElement("menuitem", {
						label: _localize("clearAllHistory"),
						accesskey: _localize("clearAllHistoryAccesskey"),
						oncommand: "this.parentNode.parentNode.undoCloseTabsList.clearAllLists();"
					}));
				break;
				case "restoreLastSession": // Gecko 2.0+
					canRestoreLastSession && df.appendChild(this.createElement("menuitem", {
						label: _localize("restoreLastSession"),
						accesskey: _localize("restoreLastSessionAccesskey"),
						oncommand: "this.parentNode.parentNode.undoCloseTabsList.ss.restoreLastSession();"
					}));
				break;
				case "buttonMenu":
					let cbMenu = this.cbMenu;
					if(cbMenu)
						df.appendChild(cbMenu);
				break;
				case "separator":
					if(df.hasChildNodes() && df.lastChild.localName != "menuseparator")
						df.appendChild(document.createElementNS(xulns, "menuseparator"));
				break;
				default:
					Components.utils.reportError(this.errPrefix + 'Invalid template entry: "' + sid + '"');
			}
		}, this);

		while(df.hasChildNodes() && df.lastChild.localName == "menuseparator")
			df.removeChild(df.lastChild);

		this._undoWindowItems = this._undoTabItems = null;

		mp.textContent = "";
		if(!df.hasChildNodes()) {
			mp.hidePopup();
			return false;
		}
		mp.appendChild(df);
		return true;
	},
	addUndoWindowsList: function(undoPopup) {
		// Based on code from chrome://browser/content/browser.js
		// Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.3a1pre) Gecko/20090824 Minefield/3.7a1pre

		var keys = this.options.accesskeys.closedWindows;
		this._undoWindowItems.forEach(function(undoItem, i) {
			var tabs = undoItem.tabs;
			var [key, keyPrefix] = this.getKey(keys, i);
			var title = undoItem.title;
			var selectedTab = tabs[undoItem.selected - 1];
			var urls = [];
			tabs.forEach(function(tab) {
				if(!tab.entries || !tab.entries.length) // Can be [] for about:blank
					return;
				var url = this.convertURI(tab.entries[tab.index - 1].url, 120);
				var selectedPrefix = tab == selectedTab && tabs.length > 1
					? this.options.windowSelectedTabPrefix
					: "";
				urls.push(selectedPrefix + url);
			}, this);
			var url = urls.join(" \n");
			var mi = this.createElement("menuitem", {
				label: keyPrefix + this.options.windowItemTemplate
					.replace("%title", title)
					.replace("%count", tabs.length),
				accesskey: key,
				"class": "menuitem-iconic bookmark-item menuitem-with-favicon",
				oncommand: "undoCloseWindow(" + i + ");",
				cb_url: url,
				cb_urlDecoded: this.convertURI(url),
				cb_closedAt: undoItem.closedAt || 0,
				cb_index: i,
				cb_type: "window"
			});
			if(this.cm)
				mi.setAttribute("context", this.cmId);
			var icon = selectedTab.image || selectedTab.attributes && selectedTab.attributes.image;
			if(icon)
				mi.setAttribute("image", this.cachedIcon(icon));
			if(i == 0)
				mi.setAttribute("key", "key_undoCloseWindow");
			undoPopup.appendChild(mi);
		}, this);
	},
	addUndoTabsList: function(undoPopup) {
		// Based on code from chrome://browser/content/browser.js
		// Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.3a1pre) Gecko/20090824 Minefield/3.7a1pre

		var keys = this.options.accesskeys.closedTabs;
		this._undoTabItems.forEach(function(undoItem, i) {
			var state = undoItem.state;
			var [key, keyPrefix] = this.getKey(keys, i);
			var title = undoItem.title;
			var url = state && state.entries && state.entries[state.index - 1].url || "";
			var mi = this.createElement("menuitem", {
				label: keyPrefix + title,
				accesskey: key,
				class: "menuitem-iconic bookmark-item menuitem-with-favicon",
				oncommand: "this.parentNode.parentNode.undoCloseTabsList.undoCloseTab(" + i + ");",
				cb_url: url,
				cb_urlDecoded: this.convertURI(url),
				cb_closedAt: undoItem.closedAt || 0,
				cb_index: i,
				cb_type: "tab"
			});
			if(
				state
				&& "attributes" in state
				&& "privateTab-isPrivate" in state.attributes
			) // https://addons.mozilla.org/addon/private-tab/
				mi.setAttribute("privateTab-isPrivate", "true");
			if(this.cm)
				mi.setAttribute("context", this.cmId);
			var image = undoItem.image // Firefox
				|| state && state.attributes && state.attributes.image // SeaMonkey
				|| state && state.xultab
					&& /(?:^| )image=(\S+)/.test(state.xultab)
					&& decodeURI(RegExp.$1); // Only Firefox 2.0 ?
			if(image)
				mi.setAttribute("image", this.cachedIcon(image));
			if(i == 0)
				mi.setAttribute("key", "key_undoCloseTab");
			undoPopup.appendChild(mi);
		}, this);
	},
	getKey: function(keys, i) {
		var key = keys && keys.charAt(i % keys.length);
		var keyPrefix = keys && (key + this.options.accesskeySeparator);
		return [key, keyPrefix];
	},
	checkForMiddleClick: function(e, upd) {
		var mi = e.target;
		if(
			"doCommand" in mi
			&& e.button == 1
			&& mi.parentNode == e.currentTarget
		) {
			mi.doCommand();
			if(upd)
				upd();
			else
				this.drawUndoList();
		}
	},
	crop: function(s, crop) {
		if(crop == undefined)
			crop = 500;
		if(s.length <= crop)
			return s;
		var start = Math.round(crop*0.6);
		return s.substr(0, start) + "…" + s.substr(start - crop);
	},
	convertURI: function(uri, crop) {
		if(!uri || uri.indexOf("\n") != -1)
			return uri;
		uri = this.losslessDecodeURI(uri);
		return this.crop(uri, crop);
	},
	losslessDecodeURI: function(uri) {
		if(uri) try {
			return this._losslessDecodeURI(uri);
		}
		catch(e) {
			Components.utils.reportError(e);
		}
		return uri;
	},
	get _losslessDecodeURI() {
		var ldu;
		if("losslessDecodeURI" in window)
			ldu = losslessDecodeURI;
		else if("UrlbarInput" in window) // Firefox 75+
			ldu = Components.utils.import("resource:///modules/UrlbarInput.jsm", {}).losslessDecodeURI;
		delete this._losslessDecodeURI;
		return this._losslessDecodeURI = ldu
			? function(uri) {
				return ldu(makeURI(uri));
			}
			: decodeURI;
	},
	cachedIcon: function(src) {
		src = src.replace(/[&#]-moz-resolution=\d+,\d+$/, ""); // Firefox 22+
		if(
			!/^https?:/.test(src)
			// IDN, see https://bugzilla.mozilla.org/show_bug.cgi?id=311045
			|| /^https?:\/\/[^.:\/]+\.[^a-z0-9-]+(?:\/|$)/.test(src)
			|| this.appName == "SeaMonkey" && this.appVersion <= 2
			|| this.appName == "Firefox"   && this.appVersion <= 3.5
		)
			return src;
		return "moz-anno:favicon:" + src; // https://bugzilla.mozilla.org/show_bug.cgi?id=467828
	},
	updUI: function() {
		var tabsCount = this.closedTabCount;
		var dis = !tabsCount && !this.closedWindowCount;
		if(
			dis
			&& this.options.useMenu
			&& this.options.menuTemplate.indexOf("restoreLastSession") != -1
			&& "restoreLastSession" in this.ss && this.ss.canRestoreLastSession
		)
			dis = false;
		this.button.disabled = dis;
	},
	updTooltip: function(tip, tn) {
		var template, header, title, url, closedAt;
		if(tn == this.button) {
			template = this.options.buttonTipTemplate;
			header = _localize("restoreTab");
			let undoTabItems = JSON.parse(this.ss.getClosedTabDataForWindow(window));
			if(undoTabItems.length) {
				let lastItem = undoTabItems[0];
				title = lastItem.title;
				url = lastItem.state && lastItem.state.entries
					&& lastItem.state.entries[lastItem.state.index - 1].url;
				closedAt = lastItem.closedAt || 0;
			}
		}
		else if(tn.hasAttribute("cb_index")) {
			template = this.options.itemTipTemplate;
			title = tn.getAttribute("label");
			url = tn.getAttribute("cb_url");
			closedAt = +tn.getAttribute("cb_closedAt");
		}
		else {
			return false;
		}

		var tipData = this.getTooltipData(template, header, title, url, closedAt);
		tip.textContent = "";
		tip.appendChild(tipData);
		if(closedAt && template.indexOf("closedAt") != -1) {
			tip.initUpdateTimer(function() {
				var tipData = this.getTooltipData(template, header, title, url, closedAt);
				if(tipData.textContent != tip.textContent) {
					tip.textContent = "";
					tip.appendChild(tipData);
				}
			}, this);
		}
		return tip.hasChildNodes();
	},
	getTooltipData: function(template, header, title, url, closedAt) {
		var df = document.createDocumentFragment();
		var hasHeader = header && template.indexOf("header") != -1;
		function item(key, val) {
			var lbl = document.createElementNS(xulns, "label");
			lbl.className = "cb-" + key + " tooltip-label";
			lbl.textContent = val;
			lbl.setAttribute("maxwidth", "450"); // Trick to restore right border for long lines
			if(key == "closedAt" || hasHeader && key != "header")
				lbl.style.color = "grayText";
			return df.appendChild(lbl);
		}
		template.forEach(function(key) {
			switch(key) {
				case "header":
					if(header)
						item(key, header);
				break;
				case "title":
					if(title && title != url)
						item(key, title);
				break;
				case "url":
					if(url)
						item(key, this.convertURI(url));
				break;
				case "closedAt":
					if(!closedAt)
						break;
					let dt = Math.round(Math.max(0, Date.now() - closedAt)/1000);
					let days = Math.floor(dt/24/3600);
					dt -= days*24*3600;
					let d = new Date((dt + new Date(dt).getTimezoneOffset()*60)*1000);
					let m = d.getMinutes();
					let ts = d.getHours() + ":" + (m > 9 ? m : "0" + m);
					if(days)
						ts = days + _localize("day") + " " + ts;
					let tsTip = _localize("itemTip")
						.replace("%ago", ts)
						.replace("%date", new Date(closedAt).toLocaleString());
					item(key, tsTip);
			}
		}, this);
		return df;
	},
	get wm() {
		delete this.wm;
		return this.wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
			.getService(Components.interfaces.nsIWindowMediator);
	},
	updUIGlobal: function() {
		var isSeaMonkey = this.appName == "SeaMonkey";
		var ws = this.wm.getEnumerator(isSeaMonkey ? null : "navigator:browser");
		const id = this.button.id;
		while(ws.hasMoreElements()) {
			let win = ws.getNext();
			if(isSeaMonkey && !this.isBrowserWindow(win))
				continue;
			let btn = win.document.getElementById(id);
			if(btn && "undoCloseTabsList" in btn) {
				let ucl = btn.undoCloseTabsList;
				ucl.ensureSessionsInitialized(ucl.updUI, ucl);
			}
		}
	},
	isBrowserWindow: function(win) {
		var loc = window.location.href;
		return loc == "chrome://browser/content/browser.xul"
			|| loc == "chrome://navigator/content/navigator.xul";
	},
	ensureSessionsInitialized: function(callback, context) {
		var _this = this;
		var stopTime = Date.now() + 3e3;
		(function ensureInitialized() {
			try {
				_this.ss.getClosedTabCountForWindow(window);
				callback.call(context);
				return;
			}
			catch(e) {
				if(Date.now() > stopTime) {
					Components.utils.reportError(
						_this.errPrefix
						+ "Can't initialize: nsISessionStore.getClosedTabCountForWindow() failed"
					);
					Components.utils.reportError(e);
					return;
				}
			}
			setTimeout(ensureInitialized, 50);
		})();
	}
};

if(!this.undoCloseTabsList.options.useMenu && this.undoCloseTabsList.useCentextMenu) {
	this.oncontextmenu = function(e) {
		if(
			e.target != this
			|| e.ctrlKey || e.shiftKey || e.altKey || e.metaKey
			|| !this.undoCloseTabsList.mp.hasChildNodes()
		)
			return;
		e.preventDefault();
		this.undoCloseTabsList.showMenu(e); // Show menu without "context" flag
	};
}
if(this.undoCloseTabsList.options.rightClickToUndoCloseTab) {
	this.oncontextmenu = function(e) {
		if(e.target == this && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey)
			e.preventDefault();
	};
}

this.disabled = true;
setTimeout(function(_this) {
	_this.undoCloseTabsList.init();
}, 0, this);

//===================
// Styles
// Used icons from Undo Closed Tabs Button extension

// Styles can't override hardcoded icon
if( // Remove icon only if nsIStyleSheetService works on-the-fly (Firefox 3.0+)
	!Components.ID("{41d979dc-ea03-4235-86ff-1e3c090c5630}")
		.equals(Components.interfaces.nsIStyleSheetService)
) {
	let icon = this.icon
		|| this.ownerDocument.getAnonymousElementByAttribute(this, "class", "toolbarbutton-icon");
	if(icon)
		icon.removeAttribute("src");
	else
		this.image = "";
}

var cssStr = '\
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");\n\
	@-moz-document url("%windowURL%") {\n\
		%button% {\n\
			list-style-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAEEUlEQVRIS9XVbWxTVRgA4Pfce3tv27t2bbNuXbfCBuyzAZ2MEdkkLH5gJvEH8TOZEo0JFdgmbgjTgEHUGQXGMJEMmDJMiNvQjS9BJhH8MY3IfsB0rnTraCcbm13b2+/1fni2xAVuxOHAH57+adNz3uee9z3vuQj+44FmG79VksglAIoMgBhCSLpdnFkBkiQxl2OQgRdbJhjoKkQofM+ALklSGSNwf1iAjbXNZ3MdI+MB+7vPF989IEnoZwBVQhCWBgVhW13b+WX5KXpFR7fDe/ntZ8wYiONUiXLojlKEU4LGANgRDpZHBH7r9iPnilZaM4jKFTlQ/P5XvHV+6o5si7HzuWUL+hzngSstRfxf0DSwa9cHa3GgWgmQTv4UNMMggyWTMuYtYepOXCKfKMiGZ4tyQEMDjPrDcGVoDI780As3/AGhJIVs2vTk6pqkJAhOFn8KaG1tpV1u53h5+RpGr7s1/uTxCIgk6g/EiaqmM2i5NRseL7SCgwMg8Wo9A5CsBLjPADDki8CbbRdgQiI631n/2NOFANwUUF9frxPECVf1628gn893Sx55IIhxBavcffIi1fO7H15atRJiAoD8XBI4UmYCwOIkCdY3fyuyrGrHZ+UldXJAwoDn5hThQESYpNXXQpJuw4HTiuzM+fBAfu7UFIQ/0wN/nfydrEKwSCdARfMZftVSa6kcEPx+v0NeA7wlKowYXX+AT604+DWTmT4XcufhFsN6r9MJ/gAHiVotpBmNoNNoIctAw8Xf7FKMjx2TA7zX6/3p7860SBCKEGJSBrj4PIyozMkm0KhZsDv7hTUP5Xt+HfFpuvqGVBZTKizEuOePEYiL0V/kQJzjuG9u1zS8RDAhRFv6/FFr5YFTaopicJGRt932yDmJQLQ3JpY9+lEHVZCTB6PecTAmEMNyIIZr8MU/3U8iSSo5RGfZPZGFFftPaU0a9dgxW+mXBEGQtJJ5xbq1hUo3mdENzxjYyoq65UAUA5/MdAGKiFQHSGbB1WEPDZGIq3COYRQD1I/XPJttn39PKRlWYpUgfvraU2/JgXAwGHxvRkAUEd6JAteYJAUhioNLwaigLN1z8sNQLA5mQyK//YWHr8zRaV9EjY2NikDAuwkQ2oL7IIRH9UzATf9PPuBUS4gIKY92u/Zf5zhixaKsAa1BXzOhhrNoz96d21JNaavT0tO9xQ+W5GDg5X8BTE/lCSIBUcqW3kGX3XW1Jz7sdtVXrn31EGpo2Nm0bl1VHt7maTw7Eo1GL8wGwPcOiRSKMpIgUpzOAd2JjqOdNTW1B1HDx7ttlRs2mnCDHZ5NYPkalmXnut3uxe3tbZeqqzd/h/bt21tgs1WocYP13AtAr9cnDg4Omo8fb7leVbXFdUfvg7uB///An8idyhRIYoVPAAAAAElFTkSuQmCC") !important;\n\
		}\n\
		%button%:hover {\n\
			list-style-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAECUlEQVRIS9XVe2xTVRgA8O/ce3tv310fa8P6AOoapwznYtXFzchQJNEYNTHEODSaYLK4jsEaGcQnEpAQu8r+WLJMMmOMIQXnNgeKYTJjfBGzMEGTztVubcGmD9q1t+263t7r2Qxka8DhwD88//SP2/P97vd95zsXwX+80ErjC4JAjE4BvWEN5BFCwvXirAjAwWkfgIVjwczK4Sc7QtlbBpwRBLG+ADVcDnbu+fjUHZMX4+mJA00NNw8IAvoZQKIEsLOp4pv7PaMP2jRKanjclzi/99kKDBSuVaobKhEuCYoCyKIZaMjOcW+89clIXe1qA9H80Hp4uqu/UGszvlNl1J/eVF/pjY9CurERcVcyugq4XAdf5gXowP2SL00XAUkzSGteSxuq7LIDw2Miu9UET9y7DhgSwHcpAhN/RuHrC34QeJ57wED17nryqQ6dDtj5jBYAj8dDB4L+WNNzz0uUStWS+PPHI4so5EtzRNuRL9Hday1QX22D6RkOSLxbShGgZAgwKSiYjsTgo2/GQCGTfbXP8egWO0BqAXC73WVFfi7gbN+Fkskkv1jggCAui2Ri1/BZ6pfpGGy+7x7IFnjA2f69rvziSDopBUY5Cd1ffMtXmfX7+rY2vFsKCBiILwbwfiJL0tIpVihz9J4UlWvL4TaTaWnwRZaMJkFOzMFnP5zjmhprG0uB4szMzGTpkcMImQFG7csUV7X2nmA0ZRow6w2Amw/BSARmZ3MgFotBi8srk0iAERHweygkVBoUg6UAl0gkzl7rTPMEIcogxuBPcVbHByckKrkKJIwYwtFw8cUN1bFfLyaU33uDEp1KDQatDkLRCNy+SnGhFCikUqlT1xsaTiCYDKLNE+n8ndt7Tkp5QKhcKkoMtTwyUgREx7LcY5tdg5TNtBoSbBos5ZJLpUAe9+DoP91PHEmKWUTbJpP59Y7uIYVBKY0NNm/8lCAIkqBE22re9lB6rR7FUwl45fH7x0qBWQx0L3cB8oiUpkmm0h9JiIRsNlBrUkcxQI14w7udx34kxIwE9wLxfW3P7CkFsizL7l8W4HnEk6RovvlksTiLgwvJXEG6sXP4YJ4rQoVGxe3d+vC41ax8AfX09IhS7OXXEBDteA4yeDmXAxY9n3/BhUnApvjoOX9vPJODhnXWKbVWsyMlhdOo8/1Dr1tMa7YYjRWpurp6KwZe+hfA1b/iAyAHmvZ4g0Ff0PtbLhzwH25pbulDne5DPa2OnXfhNAeLON1CofDdSgB875Akw2zCKZn8f0xKhz4fGH21veMIch9+b9uO7U4LHrAPVxK4dI9MJrMGAoHqgYHj405nxxnU1eWqaW1tV+ABO38rALVaXRYK+Q39/Z5wW9vuwA19D24G/v8DfwHJNM8naEZRUgAAAABJRU5ErkJggg==") !important;\n\
		}\n\
		%button%[disabled="true"] {\n\
			list-style-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADCklEQVRIS9WVz0sbQRTHZ3Y32awxYkOIMaQQjBJ026zVVLCeCpX2H2jpqaceSjGnUpBcKj0IpVA81UtLT4VCoYdepJcapBYKGjfNbwNqTGJsbGKi5pdmd/s2tEVCjBrroQMLw8x77/Pem+/MYnTOA59zfHQmwPj4+AWCIG5OTk6+OyrRpgFOp7MTgn6pVCpdLS0t9MTExH49SFMACNaFMZ7v6enRRSKRiiRJnbCWbQgAI8LjWbyBMaFtdC7r67GLwWD4CQRnLBYL4XK5yoIgbKpUqkB7e9u3oSHrlMViz/2J8bcCnl/8TJCUmVJQW0cB0ls/W91u3gqDNBqNVTNoEcrlcmhnZwdtJDdEiqSEUql0zeFwLMj7VYDf728t7xdTV/oHFeBQrAdIJpPkzMwMA5ljnU5XNwfoAgI7tLKyUhJF0T42NuavApaWltolJEQBQGWz2Xw971gsRvM8r+nr68NKpbKhulOplBSNRldBYWwtgNze3o4d5b28vKxdW1vTQRWEQqFoCIEqCtC26VoAARV4GnkCxJRIJExms5mEgeLxuJDP5wmKokSNRkNotVosw/f29hDYLdQCMABcx91ukKYV2mAxGAykDBgZGflUKBQYCHoVMlebTCYMypLh8VoA2t3d/XAcQN4Ph8P2TCbTC1NxeHj4rbwGFYzOuma1jIphoCKUTqdjtQAJAK9PApBtoF3Xi8WimeO4N78Bt+fm5vRqtZqGivIHBwePawEiaPr5SQFVncPNBHmK8hza4giFQx0KSlGB4D/0en13LUAAgPM0gMO2cKhTcA40yNMN79Moy7IZ7PV6OyrC/iuMkZ2zDSgB8KBZADwXz4KhgIAkKQECe2SzDS5ij8c9beg03tK0tpUZhtHANb93BsAU+KvyhXwlHl+f7+cG7uPvPv7FZZazQv9eQi+Fcrm82SyApmk9nIkK/B8GAr6vNlv/U+wL+O6yvawR1PC+2cCH/QBAwlNyJxTyhViW+4gjEa+lu/sSA0ar/wIgCwu+rmAwmIN3K9rUD+c0ifz/gF/LJ4uAUJQHTwAAAABJRU5ErkJggg==") !important;\n\
		}\n\
		toolbar[iconsize="small"] %button% {\n\
			list-style-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACPElEQVQ4T2NkIBL8//+fEQj+oytnJEY/UDPXzPOPTdINZQ+jG0LQgPvv/wvsvf9k54FzN432X39S9rQ3oR/ZUrgBvb29akxMf7mQJcWVNYTeCWvOfvrijVK9nymDRevqKwqsfxdYiLDNqUgP+whSCzZg4sS+dkYmxlx2NrYfMAM4efiYXonr8Z27/4q52NeGQZiLlYGd4Q/D9iuPGDafu/3/zZevvocrwraCDZgwoWd/QECwtbi4xD8QHxRS178xsPq2LmfKC/FlEBAUYfgDFORlZWCQ52FgUOP5zVCz9sjfiw/eKMENCAwMMeXl5XsMc8FPJhbOjv235A5fe8zoZWvLwMTIxPD45UsGPm5uBiVxQQZN7u8MnVtPXUN2gbGAgOAJpDBg/MrIKtCy/bLRsVtPmXi4uBj+/fn2+9vPvyycHJyMLgZaDAcvXPoFN8A/IMhIUEBoLUoIA+Ps4382qfotZ112nL3JVOyieyjdQYfXuGWtgbCgCOOnzx//IrvAgJ9fYDKWdMH4mYlduX/HOa0AHamD3Jyc5v5TtptzsrMzeBmrXWKcNGkS399/Pw8GBoTIA71QgSNhwaL7/9zjdzN6d10wdDdR/5XrbWbNOHvOjA18fHwmTo6ubECQQChlcnBzR5y9/yT4wcVTb1+/fW7DuGjR3EXR0QlfgMn16N+/fy8TMoCJiUkCiK0PHNqvduXSuTrGNWtWugcHh737+PHjHUKaYfL8/Pyip04dV7tw4dBhgnmBkKEUGwAAgK/XtUYSNDQAAAAASUVORK5CYII=") !important;\n\
		}\n\
		toolbar[iconsize="small"] %button%:hover {\n\
			list-style-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACRElEQVQ4T2NkIBr8Z2RgYPyPrhwoSBj8//+fbfXt11phqqIXGRhRDSFoAFAzz8KLzzdvP3nZ+titFwWPe+OnIVsJN6BnSo88ww8GTmRJBRUV/jeSuvOOXL6nVeJuxBA3Z+cZWfY/M0x1BZc3+Pp+A6kFGzBxYm8T0GnFrKwsP2AGsHPyMH2RNebdfukxc6KLOYMAFzvDq3fvGC49fMFw+dGL/z9+/nQ7UBm+B2zAhIk9+3x9A2ylJKX/gfigkLr9jZHVt305Y4i9JQMbJy/Dn3//GbhZmRiEuVgYWP9+ZVh19MLfHz9/y0MMmNCz39cvwEJQQOgBzAU/mdg4m3dflTty7TGjkYYm2KmvP3xg4OLgYBDm42H48/09w/UnLy8hG2AuLCRyFCkMGL8ysAo0brtoeOzmEyZ2NjYGFsY/v7///sfCzMTCKCEiyvDo+dNfcAP8/AJNhYSEV6GEMCMj0BA2yaqNZ1x3nr/FlO+kfSTbSY/bqHmtAQ8PH+OPH9/+ohggKCjUhyVVMH5hYlfs3XFeO1BH8hAHB4d50NTt5pzs7AyuhioXGWfO7OD/9p35EDAQFcVExYuxJat///6BLWJiYvo/59jtjN5dF418zDV/ZbpZWDDOnTtzI7+AoLGDvSM3KytbFKF0ycHNHXnx/tPgW+dPvnn99qk948LF8+bFRMV/Aqa4Y9+/f79G0AAODjGgUywOHdivefHipUbGVetWOYUGhr778OEDPAoJGSIgICB87Ngh5bNnL54gmBcIGUaxAQAqY9puYCzN/wAAAABJRU5ErkJggg==") !important;\n\
		}\n\
		toolbar[iconsize="small"] %button%[disabled="true"] {\n\
			list-style-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAB70lEQVQ4T2NkoBAwEqu/vLzcjpOT81pDQ8MbZD1EGVBZWZn579+/qUxMTBXt7e1dGAbcv3+f4/2n9z6M//7zoLvo7NlzXh8+fPQTFxdnfwEEvPy8R+RlpWd4evruBakFu+DCpfNLONg4/NjZ2X4jG3D16jWup0+fsRsZGTGysLAwvH79muH9+/cMQHMY2NjY8jMzMyfBDNivrKhs+f8/wy+YAb9+/WJcs2YNj66uLgMvLy+Kw75//85w6dKl74yMjNZwAxQVlEz//f13D1nlgwcPBG/evCmloqLCBFQMth1oMwMfHx/Dx48f/z99+vQssgHGDP8ZjqCHwd27d+UfP36szs7ODvLGO2BAcgNdwCEhIcH46NGjt8gGGP3/938VtmgFBrIB0N8mcnJyB1VVVbkOHjxgzMnJxfT169cnCAPklQyApk/AlS6ePXumJSQk9ACoxuHKlStmQPonUG0e4+XLl8X//v29V0lJWQoYKaWEEtaXL1/SgX43AQbJWhMT01DGq9ev7ODm4tKWEJdi+/PnTxwhA4CpMfz161e+79+/e/f7919Pxtu3b85RUlJ5+////8PAwLlPyAAODg5BoPONXr16YfDmzbtWxseP79vLyCgAY+j9Q0KaYfJAVwgCA1DpzZs3p4nKC/gMptgAAO1G2FJifkXnAAAAAElFTkSuQmCC") !important;\n\
		}\n\
	}'
	.replace(/%windowURL%/g, window.location.href)
	.replace(/%button%/g, "#" + this.id);
var cssURI = this.cssURI = Components.classes["@mozilla.org/network/io-service;1"]
	.getService(Components.interfaces.nsIIOService)
	.newURI("data:text/css," + encodeURIComponent(cssStr), null, null);
var sss = this.sss = Components.classes["@mozilla.org/content/style-sheet-service;1"]
	.getService(Components.interfaces.nsIStyleSheetService);
if(!sss.sheetRegistered(cssURI, sss.USER_SHEET))
	sss.loadAndRegisterSheet(cssURI, sss.USER_SHEET);


this.onDestroy = function(reason) {
	this.undoCloseTabsList.destroy();
	if(reason == "destructor") // May happens before "unload"
		this.undoCloseTabsList.updUIGlobal();
	if(reason == "update" || reason == "delete") {
		let sss = this.sss;
		let cssURI = this.cssURI;
		if(sss.sheetRegistered(cssURI, sss.USER_SHEET))
			sss.unregisterSheet(cssURI, sss.USER_SHEET);
	}
};
if(this.undoCloseTabsList.options.useMenu) {
	this.type = "menu";
	this.orient = "horizontal";
}

Отсутствует

 

№13831-03-2024 20:36:36

kokoss
Участник
 
Группа: Members
Зарегистрирован: 15-02-2018
Сообщений: 1739
UA: Firefox 115.0

Re: [CB]Undo Close Tabs

Alex_one пишет

Само собой, но для этого использую скрипт.
скрытый текст

Этот способ не всегда срабатывает, а способ с удалением папки startupCache всегда!


Win7

Отсутствует

 

№13901-04-2024 12:21:11

Alex_one
Участник
 
Группа: Members
Зарегистрирован: 27-09-2015
Сообщений: 151
UA: Firefox 115.0

Re: [CB]Undo Close Tabs

ifln пишет

У меня предыдущая версия работает. Но там я что-то редактировал.

Да, Ваша версия завелась drinks.gif


kokoss пишет

способ с удалением папки startupCache всегда!

Понял, буду знать.


Ребят, всем большое спасибо за помощь!
thank-you.gif

Отсутствует

 

Board footer

Powered by PunBB
Modified by Mozilla Russia
Copyright © 2004–2020 Mozilla Russia GitHub mark
Язык отображения форума: [Русский] [English]