Das kann ich so nicht stehen lassen, denn die im ersten Script eingetragenen portablen Versionen sind alle mit dem FirefoxUpdater erstellt worden, der Profilordner darin heißt "profile". Damit funktioniert es so, wie sie in dem Script eingetragen sind ohne Probleme. Nun habe ich eine weitere portable Version zum Test eingebaut, und da öffnete sich bei Klick immer der Profilmanager, Firefox wurde nicht gestartet. Diese Form brauchte im Script eine andere Behandlung, und der Eintrag im Script sieht dafür anders aus, und hier heißt er "Profilordner". Hier sind die Unterschiede aufgeführt:
JavaScript
addProfileItem(document, popup,
"️Portable U Beta 4 🔥 ", "profile",
"G:\\Portable.Firefox.Updater.4\\Firefox Beta x64 Launcher.exe",
"file:///C:/FoxIcons/Beta.png"
);
// ✅ Firefox3p: Profilordner direkt starten (kein Profilmanager)
addProfileItem(document, popup,
"️Firefox3p 🔥 ",
"G:\\Firefox Test\\Firefox3p\\Profilordner",
"G:\\Firefox Test\\Firefox3p\\Firefox64\\firefox.exe",
"file:///C:/FoxIcons/Finale.png",
"dir"
);
Alles anzeigen
Das Script wurde deswegen neu angepasst:
JavaScript
// == PROFILSTARTER.UC.JS v9-test - CSS SOFORT + MULTI-FENSTER FIX ===
console.log("=== PROFILSTARTER.UC.JS v9-test - CSS SOFORT + MULTI-FENSTER FIX ===");
(function() {
if (!window.gBrowser)
return;
// User Settings
let btn_id = 'aboutprofiles-Start'; // Button #id
const btn_icon = 'p2.png'; // Symbol
const iconPath = 'file:///C:/FoxIcons/'; // Icon-Ordner
const ImagePath = iconPath + btn_icon;
const btn_label = 'Profil zusätzlich starten';
const btn_tooltiptext = 'Zusätzliche Firefox-Profile starten';
const POPUP_ID = btn_id + '-popup';
// ✅ CSS einmalig pro Fenster injizieren
let cssInjected = false;
// ============== CSS ==============
function injectUserCSS() {
try {
if (cssInjected) return;
const css = `
#${btn_id} image.toolbarbutton-icon {
transform: scale(1.0) !important;
padding: 6px !important;
}
#${POPUP_ID} {
max-width: 285px !important;
}
#${POPUP_ID} menuitem {
padding-inline-start: 8px !important;
padding-inline-end: 8px !important;
margin: 0 !important;
min-height: 24px !important;
}
#${POPUP_ID} menuitem.menuitem-iconic .menu-icon {
margin-inline-end: 8px !important;
margin-inline-start: -30px !important;
width: 16px !important;
height: 16px !important;
}
#${POPUP_ID} menuitem.menuitem-iconic .menu-text {
margin-left: 8px !important;
font-weight: 500 !important;
padding: 2px 0 2px 0 !important;
}
#${POPUP_ID} menuitem.menuitem-iconic:hover .menu-text {
margin-left: 8px !important;
font-weight: 600 !important;
color: red !important;
opacity: 1 !important;
}
`;
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const Services = globalThis.Services || Cu.import("resource://gre/modules/Services.jsm").Services;
const sss = Cc["@mozilla.org/content/style-sheet-service;1"]
.getService(Ci.nsIStyleSheetService);
const uri = Services.io.newURI(
"data:text/css;charset=utf-8," + encodeURIComponent(css)
);
if (!sss.sheetRegistered(uri, sss.AUTHOR_SHEET)) {
sss.loadAndRegisterSheet(uri, sss.AUTHOR_SHEET);
}
cssInjected = true;
console.log("[PROFILSTARTER] CSS injiziert.");
} catch (e) {
console.error("[PROFILSTARTER] CSS Fehler:", e);
}
}
// ============== Profil-Daten ==============
const PROFIL_NAMEN = {
"ArbeitsFox": { name: " ArbeitsFox ( >>Standard<< ) 🏠", icon: "Finale.png" },
"Einkauf": { name: " Einkaufen ( >>Shops<< ) 🏠", icon: "s4.png" },
"default": { name: " Nicht starten ( >>Default<< ) 🏠", icon: "warnung19.png" },
"Reserve": { name: " Reserve 1 ( >>Ersatz-Profil<< ) 🏠", icon: "Firefox32.png" },
"Reserve-Profil 2": { name: " Reserve 2 ( >>Ersatz-Profil<< ) 🏠", icon: "Firefox32.png" },
"Reserve 3": { name: " Reserve 3 ( >>Ersatz-Profil<< ) 🏠", icon: "Firefox32.png" }
};
// ============== START (angepasst: -profile dir) ==============
function startProfile(profileValue, exePath, mode = "name") {
try {
const Cc = Components.classes;
const Ci = Components.interfaces;
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
let defaultPath = "C:\\Program Files\\Mozilla Firefox\\firefox.exe";
file.initWithPath(exePath || defaultPath);
let args;
if (mode === "dir") {
// Profilordner direkt starten
args = ["-no-remote", "-profile", profileValue, "-foreground"];
} else {
// Normal: Profilname (aus profiles.ini)
args = ["-no-remote", "-P", profileValue || "", "-foreground"];
}
let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
process.init(file);
process.run(false, args, args.length);
console.log(
"[PROFILSTARTER] Start:",
mode,
profileValue,
"EXE:",
exePath || defaultPath,
"ARGS:",
args.join(" ")
);
} catch (e) {
console.error("[PROFILSTARTER] Start Fehler:", e);
}
}
// ============== MENU ITEM (angepasst: mode weiterreichen) ==============
function addProfileItem(aDocument, menupopup, label, profileValue, exePath, iconURI = null, mode = "name") {
const xulNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
let item = aDocument.createElementNS(xulNS, "menuitem");
item.setAttribute("label", label);
if (iconURI) {
item.setAttribute("class", "menuitem-iconic");
item.setAttribute("image", iconURI);
}
item.addEventListener("command", () => startProfile(profileValue, exePath, mode));
menupopup.appendChild(item);
}
function loadProfilesWithNiceNames(aDocument, menupopup) {
const ICON_BASE = "file:///C:/FoxIcons/";
const INI_PATH = "C:\\Users\\Old Man\\AppData\\Roaming\\Mozilla\\Firefox\\profiles.ini";
try {
let iniFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
iniFile.initWithPath(INI_PATH);
if (!iniFile.exists()) {
addProfileItem(aDocument, menupopup, "❌ profiles.ini fehlt", "", null, null);
return;
}
const iniParser = Components.classes["@mozilla.org/xpcom/ini-parser-factory;1"]
.getService(Components.interfaces.nsIINIParserFactory)
.createINIParser(iniFile);
for (let section of iniParser.getSections()) {
if (!section.startsWith("Profile")) continue;
let profileNameRaw = iniParser.getString(section, "Name") || section.replace("Profile", "");
let eintrag = PROFIL_NAMEN[profileNameRaw];
let niceName, iconURI = null;
if (eintrag && typeof eintrag === "object") {
niceName = eintrag.name;
if (eintrag.icon) iconURI = ICON_BASE + eintrag.icon;
} else {
niceName = profileNameRaw + " (unbekannt)";
}
addProfileItem(aDocument, menupopup, niceName, profileNameRaw, null, iconURI);
}
} catch (e) {
console.error("[PROFILSTARTER] INI Fehler:", e);
addProfileItem(aDocument, menupopup, "❌ profiles.ini Fehler", "", null, null);
}
}
function buildPopupIfNeeded() {
const button = document.getElementById(btn_id);
if (!button) return null;
if (button.getAttribute("profiles-menu-built") === "true") {
return document.getElementById(POPUP_ID);
}
const xulNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
let popup = document.getElementById(POPUP_ID);
if (!popup) {
popup = document.createElementNS(xulNS, "menupopup");
popup.setAttribute("id", POPUP_ID);
button.appendChild(popup);
} else {
// ggf. vorherige Einträge löschen
while (popup.firstChild) popup.removeChild(popup.firstChild);
}
// Profile aus profiles.ini
loadProfilesWithNiceNames(document, popup);
// Portable Profile (wie bisher: mode default="name")
addProfileItem(document, popup,
"Portable U Nightly 3 🔥", "profile",
"G:\\Portable.Firefox.Updater.3\\Firefox Nightly x64 Launcher.exe",
"file:///C:/FoxIcons/Nightly.png"
);
addProfileItem(document, popup,
"️Portable U Stable 3 🔥 ", "profile",
"G:\\Portable.Firefox.Updater.3\\Firefox Stable x64 Launcher.exe",
"file:///C:/FoxIcons/Finale.png"
);
addProfileItem(document, popup,
"️Portable U Beta 3 🔥 ", "profile",
"G:\\Portable.Firefox.Updater.3\\Firefox Beta x64 Launcher.exe",
"file:///C:/FoxIcons/Beta.png"
);
addProfileItem(document, popup,
"Portable U Nightly 1 🔥", "profile",
"G:\\Portable.Firefox.Updater.1\\Firefox Nightly x64 Launcher.exe",
"file:///C:/FoxIcons/Nightly.png"
);
addProfileItem(document, popup,
"️Portable U Stable 1 🔥 ", "profile",
"G:\\Portable.Firefox.Updater.1\\Firefox Stable x64 Launcher.exe",
"file:///C:/FoxIcons/Finale.png"
);
addProfileItem(document, popup,
"️Portable U Beta 1 🔥 ", "profile",
"G:\\Portable.Firefox.Updater.1\\Firefox Beta x64 Launcher.exe",
"file:///C:/FoxIcons/Beta.png"
);
addProfileItem(document, popup,
"Portable U Nightly 2 🔥", "profile",
"G:\\Portable.Firefox.Updater.2\\Firefox Nightly x64 Launcher.exe",
"file:///C:/FoxIcons/Nightly.png"
);
addProfileItem(document, popup,
"️Portable U Stable 2 🔥 ", "profile",
"G:\\Portable.Firefox.Updater.2\\Firefox Stable x64 Launcher.exe",
"file:///C:/FoxIcons/Finale.png"
);
addProfileItem(document, popup,
"️Portable U Beta 2 🔥 ", "profile",
"G:\\Portable.Firefox.Updater.2\\Firefox Beta x64 Launcher.exe",
"file:///C:/FoxIcons/Beta.png"
);
addProfileItem(document, popup,
"Portable U Nightly 4 🔥", "profile",
"G:\\Portable.Firefox.Updater.4\\Firefox Nightly x64 Launcher.exe",
"file:///C:/FoxIcons/Nightly.png"
);
addProfileItem(document, popup,
"️Portable U Stable 4 🔥 ", "profile",
"G:\\Portable.Firefox.Updater.4\\Firefox Stable x64 Launcher.exe",
"file:///C:/FoxIcons/Finale.png"
);
addProfileItem(document, popup,
"️Portable U Beta 4 🔥 ", "profile",
"G:\\Portable.Firefox.Updater.4\\Firefox Beta x64 Launcher.exe",
"file:///C:/FoxIcons/Beta.png"
);
// ✅ Firefox3p: Profilordner direkt starten (kein Profilmanager)
addProfileItem(document, popup,
"️Firefox3p 🔥 ",
"G:\\Firefox Test\\Firefox3p\\Profilordner",
"G:\\Firefox Test\\Firefox3p\\Firefox64\\firefox.exe",
"file:///C:/FoxIcons/Finale.png",
"dir"
);
button.setAttribute("profiles-menu-built", "true");
return popup;
}
function click_button() {
let button = document.getElementById(btn_id);
if (!button) return;
if (button.hasAttribute("listener-added"))
return;
button.setAttribute("listener-added", "true");
// Kontextmenü unterdrücken
button.addEventListener("contextmenu", event => {
event.preventDefault();
});
// Klick: Popup öffnen (links oder rechts)
button.addEventListener('click', event => {
event.preventDefault();
event.stopPropagation();
// CSS ist jetzt schon beim Start aktiv (injectUserCSS ist idempotent),
injectUserCSS();
let popup = buildPopupIfNeeded();
if (!popup) return;
// Popup am Button öffnen
try {
popup.openPopup(button, "after_start", 0, 0, false, false);
} catch (e) {
console.error("[PROFILSTARTER] openPopup Fehler:", e);
}
});
}
// Widget anlegen (nur einmal versuchen)
try {
CustomizableUI.createWidget({
id: btn_id,
defaultArea: CustomizableUI.AREA_NAVBAR,
label: btn_label,
tooltiptext: btn_tooltiptext,
onCreated: (this_button) => {
this_button.style.listStyleImage = 'url("' + ImagePath + '")';
this_button.style.minWidth = 'fit-content';
}
});
} catch (e) {
// Widget existiert evtl. schon -> ignorieren
}
// Listener pro Fenster setzen
function initForWindow() {
// ✅ CSS sofort verfügbar machen (damit das Icon von Anfang an stimmt)
injectUserCSS();
if (window.readyState !== "loading") {
setTimeout(click_button, 300);
} else {
window.addEventListener("DOMContentLoaded", () => setTimeout(click_button, 300));
}
}
initForWindow();
window.addEventListener('aftercustomization', () => {
injectUserCSS();
setTimeout(() => click_button(), 100);
});
})();
Alles anzeigen