- Firefox-Version
- Firefox 138.0.1
- Betriebssystem
- Windows 10 Home
Das Script erlaubt über Programm-Icons das aufrufen externer Anwendungen. Eben bemerkt das beim klicken eines Icon unter FF 138 nichts mehr aufgerufen wird. Alle Icons sind noch da aber funktionslos. Weiss jemand woran es liegen könnte?
Code
		
					
				// ==UserScript==
// @name           External-Application.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==
/* :::: External Applications :::: */
var gExternalApplications = {
  type: 'button', //'menu' or 'button'
  insertafter: 'menubar-items',
  apps: [
    {name: 'Editor', path: 'C:\\WINDOWS\\system32\\notepad.exe'},
    {name: 'Notepad++', path: 'C:\\Programme\\Notepad++\\notepad++.exe'},
    {name: 'Thunderbird', path: 'C:\\Program Files\\Mozilla Thunderbird\\thunderbird.exe'},
    {name: 'Command Prompt', path: 'C:\\WINDOWS\\system32\\cmd.exe'},
    {name: 'separator'},
    ],
  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');
      var menu = mainmenu.appendChild(document.createXULElement('menu'));
      menu.setAttribute('label', 'Start');
      menu.setAttribute('accesskey', 'a');
      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");
      for (var i=0; i<this.apps.length; i++) {
        toolbaritem.appendChild(this.createButton(this.apps[i]));
      }
    */
      for (var i=0; i<this.apps.length; i++) {
        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')
      return document.createXULElement('toolbarseparator');
    var item = document.createXULElement('toolbarbutton');
    item.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional');
    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.setAttribute('tooltiptext', app.name);
    item.path = app.path;
    item.args = app.args;
    return item;
  */
    if (app.name == 'separator')
      return;
    var buttonId = app.name.replace(/ /g, '_').replace(/\+/g, 'Plus') + '-ExtApp-button';
    try {
      CustomizableUI.createWidget({
        id: buttonId,
        type: 'custom',
        defaultArea: CustomizableUI.AREA_MENUBAR,
        onBuild: function(aDocument) {
          var toolbaritem = aDocument.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'toolbarbutton');
          var attributes = {
            id: buttonId,
            class: 'toolbarbutton-1 chromeclass-toolbar-additional',
            label: app.name,
            tooltiptext: app.name,
            image: 'moz-icon:file:///' + app.path + '?size=16',
            oncommand: 'gExternalApplications.exec(this.path, this.args);'
          };
          for (var a in attributes) {
            toolbaritem.setAttribute(a, attributes[a]);
          };
          toolbaritem.path = app.path;
          toolbaritem.args = app.args;
          return toolbaritem;
        }
      });
    } catch(e) {};
  },
  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(); 
		
		
	 
															
		
 Funktioniert wieder!
  Funktioniert wieder! 



