Alles Gute!
Beiträge von aborix
-
-
-
In UndoListInTabmenuToo.uc.js aus #57 funktioniert im Tab-Kontextmenü das Wiederherstellen kürzlich geschlossener Fenster nicht.
In folgender Version funktioniert auch das und von mir aus kann das Skript nach GitHub:
Code
Alles anzeigen// ==UserScript== // @name UndoListInTabmenuToo // @namespace http://space.geocities.yahoo.co.jp/gl/alice0775 // @description UndoListInTabmenuToo.uc.js // @include main // @compatibility Firefox 4.0 - 59 // @author Alice0775 // @version 2017/11/18 nsIPrefBranch to nsIPrefBranch // @version 2010/09/18 00:00 4.0b7pre // @version 2009/02/03 13:00 ツールチップにタブ内履歴を表示するようにした // @Note タブやコンテキストメニューにもUndoClose Tab Listを追加するもの // @OriginalCode browser.jsからpopulateUndoSubmenuを拝借し, ごにょごにょした // @version 2010/03/26 13:00 Minefield/3.7a4pre Bug 554991 - allow tab context menu to be modified by normal XUL overlays // @version 2010/03/15 00:00 Minefield/3.7a4pre Bug 347930 - Tab strip should be a toolbar instead // @version 2009/09/09 15:00 中クリック処理 // ==/UserScript== // @version 2009/09/03 22:00 Firegox3.7a1preで動かなくなっていたのを修正(Bug 489925. getElementById should not return anonymous nodes) // @version 2009/08/22 00:00 Firegox3.6 stringbandleの変更による // @version 2009/04/24 00:00 #394759 [Firefox:Session Restore]-Add undo close window feature // @version 2008/10/12 18:00 Fx3.0.4pre中クリックしたときメニューポップアップが閉じないおよびその他fix // @version 2007/10/05 10:00 var UndoListInTabmenu = { // -- config -- TABCONTEXTMENU : true , //Im Tabkontextmenü: anzeigen: true, nicht anzeigen: false CONTEXTMENU : true, //Im Hauptkontextmenü: anzeigen: true , nicht anzeigen: false // -- config end-- ss: null, get tabContext() { /* return document.getAnonymousElementByAttribute( gBrowser, "anonid", "tabContextMenu")|| gBrowser.tabContainer.contextMenu; */ return gBrowser.tabContainer.contextMenu; }, init: function(){ if (this.TABCONTEXTMENU){ //タブコンテキスト var tabContext = this.tabContext; this.makePopup(tabContext, null, "tabContextUndoList"); } if (this.CONTEXTMENU){ //コンテンツエリアコンテキスト var contextMenu = document.getElementById("contentAreaContextMenu"); var refItem = document.getElementById("context-sep-stop"); this.makePopup(contextMenu, refItem, "ContextUndoList"); } // get closed-tabs from nsSessionStore /* this._ss = Cc["@mozilla.org/browser/sessionstore;1"]. getService(Ci.nsISessionStore); */ this._ss = SessionStore; }, makePopup: function(popup, refItem, id){ var menu; //label /* const locale = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch).getCharPref("general.useragent.locale"); */ const locale = ''; if (this.getVer() > 3.0) { // "Recently Closed Windows" let idPrefix = id.substring(0, id.length - 15); menu = document.createElement("menu"); //menu.setAttribute("id", "historyUndoWindowMenu3"); menu.setAttribute("id", idPrefix + "HistoryUndoWindowMenu3"); menu.setAttribute("label", "K\u00FCrzlich geschlossene Fenster"); menu.setAttribute("accesskey", "F"); menu.setAttribute("disabled", "true"); popup.insertBefore(menu, refItem); /* this.historyUndoWindowPopup3 = menu = menu.appendChild(document.createElement("menupopup")); menu.setAttribute("id", "historyUndoWindowPopup3"); menu.setAttribute("onpopupshowing", "UndoListInTabmenu.populateUndoWindowSubmenu();"); */ var undoPopup = (document.createElement("menupopup")); undoPopup.setAttribute("id", idPrefix + "HistoryUndoWindowPopup3"); undoPopup.setAttribute("onpopupshowing", "UndoListInTabmenu.populateUndoWindowSubmenu(this);"); menu.appendChild(undoPopup); } //UndoClose Tab List 最近閉じたタブ const LABELTEXT = locale.indexOf("ja") == -1?"K\u00FCrzlich geschlossene Tabs":"\u6700\u8fd1\u9589\u3058\u305f\u30bf\u30d6"; //create menu menu = document.createElement("menu"); menu.setAttribute("label", LABELTEXT); menu.setAttribute("accesskey", "T"); if (id) menu.setAttribute("id", id); //menu.setAttribute("disabled", true); var menupopup = document.createElement("menupopup"); if (this.getVer()<3) { menupopup.setAttribute("onpopupshowing", "UndoListInTabmenu.populateUndoSubmenu(this);"); } else if (this.getVer()<3.6) { menupopup.setAttribute("onpopupshowing", "UndoListInTabmenu.populateUndoSubmenu3(this);"); } else { menupopup.setAttribute("onpopupshowing", "UndoListInTabmenu.populateUndoSubmenu36(this);"); } menu.appendChild(menupopup); popup.insertBefore(menu, refItem); //add event listener popup.addEventListener('popupshowing',function(event) { if (UndoListInTabmenu.getVer() > 3.0) UndoListInTabmenu.toggleRecentlyClosedWindows(undoPopup); // no restorable tabs, so make sure menu is disabled, and return if (UndoListInTabmenu._ss.getClosedTabCount(window) == 0) { menu.setAttribute("disabled", true); //menu.setAttribute("hidden", true); return; } menu.removeAttribute("disabled"); //menu.setAttribute("hidden", false); },false); }, /** * Populate when the history menu is opened (Fx2) */ populateUndoSubmenu: function(undoPopup) { // remove existing menu items while (undoPopup.hasChildNodes()) undoPopup.removeChild(undoPopup.firstChild); // populate menu var undoItems = eval("(" + UndoListInTabmenu._ss.getClosedTabData(window) + ")"); for (var i = 0; i < undoItems.length; i++) { var m = undoPopup.appendChild(document.createElement("menuitem")); m.setAttribute("label", undoItems[i].title); m.setAttribute("value", i); m.setAttribute("oncommand", "undoCloseTab(" + i + ");"); m.setAttribute("onclick", "UndoListInTabmenu._undoCloseMiddleClick(event);"); } // "open in tabs" var bundleService = Cc["@mozilla.org/intl/stringbundle;1"]. getService(Ci.nsIStringBundleService); var stringBundle = bundleService.createBundle("chrome://browser/locale/bookmarks/bookmarks.properties"); undoPopup.appendChild(document.createElement("menuseparator")); m = undoPopup.appendChild(document.createElement("menuitem")); m.setAttribute("label", stringBundle.GetStringFromName("cmd_bm_openfolder")); m.setAttribute("accesskey", stringBundle.GetStringFromName("cmd_bm_openfolder_accesskey")); m.addEventListener("command", function() { for (var i = 0; i < undoItems.length; i++) undoCloseTab(); }, false); }, /** * Re-open a closed tab and put it to the end of the tab strip. * Used for a middle click. * @param aEvent * The event when the user clicks the menu item */ _undoCloseMiddleClick: function PHM__undoCloseMiddleClick(aEvent) { if (aEvent.button != 1) return; undoCloseTab(aEvent.originalTarget.value); gBrowser.moveTabToEnd(); if (!aEvent.ctrlKey) aEvent.originalTarget.parentNode.parentNode.parentNode.hidePopup(); }, /** * Populate when the history menu is opened (Fx3) */ populateUndoSubmenu3: function(undoPopup) { // remove existing menu items while (undoPopup.hasChildNodes()) undoPopup.removeChild(undoPopup.firstChild); // "Open All in Tabs" var strings = gNavigatorBundle; m = undoPopup.appendChild(document.createElement("menuitem")); m.setAttribute("label", strings.getString("menuOpenAllInTabs.label")); m.setAttribute("accesskey", strings.getString("menuOpenAllInTabs.accesskey")); m.addEventListener("command", function() { for (var i = 0; i < undoItems.length; i++) undoCloseTab(); }, false); undoPopup.appendChild(document.createElement("menuseparator")); // populate menu var undoItems = eval("(" + UndoListInTabmenu._ss.getClosedTabData(window) + ")"); for (var i = 0; i < undoItems.length; i++) { var entries = undoItems[i].state.entries; var tooltiptext = ""; for (var j = entries.length - 1; j > -1; j--){ if (j != entries.length - 1) tooltiptext += "\n"; tooltiptext += parseInt(j + 1, 10) + ". " + entries[j].title; } var m = document.createElement("menuitem"); m.setAttribute("tooltiptext", tooltiptext); m.setAttribute("label", undoItems[i].title); if (undoItems[i].image) m.setAttribute("image", undoItems[i].image); m.setAttribute("class", "menuitem-iconic bookmark-item"); m.setAttribute("value", i); m.setAttribute("oncommand", "undoCloseTab(" + i + ");"); m.setAttribute("onclick", "UndoListInTabmenu._undoCloseMiddleClick(event);"); if (i == 0) m.setAttribute("key", "key_undoCloseTab"); undoPopup.appendChild(m); } // "Clear undo close tb list" undoPopup.appendChild(document.createElement("menuseparator")); m = undoPopup.appendChild(document.createElement("menuitem")); m.setAttribute("label", "Liste der letzten Tabs l\u00F6schen"); m.setAttribute("accesskey", "l"); m.addEventListener("command", function() { var max_undo = UndoListInTabmenu.getPref("browser.sessionstore.max_tabs_undo", "int", 10); UndoListInTabmenu.setPref("browser.sessionstore.max_tabs_undo", "int", 0); UndoListInTabmenu.setPref("browser.sessionstore.max_tabs_undo", "int", max_undo); if (max_undo != UndoListInTabmenu.getPref("browser.sessionstore.max_tabs_undo", "int", 10)) UndoListInTabmenu.setPref("browser.sessionstore.max_tabs_undo", "int", max_undo); }, false); }, /** * Populate when the history menu is opened (Fx3.6) */ populateUndoSubmenu36: function(undoPopup) { // remove existing menu items while (undoPopup.hasChildNodes()) undoPopup.removeChild(undoPopup.firstChild); // "Open All in Tabs" var strings = gNavigatorBundle; m = undoPopup.appendChild(document.createElement("menuitem")); m.setAttribute("label", strings.getString("menuRestoreAllTabs.label")); //m.setAttribute("class", "menuitem-iconic bookmark-item"); m.setAttribute("accesskey", "R" /*strings.getString("menuRestoreAllTabs.accesskey")*/); m.addEventListener("command", function() { for (var i = 0; i < undoItems.length; i++) undoCloseTab(); }, false); undoPopup.appendChild(document.createElement("menuseparator")); // populate menu var undoItems = eval("(" + UndoListInTabmenu._ss.getClosedTabData(window) + ")"); for (var i = 0; i < undoItems.length; i++) { var entries = undoItems[i].state.entries; var tooltiptext = ""; for (var j = entries.length - 1; j > -1; j--){ if (j != entries.length - 1) tooltiptext += "\n"; tooltiptext += parseInt(j + 1, 10) + ". " + entries[j].title; } var m = document.createElement("menuitem"); m.setAttribute("tooltiptext", tooltiptext); m.setAttribute("label", undoItems[i].title); if (undoItems[i].image) m.setAttribute("image", undoItems[i].image); m.setAttribute("class", "menuitem-iconic bookmark-item"); m.setAttribute("value", i); m.setAttribute("oncommand", "undoCloseTab(" + i + ");"); m.setAttribute("onclick", "UndoListInTabmenu._undoCloseMiddleClick(event);"); if (i == 0) m.setAttribute("key", "key_undoCloseTab"); undoPopup.appendChild(m); } // "Clear undo close tb list" undoPopup.appendChild(document.createElement("menuseparator")); m = undoPopup.appendChild(document.createElement("menuitem")); m.setAttribute("label", "Liste der letzten Tabs l\u00F6schen"); m.setAttribute("class", "menuitem-iconic bookmark-item"); m.setAttribute("accesskey", "l"); m.addEventListener("command", function() { var max_undo = UndoListInTabmenu.getPref("browser.sessionstore.max_tabs_undo", "int", 10); UndoListInTabmenu.setPref("browser.sessionstore.max_tabs_undo", "int", 0); UndoListInTabmenu.setPref("browser.sessionstore.max_tabs_undo", "int", max_undo); if (max_undo != UndoListInTabmenu.getPref("browser.sessionstore.max_tabs_undo", "int", 10)) UndoListInTabmenu.setPref("browser.sessionstore.max_tabs_undo", "int", max_undo); }, false); }, toggleRecentlyClosedWindows: function PHM_toggleRecentlyClosedWindows(undoPopup) { // enable/disable the Recently Closed Windows sub menu /* let undoPopup = this.historyUndoWindowPopup3; // no restorable windows, so disable menu if (this._ss.getClosedWindowCount() == 0) this.historyUndoWindowPopup3.parentNode.setAttribute("disabled", true); else this.historyUndoWindowPopup3.parentNode.removeAttribute("disabled"); */ // no restorable windows, so disable menu if (this._ss.getClosedWindowCount() == 0) undoPopup.parentNode.setAttribute("disabled", true) else undoPopup.parentNode.removeAttribute("disabled"); }, /** * Populate when the history menu is opened */ populateUndoWindowSubmenu: function PHM_populateUndoWindowSubmenu(undoPopup) { //let undoPopup = this.historyUndoWindowPopup3; let menuLabelString = gNavigatorBundle.getString("menuUndoCloseWindowLabel"); let menuLabelStringSingleTab = gNavigatorBundle.getString("menuUndoCloseWindowSingleTabLabel"); // remove existing menu items while (undoPopup.hasChildNodes()) undoPopup.removeChild(undoPopup.firstChild); // no restorable windows, so make sure menu is disabled, and return if (this._ss.getClosedWindowCount() == 0) { undoPopup.parentNode.setAttribute("disabled", true); return; } // enable menu undoPopup.parentNode.removeAttribute("disabled"); let undoItems = JSON.parse(this._ss.getClosedWindowData()); // "Open All in Windows" let m = undoPopup.appendChild(document.createElement("menuitem")); m.setAttribute("label", gNavigatorBundle.getString("menuRestoreAllWindows.label")); //m.setAttribute("class", "menuitem-iconic bookmark-item"); m.setAttribute("accesskey", "W"/*gNavigatorBundle.getString("menuRestoreAllWindows.accesskey")*/); m.setAttribute("oncommand", "for (var i = 0; i < " + undoItems.length + "; i++) UndoListInTabmenu.undoCloseWindow();"); undoPopup.appendChild(document.createElement("menuseparator")); // populate menu for (let i = 0; i < undoItems.length; i++) { let undoItem = undoItems[i]; let otherTabsCount = undoItem.tabs.length - 1; let label = (otherTabsCount == 0) ? menuLabelStringSingleTab : PluralForm.get(otherTabsCount, menuLabelString); let menuLabel = label.replace("#1", undoItem.title) .replace("#2", otherTabsCount); let m = document.createElement("menuitem"); m.setAttribute("label", menuLabel); let selectedTab = undoItem.tabs[undoItem.selected - 1]; if (selectedTab.attributes.image) { let iconURL = selectedTab.attributes.image; // don't initiate a connection just to fetch a favicon (see bug 467828) if (/^https?:/.test(iconURL)) iconURL = "moz-anno:favicon:" + iconURL; m.setAttribute("image", iconURL); } m.setAttribute("class", "menuitem-iconic bookmark-item"); m.setAttribute("oncommand", "UndoListInTabmenu.undoCloseWindow(" + i + ");"); if (i == 0) m.setAttribute("key", "key_undoCloseWindow"); undoPopup.appendChild(m); } }, /** * Re-open a closed window. * @param aIndex * The index of the window (via nsSessionStore.getClosedWindowData) * @returns a reference to the reopened window. */ undoCloseWindow: function (aIndex) { /* let ss = Cc["@mozilla.org/browser/sessionstore;1"]. getService(Ci.nsISessionStore); */ let ss = SessionStore; let window = null; if (ss.getClosedWindowCount() > (aIndex || 0)) window = ss.undoCloseWindow(aIndex || 0); return window; }, getPref: function(aPrefString, aPrefType, aDefault){ var xpPref = Components.classes['@mozilla.org/preferences-service;1'] .getService(Components.interfaces.nsIPrefBranch); try{ switch (aPrefType){ case 'complex': return xpPref.getComplexValue(aPrefString, Components.interfaces.nsILocalFile); break; case 'str': return xpPref.getCharPref(aPrefString).toString(); break; case 'int': return xpPref.getIntPref(aPrefString); break; case 'bool': default: return xpPref.getBoolPref(aPrefString); break; } }catch(e){ } return aDefault; }, setPref: function(aPrefString, aPrefType, aValue){ var xpPref = Components.classes['@mozilla.org/preferences-service;1'] .getService(Components.interfaces.nsIPrefBranch); try{ switch (aPrefType){ case 'complex': return xpPref.setComplexValue(aPrefString, Components.interfaces.nsILocalFile, aValue); break; case 'str': return xpPref.setCharPref(aPrefString, aValue); break; case 'int': aValue = parseInt(aValue); return xpPref.setIntPref(aPrefString, aValue); break; case 'bool': default: return xpPref.setBoolPref(aPrefString, aValue); break; } }catch(e){ } return null; }, //Fxのバージョンを得る //Fxのバージョン getVer: function(){ const Cc = Components.classes; const Ci = Components.interfaces; var info = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo); var ver = parseInt(info.version.substr(0,3) * 10,10) / 10; return ver; } }; if(!('TM_init' in window)) UndoListInTabmenu.init();
-
Bitte teste beide:
Code
Alles anzeigen// ==UserScript== // @name UndoListInTabmenuToo // @namespace http://space.geocities.yahoo.co.jp/gl/alice0775 // @description UndoListInTabmenuToo.uc.js // @include main // @compatibility Firefox 4.0 - 59 // @author Alice0775 // @version 2017/11/18 nsIPrefBranch to nsIPrefBranch // @version 2010/09/18 00:00 4.0b7pre // @version 2009/02/03 13:00 ツールチップにタブ内履歴を表示するようにした // @Note タブやコンテキストメニューにもUndoClose Tab Listを追加するもの // @OriginalCode browser.jsからpopulateUndoSubmenuを拝借し, ごにょごにょした // @version 2010/03/26 13:00 Minefield/3.7a4pre Bug 554991 - allow tab context menu to be modified by normal XUL overlays // @version 2010/03/15 00:00 Minefield/3.7a4pre Bug 347930 - Tab strip should be a toolbar instead // @version 2009/09/09 15:00 中クリック処理 // ==/UserScript== // @version 2009/09/03 22:00 Firegox3.7a1preで動かなくなっていたのを修正(Bug 489925. getElementById should not return anonymous nodes) // @version 2009/08/22 00:00 Firegox3.6 stringbandleの変更による // @version 2009/04/24 00:00 #394759 [Firefox:Session Restore]-Add undo close window feature // @version 2008/10/12 18:00 Fx3.0.4pre中クリックしたときメニューポップアップが閉じないおよびその他fix // @version 2007/10/05 10:00 var UndoListInTabmenu = { // -- config -- TABCONTEXTMENU : true , //Im Tabkontextmenü: anzeigen: true, nicht anzeigen: false CONTEXTMENU : true, //Im Hauptkontextmenü: anzeigen: true , nicht anzeigen: false // -- config end-- ss: null, get tabContext() { /* return document.getAnonymousElementByAttribute( gBrowser, "anonid", "tabContextMenu")|| gBrowser.tabContainer.contextMenu; */ return gBrowser.tabContainer.contextMenu; }, init: function(){ if (this.TABCONTEXTMENU){ //タブコンテキスト var tabContext = this.tabContext; this.makePopup(tabContext, null, "tabContextUndoList"); } if (this.CONTEXTMENU){ //コンテンツエリアコンテキスト var contextMenu = document.getElementById("contentAreaContextMenu"); var refItem = document.getElementById("context-sep-stop"); this.makePopup(contextMenu, refItem, "ContextUndoList"); } // get closed-tabs from nsSessionStore /* this._ss = Cc["@mozilla.org/browser/sessionstore;1"]. getService(Ci.nsISessionStore); */ this._ss = SessionStore; }, makePopup: function(popup, refItem, id){ var menu; //label /* const locale = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch).getCharPref("general.useragent.locale"); */ const locale = ''; if (this.getVer() > 3.0) { // "Recently Closed Windows" menu = document.createElement("menu"); menu.setAttribute("id", "historyUndoWindowMenu3"); menu.setAttribute("label", "K\u00FCrzlich geschlossene Fenster"); menu.setAttribute("accesskey", "F"); menu.setAttribute("disabled", "true"); popup.insertBefore(menu, refItem); this.historyUndoWindowPopup3 = menu = menu.appendChild(document.createElement("menupopup")); menu.setAttribute("id", "historyUndoWindowPopup3"); menu.setAttribute("onpopupshowing", "UndoListInTabmenu.populateUndoWindowSubmenu();"); } //UndoClose Tab List 最近閉じたタブ const LABELTEXT = locale.indexOf("ja") == -1?"K\u00FCrzlich geschlossene Tabs":"\u6700\u8fd1\u9589\u3058\u305f\u30bf\u30d6"; //create menu menu = document.createElement("menu"); menu.setAttribute("label", LABELTEXT); menu.setAttribute("accesskey", "T"); if (id) menu.setAttribute("id", id); //menu.setAttribute("disabled", true); var menupopup = document.createElement("menupopup"); if (this.getVer()<3) { menupopup.setAttribute("onpopupshowing", "UndoListInTabmenu.populateUndoSubmenu(this);"); } else if (this.getVer()<3.6) { menupopup.setAttribute("onpopupshowing", "UndoListInTabmenu.populateUndoSubmenu3(this);"); } else { menupopup.setAttribute("onpopupshowing", "UndoListInTabmenu.populateUndoSubmenu36(this);"); } menu.appendChild(menupopup); popup.insertBefore(menu, refItem); //add event listener popup.addEventListener('popupshowing',function(event) { if (UndoListInTabmenu.getVer() > 3.0) UndoListInTabmenu.toggleRecentlyClosedWindows(); // no restorable tabs, so make sure menu is disabled, and return if (UndoListInTabmenu._ss.getClosedTabCount(window) == 0) { menu.setAttribute("disabled", true); //menu.setAttribute("hidden", true); return; } menu.removeAttribute("disabled"); //menu.setAttribute("hidden", false); },false); }, /** * Populate when the history menu is opened (Fx2) */ populateUndoSubmenu: function(undoPopup) { // remove existing menu items while (undoPopup.hasChildNodes()) undoPopup.removeChild(undoPopup.firstChild); // populate menu var undoItems = eval("(" + UndoListInTabmenu._ss.getClosedTabData(window) + ")"); for (var i = 0; i < undoItems.length; i++) { var m = undoPopup.appendChild(document.createElement("menuitem")); m.setAttribute("label", undoItems[i].title); m.setAttribute("value", i); m.setAttribute("oncommand", "undoCloseTab(" + i + ");"); m.setAttribute("onclick", "UndoListInTabmenu._undoCloseMiddleClick(event);"); } // "open in tabs" var bundleService = Cc["@mozilla.org/intl/stringbundle;1"]. getService(Ci.nsIStringBundleService); var stringBundle = bundleService.createBundle("chrome://browser/locale/bookmarks/bookmarks.properties"); undoPopup.appendChild(document.createElement("menuseparator")); m = undoPopup.appendChild(document.createElement("menuitem")); m.setAttribute("label", stringBundle.GetStringFromName("cmd_bm_openfolder")); m.setAttribute("accesskey", stringBundle.GetStringFromName("cmd_bm_openfolder_accesskey")); m.addEventListener("command", function() { for (var i = 0; i < undoItems.length; i++) undoCloseTab(); }, false); }, /** * Re-open a closed tab and put it to the end of the tab strip. * Used for a middle click. * @param aEvent * The event when the user clicks the menu item */ _undoCloseMiddleClick: function PHM__undoCloseMiddleClick(aEvent) { if (aEvent.button != 1) return; undoCloseTab(aEvent.originalTarget.value); gBrowser.moveTabToEnd(); if (!aEvent.ctrlKey) aEvent.originalTarget.parentNode.parentNode.parentNode.hidePopup(); }, /** * Populate when the history menu is opened (Fx3) */ populateUndoSubmenu3: function(undoPopup) { // remove existing menu items while (undoPopup.hasChildNodes()) undoPopup.removeChild(undoPopup.firstChild); // "Open All in Tabs" var strings = gNavigatorBundle; m = undoPopup.appendChild(document.createElement("menuitem")); m.setAttribute("label", strings.getString("menuOpenAllInTabs.label")); m.setAttribute("accesskey", strings.getString("menuOpenAllInTabs.accesskey")); m.addEventListener("command", function() { for (var i = 0; i < undoItems.length; i++) undoCloseTab(); }, false); undoPopup.appendChild(document.createElement("menuseparator")); // populate menu var undoItems = eval("(" + UndoListInTabmenu._ss.getClosedTabData(window) + ")"); for (var i = 0; i < undoItems.length; i++) { var entries = undoItems[i].state.entries; var tooltiptext = ""; for (var j = entries.length - 1; j > -1; j--){ if (j != entries.length - 1) tooltiptext += "\n"; tooltiptext += parseInt(j + 1, 10) + ". " + entries[j].title; } var m = document.createElement("menuitem"); m.setAttribute("tooltiptext", tooltiptext); m.setAttribute("label", undoItems[i].title); if (undoItems[i].image) m.setAttribute("image", undoItems[i].image); m.setAttribute("class", "menuitem-iconic bookmark-item"); m.setAttribute("value", i); m.setAttribute("oncommand", "undoCloseTab(" + i + ");"); m.setAttribute("onclick", "UndoListInTabmenu._undoCloseMiddleClick(event);"); if (i == 0) m.setAttribute("key", "key_undoCloseTab"); undoPopup.appendChild(m); } // "Clear undo close tb list" undoPopup.appendChild(document.createElement("menuseparator")); m = undoPopup.appendChild(document.createElement("menuitem")); m.setAttribute("label", "Liste der letzten Tabs l\u00F6schen"); m.setAttribute("accesskey", "l"); m.addEventListener("command", function() { var max_undo = UndoListInTabmenu.getPref("browser.sessionstore.max_tabs_undo", "int", 10); UndoListInTabmenu.setPref("browser.sessionstore.max_tabs_undo", "int", 0); UndoListInTabmenu.setPref("browser.sessionstore.max_tabs_undo", "int", max_undo); if (max_undo != UndoListInTabmenu.getPref("browser.sessionstore.max_tabs_undo", "int", 10)) UndoListInTabmenu.setPref("browser.sessionstore.max_tabs_undo", "int", max_undo); }, false); }, /** * Populate when the history menu is opened (Fx3.6) */ populateUndoSubmenu36: function(undoPopup) { // remove existing menu items while (undoPopup.hasChildNodes()) undoPopup.removeChild(undoPopup.firstChild); // "Open All in Tabs" var strings = gNavigatorBundle; m = undoPopup.appendChild(document.createElement("menuitem")); m.setAttribute("label", strings.getString("menuRestoreAllTabs.label")); //m.setAttribute("class", "menuitem-iconic bookmark-item"); m.setAttribute("accesskey", "R" /*strings.getString("menuRestoreAllTabs.accesskey")*/); m.addEventListener("command", function() { for (var i = 0; i < undoItems.length; i++) undoCloseTab(); }, false); undoPopup.appendChild(document.createElement("menuseparator")); // populate menu var undoItems = eval("(" + UndoListInTabmenu._ss.getClosedTabData(window) + ")"); for (var i = 0; i < undoItems.length; i++) { var entries = undoItems[i].state.entries; var tooltiptext = ""; for (var j = entries.length - 1; j > -1; j--){ if (j != entries.length - 1) tooltiptext += "\n"; tooltiptext += parseInt(j + 1, 10) + ". " + entries[j].title; } var m = document.createElement("menuitem"); m.setAttribute("tooltiptext", tooltiptext); m.setAttribute("label", undoItems[i].title); if (undoItems[i].image) m.setAttribute("image", undoItems[i].image); m.setAttribute("class", "menuitem-iconic bookmark-item"); m.setAttribute("value", i); m.setAttribute("oncommand", "undoCloseTab(" + i + ");"); m.setAttribute("onclick", "UndoListInTabmenu._undoCloseMiddleClick(event);"); if (i == 0) m.setAttribute("key", "key_undoCloseTab"); undoPopup.appendChild(m); } // "Clear undo close tb list" undoPopup.appendChild(document.createElement("menuseparator")); m = undoPopup.appendChild(document.createElement("menuitem")); m.setAttribute("label", "Liste der letzten Tabs l\u00F6schen"); m.setAttribute("class", "menuitem-iconic bookmark-item"); m.setAttribute("accesskey", "l"); m.addEventListener("command", function() { var max_undo = UndoListInTabmenu.getPref("browser.sessionstore.max_tabs_undo", "int", 10); UndoListInTabmenu.setPref("browser.sessionstore.max_tabs_undo", "int", 0); UndoListInTabmenu.setPref("browser.sessionstore.max_tabs_undo", "int", max_undo); if (max_undo != UndoListInTabmenu.getPref("browser.sessionstore.max_tabs_undo", "int", 10)) UndoListInTabmenu.setPref("browser.sessionstore.max_tabs_undo", "int", max_undo); }, false); }, toggleRecentlyClosedWindows: function PHM_toggleRecentlyClosedWindows() { // enable/disable the Recently Closed Windows sub menu let undoPopup = this.historyUndoWindowPopup3; // no restorable windows, so disable menu if (this._ss.getClosedWindowCount() == 0) this.historyUndoWindowPopup3.parentNode.setAttribute("disabled", true); else this.historyUndoWindowPopup3.parentNode.removeAttribute("disabled"); }, /** * Populate when the history menu is opened */ populateUndoWindowSubmenu: function PHM_populateUndoWindowSubmenu() { let undoPopup = this.historyUndoWindowPopup3; let menuLabelString = gNavigatorBundle.getString("menuUndoCloseWindowLabel"); let menuLabelStringSingleTab = gNavigatorBundle.getString("menuUndoCloseWindowSingleTabLabel"); // remove existing menu items while (undoPopup.hasChildNodes()) undoPopup.removeChild(undoPopup.firstChild); // no restorable windows, so make sure menu is disabled, and return if (this._ss.getClosedWindowCount() == 0) { undoPopup.parentNode.setAttribute("disabled", true); return; } // enable menu undoPopup.parentNode.removeAttribute("disabled"); let undoItems = JSON.parse(this._ss.getClosedWindowData()); // "Open All in Windows" let m = undoPopup.appendChild(document.createElement("menuitem")); m.setAttribute("label", gNavigatorBundle.getString("menuRestoreAllWindows.label")); //m.setAttribute("class", "menuitem-iconic bookmark-item"); m.setAttribute("accesskey", "W"/*gNavigatorBundle.getString("menuRestoreAllWindows.accesskey")*/); m.setAttribute("oncommand", "for (var i = 0; i < " + undoItems.length + "; i++) UndoListInTabmenu.undoCloseWindow();"); undoPopup.appendChild(document.createElement("menuseparator")); // populate menu for (let i = 0; i < undoItems.length; i++) { let undoItem = undoItems[i]; let otherTabsCount = undoItem.tabs.length - 1; let label = (otherTabsCount == 0) ? menuLabelStringSingleTab : PluralForm.get(otherTabsCount, menuLabelString); let menuLabel = label.replace("#1", undoItem.title) .replace("#2", otherTabsCount); let m = document.createElement("menuitem"); m.setAttribute("label", menuLabel); let selectedTab = undoItem.tabs[undoItem.selected - 1]; if (selectedTab.attributes.image) { let iconURL = selectedTab.attributes.image; // don't initiate a connection just to fetch a favicon (see bug 467828) if (/^https?:/.test(iconURL)) iconURL = "moz-anno:favicon:" + iconURL; m.setAttribute("image", iconURL); } m.setAttribute("class", "menuitem-iconic bookmark-item"); m.setAttribute("oncommand", "UndoListInTabmenu.undoCloseWindow(" + i + ");"); if (i == 0) m.setAttribute("key", "key_undoCloseWindow"); undoPopup.appendChild(m); } }, /** * Re-open a closed window. * @param aIndex * The index of the window (via nsSessionStore.getClosedWindowData) * @returns a reference to the reopened window. */ undoCloseWindow: function (aIndex) { /* let ss = Cc["@mozilla.org/browser/sessionstore;1"]. getService(Ci.nsISessionStore); */ let ss = SessionStore; let window = null; if (ss.getClosedWindowCount() > (aIndex || 0)) window = ss.undoCloseWindow(aIndex || 0); return window; }, getPref: function(aPrefString, aPrefType, aDefault){ var xpPref = Components.classes['@mozilla.org/preferences-service;1'] .getService(Components.interfaces.nsIPrefBranch); try{ switch (aPrefType){ case 'complex': return xpPref.getComplexValue(aPrefString, Components.interfaces.nsILocalFile); break; case 'str': return xpPref.getCharPref(aPrefString).toString(); break; case 'int': return xpPref.getIntPref(aPrefString); break; case 'bool': default: return xpPref.getBoolPref(aPrefString); break; } }catch(e){ } return aDefault; }, setPref: function(aPrefString, aPrefType, aValue){ var xpPref = Components.classes['@mozilla.org/preferences-service;1'] .getService(Components.interfaces.nsIPrefBranch); try{ switch (aPrefType){ case 'complex': return xpPref.setComplexValue(aPrefString, Components.interfaces.nsILocalFile, aValue); break; case 'str': return xpPref.setCharPref(aPrefString, aValue); break; case 'int': aValue = parseInt(aValue); return xpPref.setIntPref(aPrefString, aValue); break; case 'bool': default: return xpPref.setBoolPref(aPrefString, aValue); break; } }catch(e){ } return null; }, //Fxのバージョンを得る //Fxのバージョン getVer: function(){ const Cc = Components.classes; const Ci = Components.interfaces; var info = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo); var ver = parseInt(info.version.substr(0,3) * 10,10) / 10; return ver; } }; if(!('TM_init' in window)) UndoListInTabmenu.init();
Code
Alles anzeigen(function() { if (location != 'chrome://browser/content/browser.xul') return; let tabContextMenu = document.getElementById('tabContextMenu'); let historyPopup = document.getElementById('goPopup'); let menubar = document.getElementById('toolbar-menubar'); tabContextMenu.addEventListener('popupshowing', function(event) { if (event.target != this) return; menubar.style.visibility = 'collapse'; historyPopup.showPopup(); document.getElementById('historyUndoPopup').showPopup(); let dblHistoryUndoMenu = document.getElementById('historyUndoMenu').cloneNode(true); dblHistoryUndoMenu.id = 'context_historyUndoMenu'; dblHistoryUndoMenu.getElementsByTagName('menupopup')[0].removeAttribute('id'); tabContextMenu.appendChild(dblHistoryUndoMenu); }); tabContextMenu.addEventListener('popuphidden', function(event) { if (event.target != this) return; tabContextMenu.removeChild(document.getElementById('context_historyUndoMenu')); setTimeout(function() { menubar.style.visibility = ''; }, 300); }); })();
-
Gerne.
Noch eine kleine Änderung, damit im Anpassen-Modus auch das richtige Symbol zu sehen ist:
Code
Alles anzeigen// in-page-pop-up-reporter.uc.js (function() { if (location != 'chrome://browser/content/browser.xul') return; const itemId = 'ucjs_in-page-pop-up-reporter-item'; const imageId = 'pageAction-urlbar-_feb799e2-29e2-4e35-b862-cc4e1842b6f5_'; try { CustomizableUI.createWidget({ id: itemId, type: 'custom', defaultArea: CustomizableUI.AREA_NAVBAR, onBuild: function(aDocument) { let toolbaritem = aDocument.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'toolbaritem'); toolbaritem.id = itemId; toolbaritem.className = 'chromeclass-toolbar-additional'; let placeholder = aDocument.createElement('image'); placeholder.id = itemId + '-placeholder'; placeholder.className = 'urlbar-icon urlbar-page-action'; toolbaritem.appendChild(placeholder); return toolbaritem; } }); let css = '\ @-moz-document url("chrome://browser/content/browser.xul") { \ #' + itemId + '-placeholder { \ display: none; \ } \ #wrapper-' + itemId + ' #' + itemId + '-placeholder { \ display: -moz-box; \ --pageAction-image-16px: url("moz-extension://2d64e8e3-28de-4389-9ceb-362e67864578/icons/icon.svg"); \ --pageAction-image-32px: url("moz-extension://2d64e8e3-28de-4389-9ceb-362e67864578/icons/icon.svg"); \ } \ }'; let cssUri = Services.io.newURI('data:text/css,' + encodeURIComponent(css), null, null); let SSS = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService); SSS.loadAndRegisterSheet(cssUri, SSS.AGENT_SHEET); } catch(e) { }; function moveIcon() { try { document.getElementById(itemId).appendChild(document.getElementById(imageId)); } catch(e) { }; }; setTimeout(moveIcon, 0); let observer = new MutationObserver(moveIcon); observer.observe(document.getElementById('page-action-buttons'), {childList: true}); }());
-
Alles Gute!
-
@ Andreas:
Danke.@ Boersenfeger:
Teste folgendes Skript. Im Anpassen-Modus ist vorerst anstatt des Icons ein graues Rechteck zu sehen.Code
Alles anzeigen// in-page-pop-up-reporter.uc.js (function() { if (location != 'chrome://browser/content/browser.xul') return; const itemId = 'ucjs_in-page-pop-up-reporter-item'; const imageId = 'pageAction-urlbar-_feb799e2-29e2-4e35-b862-cc4e1842b6f5_'; try { CustomizableUI.createWidget({ id: itemId, type: 'custom', defaultArea: CustomizableUI.AREA_NAVBAR, onBuild: function(aDocument) { var toolbaritem = aDocument.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'toolbaritem'); toolbaritem.id = itemId; toolbaritem.className = 'chromeclass-toolbar-additional'; return toolbaritem; } }); let css = '\ @-moz-document url("chrome://browser/content/browser.xul") { \ #wrapper-ucjs_in-page-pop-up-reporter-item #ucjs_in-page-pop-up-reporter-item \ {width: 28px; height: 15px; background: grey} \ }'; let cssUri = Services.io.newURI('data:text/css,' + encodeURIComponent(css), null, null); let SSS = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService); SSS.loadAndRegisterSheet(cssUri, SSS.AGENT_SHEET); } catch(e) { }; function moveIcon() { try { document.getElementById(itemId).appendChild(document.getElementById(imageId)); } catch(e) { }; }; setTimeout(function() { moveIcon(); }, 0); let observer = new MutationObserver(moveIcon); observer.observe(document.getElementById('page-action-buttons'), {childList: true}); }());
-
Statusleiste(Via user.js. Script erzeugt)
Welches Skript genau?
Kannst du mit den Browser-Werkzeugen (Strg+Alt+Umschalt+I) die ID des Icons herausfinden? -
Das Schließen-Kreuz ist bereits ausgenommen, nur seit Fx 59 funktioniert das nicht mehr.
Damit klappt es wieder:Code
Alles anzeigen(function() { if (location != 'chrome://browser/content/browser.xul') return; let previousTab = gBrowser.selectedTab; let selectedTab = gBrowser.selectedTab; gBrowser.tabContainer.addEventListener('TabSelect', function(event) { setTimeout(function() { previousTab = event.detail.previousTab; selectedTab = event.target; }, 200); }); let selectPreviousTab; gBrowser.tabContainer.addEventListener('mousedown', function(event) { selectPreviousTab = false; if (event.button == 0 && event.target == selectedTab) { let classList = event.originalTarget.classList; if (!classList.contains('tab-close-button') && !classList.contains('tab-icon-sound')) { selectPreviousTab = true; }; }; }); gBrowser.tabContainer.addEventListener('click', function(event) { if (selectPreviousTab) { gBrowser.selectedTab = previousTab; }; }); })();
Ob sich das mit dem langen Mausklick machen lässt, weiß ich noch nicht.
-
Ja, gibt es.
Gib folgenden Code in die userChrome.css:
Gib in den Ordner chrome noch eine weitere Textdatei namens "userChrome.xml" mit diesem Code:
XML
Alles anzeigen<?xml version="1.0"?> <bindings id="generalBindings" xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xbl="http://www.mozilla.org/xbl"> <binding id="ucjs" extends="chrome://global/content/bindings/toolbarbutton.xml#menu"> <implementation> <constructor> <![CDATA[ (function() { if (window.ucjsExecuted) return; window.ucjsExecuted = true; setTimeout(function() { let keyset = document.getElementById('devtoolsKeyset'); for (let key of keyset.childNodes) { key.setAttribute('disabled', 'true'); }; }, 500); })(); ]]> </constructor> </implementation> </binding> </bindings>
Dann starte Firefox neu. Wenn es nicht funktioniert, starte nochmals neu.
-
Gern geschehen.
Mit dem CSS-Code sind die Zeilen 12 und 25 nicht mehr nötig und können wieder auskommentiert werden.
-
Hallo,
ja, wenn Firefox im Offline-Modus ist.
-
Die Menüleiste blendet sich immer noch ein, diesmal aber nicht ausgeklappt.Schreibe zusätzlich in die userChrome.css:
-
Entferne in den Zeilen 12 und 25 das // am Anfang.
-
Ersetze in Zeile 16 'mousedown' durch 'click'.
-
Man kann mit einem Observer [1] diverse Ereignisse beobachten, beim Start u.a. 'final-ui-startup' [2] und beim Öffnen eines Fensters 'domwindowopened' [3].
Das Skript main.js ging davon aus, dass das 'domwindowopened' des ersten Fensters nach 'final-ui-startup' erfolgt. In den letzten Nightlys findet es jedoch davor statt und darum wurden im ersten Fenster keine Skripte ausgeführt. Im geänderten main.js ist das nun berücksichtigt.
[1] MDN - nsIObserverService
[2] MDN - Observer Notifications - Application startup
[3] MDN - nsIWindowWatcher - registerNotification() -
Könntest du ggf. damit mein Ticket (vorläufig) zu Ende führen bzw. die Lösung /Workaround erklären ?Ja, ich erkläre das in Kürze, vorher will ich noch etwas testen.
-
Bitte testet:
Nehmt diese Variante für die Skriptausführung: Firefox Anpassungen: die Basis
Im Ordner userChromeJS befindet sich die Datei main.js. Ersetzt den Code darin durch folgenden:Code
Alles anzeigen// main.js /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is the userChrome.js component. * * The Initial Developer of the Original Code is * Simon Bünzli <zeniko@gmail.com> * * Portions created by the Initial Developer are Copyright (C) 2007 * the Initial Developer. All Rights Reserved. * * Contributor(s): * alta88 <alta88@gmail.com> * aborix <www.camp-firefox.de/forum> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ Cu.import("resource://gre/modules/FileUtils.jsm"); let UserChrome_js = { init: function() { Services.obs.addObserver(this, "final-ui-startup", false); Services.obs.addObserver(this, "domwindowopened", false); }, // observer observe: function(aSubject, aTopic, aData) { switch (aTopic) { case "final-ui-startup": let path = OS.Constants.Path.profileDir; let ucFilePath = OS.Path.join(path, "chrome", "userChrome.js"); let ucFile = new FileUtils.File(ucFilePath); if (!ucFile.exists()) { let path = OS.Path.join(ucjsDirPath, "Readme.txt"); let readmeFile = new FileUtils.File(path); readmeFile.copyTo(ucFile.parent, "userChrome.js"); }; if (ucFile.exists() && ucFile.isFile()) { let path = OS.Path.join(ucjsDirPath, "utilities.js"); this.utilFileURI = OS.Path.toFileURI(path); this.ucFileURI = OS.Path.toFileURI(ucFilePath); // Services.obs.addObserver(this, "domwindowopened", false); }; Services.obs.removeObserver(this, "final-ui-startup"); break; case "domwindowopened": aSubject.addEventListener("load", this, {capture: true, once: true}); break; } }, // event listener for load handleEvent: function(aEvent) { let document = aEvent.originalTarget; let window = document.defaultView; if (document.location && document.location.protocol == "chrome:") { try { Services.scriptloader.loadSubScript(this.utilFileURI, window, "UTF-8"); Services.scriptloader.loadSubScript(this.ucFileURI, window, "UTF-8"); } catch (ex) { // script execution can be stopped with |throw "stop";| if (ex != "stop") { Cu.reportError(ex); } } }; } }; UserChrome_js.init();
Dann Neustart mit Skript-Cache leeren.
-
Ich habe Skripte mit mehreren geöffneten Fenstern getestet. Im ersten Fenster funktionieren sie fast nie, in den weiteren manchmal. Werden die Fenster bei offener Browserkonsole geöffnet, funktionieren die Skripte anscheinend öfter.
-
Es gibt zwei Methoden, Skripte auszuführen:
mittels einer Konfigurationsdatei im Installationsordner, so wie wir das tun
mittels einem speziellen Code in der userChrome.css und einer zusätzlichen Datei userChrome.xml im Profilordner
Die zweite Methode wurde m.W. bisher im Forum nicht besprochen, nur loshombre hat hier auf sie verlinkt:
https://github.com/nuchi/firefox-quantum-userchromejs
Eine weitere Seite dazu:
https://github.com/Sporif/firefox-quantum-userchromejsDie geplante Entfernung von XBL betrifft nur diese Methode, nicht die von uns verwendete.
Auch Kommentar 2 im Bugreport bezieht sich darauf.