Nur aus Neugierde, gibt es auch eine Fehlermeldung zu document.getElementById...etc, wenn der komplette CSS Teil raus ist?
Mit dem ↓ Script zumindest gibt es keine Fehlermeldung mehr.
JavaScript
// JavaScript Document
// QuickProfilesChangesButton.uc.js
// Source code https://www.camp-firefox.de/forum/thema/136664/?postID=1233148#post1233148
// Mit wichtiger Änderung von Horstmann!
// Version 1.10b from August 14, 2023
(function() {
if (location.href !== 'chrome://browser/content/browser.xhtml') return;
try {
CustomizableUI.createWidget({
id: 'profileschange-button',
type: 'custom',
defaultArea: CustomizableUI.AREA_NAVBAR,
onBuild: function(aDocument) {
let toolbaritem = aDocument.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'toolbarbutton');
let iconDirectory = PathUtils.toFileURI(PathUtils.join(PathUtils.profileDir, 'chrome', 'icons')); // Profilpfad zum Ordner des Symbols
let buttonIcon = "monitor.png"; // Name & Dateiendung des anzuzeigenden Symbols. Hier "XXX.xxx" das eigene Symbol inkl. Dateiendung eintragen
toolbaritem.onclick = event => onClick(event);
var props = {
id: 'profileschange-button',
class: 'toolbarbutton-1 chromeclass-toolbar-additional',
removable: 'true',
label: 'Profil zusätzlich starten',
accesskey: '', // Wer möchte kann hier z.B. 'C' eintragen, dann kann per "Alt + C" das Skript ausgeführt werden
tooltiptext: 'Profile Changer',
style: 'list-style-image: url("' + iconDirectory + '/' + buttonIcon + '");',
};
for (var p in props)
toolbaritem.setAttribute(p, props[p]);
return toolbaritem;
}
});
} catch(e) { };
// var css =`
// #profileschange-button {
// list-style-image: url("${ProfilePath}/${ButtonIcon}");
// }
// `;
// var sss = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService);
// var uri = makeURI('data:text/css;charset=UTF=8,' + encodeURIComponent(css));
// sss.loadAndRegisterSheet(uri, sss.AUTHOR_SHEET);
function onClick(event) {
if (event.button != 0){
return;
}
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
// let arguments = ["-no-remote", "-P", "Standard-Benutzer", "-foreground"]; // Profil wird ausgewählt Hier "XXX" den gewünschten Profilnamen eintragen
let arguments = ["-no-remote", "-P"]; // Wer lieber den Profilmanager aufrufen möchte,nutzt diese Zeile!
file.initWithPath("C:\\Program Files\\RV\\Mozilla Firefox\\firefox.exe"); // Pfad zur Firefox-Installation
// file.initWithPath("/Applications/Firefox.app/Contents/MacOS/firefox"); // Pfad zur Firefox-Installation, Dateipfad für Mac User
let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
process.init(file);
process.run(false, arguments, arguments.length); // Profil wird bestätigt
}
})();
Alles anzeigen