Den dazugehörenden Code bräuchte ich.
Aber natürlich, bitteschön.
JavaScript
// ==UserScript==
// @name AppsStarter.uc.js
// @namespace Appmenu@gmail.com
// @description Basiert auf dem Script externalFuncButtonM.uc.js, Wiederherstellung der Orangenen FF-Menü Schaltfläche
// ==/UserScript==
var Appmenu = {
// Beginn der Konfiguration ------------------
// Editor mit angegebenem Pfad verwenden
editor: 'C:\\notepad++\\notepad++.exe',
// oder
// in 'view_source.editor.path' eingetragenen Editor verwenden
editor: Services.prefs.getCharPref('view_source.editor.path'),
// Dateimanager mit angegebenem Pfad verwenden oder leer ('') wenn System-Dateimanager verwenden
fileManager: '',
// fileManager: 'C:\\Program files\\FreeCommander XE\\FreeCommander.exe',
// Parameter für Dateimanager oder leer ('')
FMParameter: '/T',
// Submenüs ohne Inhalt im Hauptmenü automatisch ausblenden
autohideEmptySubDirs: true,
// Submenüs im Hauptmenü nach unten verschieben
moveSubDirstoBottom: false,
// Ort und Aussehen des Menü-Buttons einstellen
isUrlbar: 1, // 0: TabsToolbar, 1: navbar, 2: toolbar-menubar;
isButton: 1, // 0: Hamburger, klein; 1: Firefox, groß
// Hotkey zum Öffnen des Appmenüs oder leer ('')
hotkey: 'x',
hotkeyModifier: 'alt',
// Ende der Konfiguration --------------------
subdirPopupHash: [],
subdirMenuHash: [],
toolbar: {
// Submenüs des Hauptmenüs definieren; Separator einfügen mit {name: 'separator'}
subdirs: [
],
apps: [
// im Hauptmenü angezeigt
{
name: 'Updater 1 - Beta',
root: 'ProfD',
path: 'G:/Portable.Firefox.Updater.1/Firefox Beta x64 Launcher.exe',
},
{
name: 'Updater 1 - ESR',
root: 'ProfD',
path: 'G:/Portable.Firefox.Updater.1/Firefox ESR x64 Launcher.exe',
},
{
name: 'Updater 1 - Stable',
root: 'ProfD',
path: 'G:/Portable.Firefox.Updater.1/Firefox Stable x64 Launcher.exe',
},
{
name: 'Updater 2 - Beta',
root: 'ProfD',
path: 'G:/Portable.Firefox.Updater.2/Firefox Beta x64 Launcher.exe',
},
{
name: 'Updater 2 - Nightly',
root: 'ProfD',
path: 'G:/Portable.Firefox.Updater.2/Firefox Nightly x64 Launcher.exe',
},
{
name: 'Updater 2 - Stable',
root: 'ProfD',
path: 'G:/Portable.Firefox.Updater.2/Firefox Stable x64 Launcher.exe',
},
{
name: 'Updater 3 - Beta',
root: 'ProfD',
path: 'G:/Portable.Firefox.Updater.3/Firefox Beta x64 Launcher.exe',
},
{
name: 'Updater 3 - Nightly',
root: 'ProfD',
path: 'G:/Portable.Firefox.Updater.3/Firefox Nightly x64 Launcher.exe',
},
{
name: 'Updater 3 - Stable',
root: 'ProfD',
path: 'G:/Portable.Firefox.Updater.3/Firefox Stable x64 Launcher.exe',
},
{
name: 'Nightly 1',
root: 'ProfD',
path: 'G:/Firefox Test/Nightly1/FirefoxLoader.exe',
},
{
name: 'Nightly 2',
root: 'ProfD',
path: 'G:/Firefox Test/Nightly2/FirefoxLoader.exe',
},
{
name: 'Profil-Manager',
root: 'ProfD',
path: 'G:/Profilauswahl/Profil-Starter.lnk',
},
{
name: 'WinMerge',
root: 'ProfD',
path: 'G:/Starter/WinMerge 2.16.42.1.lnk',
},
{
name: 'notepad++',
root: 'ProfD',
path: 'C:/notepad++/notepad++.exe',
}
],
configs: [
// Untermenü Firefox Funktionen
{
name: 'Browser-Werkzeuge',
command: "var { require } = ChromeUtils.importESModule('resource://devtools/shared/loader/Loader.sys.mjs', {});\
var { BrowserToolboxLauncher } = require('resource://devtools/client/framework/browser-toolbox/Launcher.sys.mjs');\
BrowserToolboxLauncher.init();",
},
{
name: 'Neustart',
tooltiptext: 'userChrome.js-Cache wird geleert',
command: 'Services.appinfo.invalidateCachesOnRestart(); \
Services.startup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);',
id: 'AMreboot',
},
{
name: 'Beenden',
command: "goQuitApplication(event);",
id: 'AMquit',
},
]
},
_externalAppPopup: null,
_isready: false,
init: function() {
this.handleRelativePath(this.toolbar.apps);
const XULNS = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul';
var ExternalAppBtn = document.createElementNS(XULNS, 'toolbarbutton');
ExternalAppBtn.id = "AppMenuButton";
ExternalAppBtn.setAttribute("label", "AppButton");
//ExternalAppBtn.setAttribute("onclick", "event.preventDefault();event.stopPropagation();");
ExternalAppBtn.addEventListener('click', event => {
event.preventDefault();
event.stopPropagation();
});
ExternalAppBtn.setAttribute("tooltiptext", "Firefox Menü");
ExternalAppBtn.setAttribute("type", "menu");
ExternalAppBtn.setAttribute("removable", "true");
if (Appmenu.isButton) {
ExternalAppBtn.style.listStyleImage = "url(file:///C:/FoxIcons/0059.png)";
} else {
ExternalAppBtn.style.listStyleImage = "url(file:///C:/FoxIcons/0059.png)";
}
if (Appmenu.isUrlbar === 1) {
var navBar = document.getElementById("nav-bar-customization-target");
navBar.insertBefore(ExternalAppBtn, navBar.firstChild);
} else if (Appmenu.isUrlbar === 2) {
var menubar = document.getElementById("toolbar-menubar");
menubar.insertBefore(ExternalAppBtn, menubar.firstChild);
} else {
var TabsToolbar = document.getElementById("TabsToolbar");
TabsToolbar.insertBefore(ExternalAppBtn, TabsToolbar.firstChild);
}
var ExternalAppPopup = document.createElementNS(XULNS, 'menupopup');
//ExternalAppPopup.setAttribute('onpopupshowing', 'event.stopPropagation(); Appmenu.onpopupshowing();');
ExternalAppPopup.addEventListener('click', event => {
event.stopPropagation();
});
ExternalAppPopup.setAttribute('id', 'AMpopup');
this._externalAppPopup = ExternalAppPopup;
ExternalAppBtn.appendChild(ExternalAppPopup);
Appmenu.onpopupshowing();
// Menü mit Tastaturkürzel öffnen
if (Appmenu.hotkey) {
let key = document.createXULElement('key');
key.id = 'key_AppMenuPopup';
key.setAttribute('key', Appmenu.hotkey);
if (Appmenu.hotkeyModifier)
key.setAttribute('modifiers', Appmenu.hotkeyModifier);
key.setAttribute('oncommand', 'document.getElementById("AMpopup").openPopup();');
document.getElementById('mainKeyset').appendChild(key);
}
},
onpopupshowing: function() {
if (this._isready)
return;
if (this._externalAppPopup === null)
return;
var ExternalAppPopup = this._externalAppPopup;
for (let subdir of this.toolbar.subdirs) {
if (subdir.name == 'separator') {
ExternalAppPopup.appendChild(document.createXULElement('menuseparator'));
} else {
var subdirItem = ExternalAppPopup.appendChild(document.createXULElement('menu'));
var subdirItemPopup = subdirItem.appendChild(document.createXULElement('menupopup'));
subdirItem.setAttribute('class', 'menu-iconic');
subdirItem.setAttribute('label', subdir.name);
subdirItem.setAttribute('image', subdir.image);
Appmenu.subdirPopupHash[subdir.name] = subdirItemPopup;
Appmenu.subdirMenuHash[subdir.name] = subdirItem;
}
}
for (let app of this.toolbar.apps) {
var appItem;
if (app.name == 'separator') {
appItem = document.createXULElement('menuseparator');
} else {
appItem = document.createXULElement('menuitem');
appItem.setAttribute('class', 'menuitem-iconic');
appItem.setAttribute('label', app.name);
appItem.setAttribute('image', app.image);
//appItem.setAttribute('oncommand', "Appmenu.exec(this.path, this.args);");
appItem.addEventListener('command', function () {
Appmenu.exec(this.path, this.args);
});
appItem.setAttribute('tooltiptext', app.name);
appItem.path = app.path;
appItem.args = app.args;
}
if (app.subdir && Appmenu.subdirPopupHash[app.subdir])
Appmenu.subdirPopupHash[app.subdir].appendChild(appItem);
else ExternalAppPopup.appendChild(appItem);
}
for (let config of this.toolbar.configs) {
var configItem;
if (config.name == 'separator') {
configItem = document.createXULElement('menuseparator');
} else {
configItem = ExternalAppPopup.appendChild(document.createXULElement('menuitem'));
configItem.setAttribute('class', 'menuitem-iconic');
configItem.setAttribute('label', config.name);
configItem.setAttribute('image', config.image);
//configItem.setAttribute('oncommand', config.command);
configItem.addEventListener('command', () => {
eval(config.command);
});
if (config.tooltiptext) {
configItem.setAttribute('tooltiptext', config.tooltiptext);
} else {
configItem.setAttribute('tooltiptext', config.name);
}
configItem.setAttribute('id', config.id);
}
if (config.subdir && Appmenu.subdirPopupHash[config.subdir]) {
Appmenu.subdirPopupHash[config.subdir].appendChild(configItem);
} else {
ExternalAppPopup.appendChild(configItem);
}
}
if (this.autohideEmptySubDirs) {
for (let i = 0; i < Appmenu.subdirPopupHash.length; i++) {
if (Appmenu.subdirPopupHash[i].hasChildNodes()) {
continue;
} else {
Appmenu.subdirMenuHash[i].setAttribute("hidden", "true");
}
}
}
if (this.moveSubDirstoBottom) {
let i = ExternalAppPopup.childNodes.length;
while (ExternalAppPopup.firstChild.getAttribute('class') != 'menuitem-iconic' && i-- != 0) {
ExternalAppPopup.appendChild(ExternalAppPopup.firstChild);
}
}
this._isready = true;
},
handleRelativePath: function(apps) {
for (let app of apps) {
if (app.path) {
app.path = app.path.replace(/\//g, '\\');
var ffdir = Cc['@mozilla.org/file/directory_service;1'].getService(Ci.nsIProperties).get(app.root, Ci.nsIFile).path;
if (/^(\\)/.test(app.path)) {
app.path = ffdir + app.path;
}
}
}
},
exec: function(path, args) {
args = args || [];
var args_t = args.slice(0);
for (let arg of args_t) {
arg = arg.replace(/%u/g, gBrowser.currentURI.spec);
}
var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);
file.initWithPath(path);
if (!file.exists()) {
//Cu.reportError('Datei nicht gefunden: ' + path);
alert('Datei nicht gefunden: ' + path);
return;
}
if (file.isExecutable() && !path.endsWith('.js')) {
var process = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess);
process.init(file);
process.run(false, args_t, args_t.length);
} else if (file.isFile()) {
if (this.editor) {
let UI = Cc["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Ci.nsIScriptableUnicodeConverter);
UI.charset = window.navigator.platform.toLowerCase().includes('win') ? 'Shift_JIS' : 'UTF-8';
let path = UI.ConvertFromUnicode(file.path);
let app = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);
app.initWithPath(this.editor);
let process = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess);
process.init(app);
process.run(false, [path], 1);
} else {
file.launch();
}
} else if (file.isDirectory()) {
if (this.fileManager) {
let args=[this.FMParameter,path];
let app = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);
app.initWithPath(this.fileManager);
let process = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess);
process.init(app);
process.run(false, args, args.length);
} else {
file.launch();
}
}
},
};
if (window.gBrowser)
Appmenu.init();
// _AppMenuButtonMoveable.js
(function() {
if (location != 'chrome://browser/content/browser.xhtml')
return;
var appButton = document.getElementById('AppMenuButton');
if (!CustomizableUI.getPlacementOfWidget('MoverAppMenuButton')) {
try {
CustomizableUI.createWidget({
id: 'MoverAppMenuButton',
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 = 'MoverAppMenuButton';
toolbaritem.className = 'chromeclass-toolbar-additional';
toolbaritem.setAttribute('label', 'Firefox Starter');
return toolbaritem;
}
});
if (!CustomizableUI.getPlacementOfWidget('MoverAppMenuButton')) {
menuButton.style.display = 'none';
return;
};
} catch(e) {
menuButton.style.display = 'none';
return;
};
};
setTimeout(function() {
document.getElementById('MoverAppMenuButton').appendChild(appButton);
appButton.setAttribute('consumeanchor', 'MoverAppMenuButton');
appButton.setAttribute('label', 'Firefox Starter');
appButton.setAttribute('tooltiptext', 'Firefox Starter');
}, 0);
}());
Alles anzeigen