Aber bittebitte nicht über meine ganzen Versuche/kommentare lachen:
Code
// 31_Externals-button-bar.uc.js
//
// ==UserScript==
// @name External-Aplication.uc.js
// @namespace ithinc#mozine.cn
// @description External Applications
// @include main
// @compatibility Firefox 3.5.x
// @author ithinc
// @version 20091212.0.0.1 Initial release
// @version 20170911.0.0.2 Fix by aborix
// ==/UserScript==
//
// Herkunft:
// https://www.camp-firefox.de/forum/thema/126871
//
// Sinn und Zweck diesmal: Zusatzleiste für App-Buttons im FullScreen-FF
// ============
// 211203: erste versuche: Buttons immer mit Text :o => wo unnötig = ''
// 211204: CSS-Regeln, u.a. Separatoren-Aussehen ersma in userChrome.css abgelegt.
// 211205: 2. mögliche Position gefunden: insertafter: 'browser' = gaaanz unten :)
// Tests zeigen, daß vertikal irgendwie möglich ist "orientation:" eingebaut
// Heureka :-)=
var gExternalApplications = {
type: 'button',
// 211205: eingebaut, getestet, funktioniert
// horientation: 'vertical',
orientation: 'horizontal',
// die hier machten nicht das, was ich erwartete ////////////////////////////////////
// insertafter: 'navbar', //klappt nicht
// insertafter: 'main-window', //klappt nicht
// insertafter: 'toolbar-menubar', // unter menü-bar
// insertafter: 'titlebar', // auch unter menü-bar
// insertafter: 'TabsToolbar', // auch unter menü-bar
// insertafter: 'PersonalToolbar', // unter Lesezeichen-bar
// insertafter: 'TabsToolbar-customization-target', // hinten _IN_ TabsToolbar
// insertafter: 'navigator-toolbox', // hinter menü-bar
//////////////////////////////////////////////////////////////////////////////////////
insertafter: 'toolbar-menubar', // unter menü-bar
// insertafter: 'browser', // gaaanz unten :)
apps: [
{name: 'Calc', path: 'C:/WINDOWS/system32/calc.exe'},
{name: 'Shell', path: 'C:/WINDOWS/system32/cmd.exe'},
{name: 'Unreal Commander', path: 'D:/___Stickware/util/uc/Uncom.exe'},
{name: 'separator'},
{name: 'Notepad++', path: 'D:/___Stickware/office/NPP/notepad++.exe'},
{name: 'OO-Writer', path: 'D:/___Stickware/office/OpenOffice/OpenOfficeWriterPortable.exe'},
{name: 'OO-Calc', path: 'D:/___Stickware/office/OpenOffice/OpenOfficeCalcPortable.exe'},
{name: 'separator'},
{name: 'Photofiltre', path: 'D:/___Stickware/gfx/PhotoFiltre/PhotoFiltre.exe'},
{name: 'separator'},
{name: 'AVC-Converter', path: 'C:/Program Files (x86)/Anvsoft/Any Video Converter/AVCFree.exe'},
{name: 'VDub', path: 'D:/___Stickware/av/vdub11005_64/Veedub64.exe'},
{name: 'TSDoctor', path: 'C:/Program Files (x86)/Cypheros/TSDoctor2/TSDoctor.exe'},
{name: 'separator'},
{name: 'Limical', path: 'D:/05_E-Smoke/02_panschen/Limical10.exe'},
{name: 'SnapTimert', path: 'D:/___Stickware/util/SnapTimer/SnapTimer.exe'},
{name: '7Zip', path: 'D:/___Stickware/util/7-Zip/7-ZipPortable.exe'},
{name: 'separator'},
{name: 'Solitair', path: 'C:/Program Files (x86)/123 Free Solitaire/123FreeSolitaire.exe'},
{name: 'Click', path: 'D:/___Stickware/fun/ClickOmania/Click.exe'},
{name: 'separator'},
{name: 'separator'},
{name: 'separator'},
{name: 'this bar', path: 'D:/___Stickware/comm/firefoxportable/Data/profile/chrome/my_js/31_Externals-button-bar.uc.js'},
],
init: function() {
for (var i=0; i<this.apps.length; i++) {
if (!this.apps[i].path) continue;
if (!this.apps[i].args) this.apps[i].args = [];
this.apps[i].path = this.apps[i].path.replace(/\//g, '\\');
var ffdir = Cc['@mozilla.org/file/directory_service;1'].getService(Ci.nsIProperties).get('CurProcD', Ci.nsIFile).path;
if (/^(\\)/.test(this.apps[i].path)) {
this.apps[i].path = ffdir.substr(0,2) + this.apps[i].path;
}
else if (/^(\.)/.test(this.apps[i].path)) {
this.apps[i].path = ffdir + '\\' + this.apps[i].path;
}
}
if (this.type == 'menu') {
var mainmenu = document.getElementById('main-menubar'); // das war das Original
var menu = mainmenu.appendChild(document.createXULElement('menu'));
menu.setAttribute('label', 'Start'); // Menu = "Start"
menu.setAttribute('accesskey', 't');
menu.setAttribute('id', 'start-menu');
var menupopup = menu.appendChild(document.createXULElement('menupopup'));
for (var i=0; i<this.apps.length; i++) {
menupopup.appendChild(this.createMenuitem(this.apps[i]));
}
}
else {
var menubarItems = document.getElementById(this.insertafter);
var toolbaritem = menubarItems.parentNode.insertBefore(document.createXULElement('toolbaritem'), menubarItems.nextSibling);
toolbaritem.id = 'ExtAppButtons';
toolbaritem.setAttribute("class", "chromeclass-toolbar-additional");
// toolbaritem.setAttribute("orient", "horizontal"); //original
// 211205: this.orientation eingebaut
toolbaritem.setAttribute("orient", this.orientation);
for (var i=0; i<this.apps.length; i++) {
toolbaritem.appendChild(this.createButton(this.apps[i]));
}
}
},
exec: function(path, args) {
for (var i=0; i<args.length; i++) {
args[i] = args[i].replace(/%u/g, gBrowser.currentURI.spec);
}
var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);
file.initWithPath(path);
if (!file.exists()) {
throw 'File Not Found: ' + path;
}
if (!file.isExecutable() || args.length==0) {
file.launch();
}
else {
var process = Cc['@mozilla.org/process/util;1'].getService(Ci.nsIProcess);
process.init(file);
process.run(false, args, args.length);
}
},
createButton: function(app) {
if (app.name == 'separator')
// hier könnte ich einen eigenen basteln, aber (noch) keine Ahnung, wie....
return document.createXULElement('toolbarseparator');
var item = document.createXULElement('toolbarbutton');
item.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional');
// item.setAttribute('label', app.name); //überflüssig, Tooltips reichen
item.setAttribute('image', 'moz-icon:file:///' + app.path + '?size=16');
item.setAttribute('oncommand', 'gExternalApplications.exec(this.path, this.args);');
item.setAttribute('tooltiptext', app.name);
item.path = app.path;
item.args = app.args;
return item;
},
createMenuitem: function(app) {
if (app.name == 'separator')
return document.createXULElement('menuseparator');
var item = document.createXULElement('menuitem');
item.setAttribute('class', 'menuitem-iconic');
item.setAttribute('label', app.name);
item.setAttribute('image', 'moz-icon:file:///' + app.path + '?size=16');
item.setAttribute('oncommand', 'gExternalApplications.exec(this.path, this.args);');
item.path = app.path;
item.args = app.args;
return item;
}
};
gExternalApplications.init();
Alles anzeigen