Gerne, freut mich wenn jemand das brauchen kann.
all:
Dieses Script funktioniert hier ab Firefox 95 auch nicht mehr:
UndoCloseTabButtonN.uc.js
CSS
// ==UserScript==
// @name UndoCloseTabButtonN
// @description 閉じたタブを復元するツールバーボタン&タブバーの空き上の中クリックで最後に閉じたタブを復元
// @version 1.2.5
// @include main
// @charset UTF-8
// @note 2019/01/23 Fx66でタブバー中クリックが効かないのを修正
// @note 2019/07/04 Fx69
// @note 2019/09/03 Fx70
// @note 2019/12/09 Fx72
// ==/UserScript==
// アイコン初期位置はタブバーです
(function() {
"use strict";
const useTabbarMiddleClick = true; // タブバーの空き・タブ追加ボタン上の中クリックで最後に閉じたタブを復元するか?
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
window.ucjsUndoCloseTabButtonService = {
prepareMenu(event) {
const doc = (event.view && event.view.document) || document;
const menu = event.originalTarget;
this.removeChilds(menu);
// 閉じたタブ
let data = JSON.parse(SessionStore.getClosedTabData(window));
const tabLength = data.length;
for (let i = 0; i < tabLength; i++) {
const item = data[i];
const m = this.createFaviconMenuitem(doc, item.title, item.image, i, this.undoTab);
const state = item.state;
let idx = state.index;
if (idx == 0)
idx = state.entries.length;
if (--idx >= 0 && state.entries[idx])
m.setAttribute("targetURI", state.entries[idx].url);
menu.appendChild(m);
}
// 閉じたウィンドウ
data = JSON.parse(SessionStore.getClosedWindowData());
const winLength = data.length;
if (winLength > 0) {
if (tabLength > 0)
menu.appendChild(this.$C(doc, "menuseparator"));
menu.appendChild(this.$C(doc, "menuitem", {
disabled: true,
label: "Geschlossene Fenster"
}));
for (let i = 0; i < winLength; i++) {
const item = data[i];
let title = item.title;
const tabsCount = item.tabs.length - 1;
if (tabsCount > 0)
title += " (他:" + tabsCount + ")";
const tab = item.tabs[item.selected - 1];
const m = this.createFaviconMenuitem(doc, title, tab.image, i, this.undoWindow);
menu.appendChild(m);
}
}
if (tabLength + winLength === 0) {
/* menu.appendChild(this.$C(doc, "menuitem", {
disabled: true,
label : "履歴がありません"
}));*/
event.preventDefault();
}
},
createFaviconMenuitem(doc, label, icon, value, command) {
const attr = {
class: "menuitem-iconic bookmark-item menuitem-with-favicon",
label: label,
value: value
};
if (icon) {
if (/^https?:/.test(icon))
icon = "moz-anno:favicon:" + icon;
attr.image = icon;
}
const m = this.$C(doc, "menuitem", attr);
m.addEventListener("command", command, false);
return m;
},
undoTab(event) {
undoCloseTab(event.originalTarget.getAttribute("value"));
},
undoWindow(event) {
undoCloseWindow(event.originalTarget.getAttribute("value"));
},
removeChilds(element) {
const range = document.createRange();
range.selectNodeContents(element);
range.deleteContents();
},
onClick(event) {
if (event.button === 1) {
switch (event.originalTarget.localName) {
case "box": // -Fx65
case "scrollbox": // Fx66-
case "toolbarbutton":
event.preventDefault();
event.stopPropagation();
undoCloseTab();
break;
}
}
},
$C(doc, tag, attrs) {
const e = tag instanceof Node? tag: doc.createElementNS(XULNS, tag);
if (attrs) {
Object.entries(attrs).forEach(([key, value]) => e.setAttribute(key, value));
}
return e;
},
};
function run() {
if (useTabbarMiddleClick) {
gBrowser.tabContainer.addEventListener("click", ucjsUndoCloseTabButtonService.onClick, true);
}
const buttonId = "ucjs-undo-close-tab-button";
if (document.getElementById(buttonId)) {
return;
}
try {
Cu.import("resource:///modules/CustomizableUI.jsm");
CustomizableUI.createWidget({
id : buttonId,
defaultArea : CustomizableUI.AREA_TABSTRIP,
type : "custom",
onBuild : doc => {
const btn = ucjsUndoCloseTabButtonService.$C(doc, "toolbarbutton", {
id : buttonId,
class : "toolbarbutton-1 chromeclass-toolbar-additional",
type : "menu",
anchor : "dropmarker",
label: "Geschlossene Tabs",
tooltiptext: "Geschlossene Tabs wieder herstellen",
image : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAADRklEQVRYhcWV32tbZRjHc7ELL3bRP8ELL7zohTeCl70IijhEkJcWdmcdSFDBoWydlIZSsE7tLFLowLqs1YKpdCXM1bhhxM11SsuMZml2znkW94vRJO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ncontextmenu : "event.preventDefault();",
});
const menu = ucjsUndoCloseTabButtonService.$C(doc, "menupopup", {
tooltip : "bhTooltip",
popupsinherittooltip: "true",
oncontextmenu : "event.preventDefault();",
onpopupshowing : "ucjsUndoCloseTabButtonService.prepareMenu(event);",
});
btn.appendChild(menu);
return btn;
},
});
} catch (e) {}
}
if (gBrowserInit.delayedStartupFinished) {
run();
} else {
const OBS_TOPIC = "browser-delayed-startup-finished";
const delayedStartupFinished = (subject, topic) => {
if (topic === OBS_TOPIC && subject === window) {
Services.obs.removeObserver(delayedStartupFinished, topic);
run();
}
};
Services.obs.addObserver(delayedStartupFinished, OBS_TOPIC);
}
})();
Alles anzeigen
Es fügt in die Navbar eine Schaltfläche ein, über die sich die Liste mit den zuletzt geschlossenen Tabs in einem Popup Fenster öffnen lässt. Schaltfläche ist da aber es tut sich nichts bei klick. Keine Ahnung was da angepasst werden muss.
Mfg.
Endor