2002Andreas Wenn Du nur Deine "Testprofile" einbinden möchtest, ....

ScrollTopAndBottom.uc.js und Open with.uc.js zeigen keine Icons mehr an im Nightly
-
2002Andreas -
31. Juli 2025 um 11:53 -
Erledigt
-
-
Wenn Du nur..
Hallo Mira, danke auch dir
Aber auch dann wird wieder das Standard Profil (Test-Ohne) geöffnet
-
Aber auch dann wird wieder das Standard Profil (Test-Ohne) geöffnet
Wenn Du "Clean" auswählst?
-
-
2002Andreas Interessant!
Reicht es Dir, wenn das Menü nur bei Links erscheint?
Also wenn Du nur Links mit einem anderen Browser und/oder einem anderen Firefoxprofil öffnen willst? -
nur bei Links erscheint?
Am besten wäre es dann, wenn: Seite öffnen mit...funktionieren würde.
Mit diesem Skript(kennst du sicherlich)
, und einem eigenen Button funktioniert es ja einwandfrei:
JavaScript
Alles anzeigen(function() { if (location.href !== 'chrome://browser/content/browser.xhtml') return; try { CustomizableUI.createWidget({ id: 'aboutprofiles-button', type: 'custom', defaultArea: CustomizableUI.AREA_NAVBAR, onBuild: function(aDocument) { let toolbaritem = aDocument.createXULElement('toolbarbutton'); let currentProfileDirectory = Services.dirsvc.get("ProfD", Ci.nsIFile).path.replace(/\\/g, "/"); // Pfadangabe zum Profilordner let buttonicon = "N.svg" // Name & Dateiendung des anzuzeigenden Symbols toolbaritem.onclick = event => onClick(event); var props = { id: 'aboutprofiles-button', class: 'toolbarbutton-1 chromeclass-toolbar-additional', removable: 'true', label: 'Profil Clean', accesskey: '', tooltiptext: 'Profil Clean', style: 'list-style-image: url("' + ("file:" + currentProfileDirectory + "/chrome/icons/" + buttonicon) +'");', }; for (var p in props) toolbaritem.setAttribute(p, props[p]); return toolbaritem; } }); } catch(e) { }; function onClick(event) { if (event.button != 0){ return; } let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile); let arguments = ["-P", "Clean"]; // Profil wird ausgewählt Hier "XXX" das gewünschte Profil eintragen, z.B. Test file.initWithPath("C:\\Program Files\\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 } }) ();
Evtl. bringt dich das ja auf den richtigen Gedanken für das andere Skript.
Aber wie schon gesagt, macht euch bitte keinen Stress damit
-
2002Andreas Hast du die Änderung aus #111 in deinem Skript übernommen?
args = args.split(" ").map(a => a.replace("$1", openURL)); //Split bei Leerzeichen
Ich glaube, man sollte das bestehende OpenWith-Skript aber so umschreiben, dass man die Parameter in einzelnen Strings übergeben kann. Dann hat man das ganze Problem mit dem "Aufdröseln" mittels split() nicht mehr...
-
Bitte Testen!
JavaScript
Alles anzeigen// ==/UserScript== (function() { "use strict"; if (location != 'chrome://browser/content/browser.xhtml') return; /* Vor Verwendung, Pfad auf eigene Umgebung ändern(\ wird durch \\ ersetzt) Zum Übergeben von Argumenten, wie folgt vorgehen: C:\\Program Files\\Internet Explorer\\iexplore.exe<>$1 Argument Argument ※ $1 wird in URL umgewandelt */ const BrowserPath = { "Nightly": "C:\\Program Files\\Firefox Nightly\\firefox.exe", "Firefox": "C:\\Program Files\\Mozilla Firefox\\firefox.exe", "Vivaldi": "C:\\Users\\Andreas\\AppData\\Local\\Vivaldi\\Application\\vivaldi.exe", "Edge": "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe", "IE": "C:\\Program Files\\Internet Explorer\\iexplore.exe", "Test ohne": "C:\\Program Files\\Mozilla Firefox\\firefox.exe<>$1 -no-remote -P Test ohne -foreground", "Clean": "C:\\Program Files\\Mozilla Firefox\\firefox.exe<>$1 -no-remote -P Clean -foreground", }; const FlatMenu = false; const OpenWith = { start: function() { const cm = document.getElementById("contentAreaContextMenu"); cm.addEventListener("popupshowing", function(e) { if (e.target == this) { OpenWith.onpopup(e); } }, false); }, createMenu: function() { if (this.pageItem) { return; } const contextMenu = document.getElementById("contentAreaContextMenu"); const pageMenu = this.$C("menu", { id: "context-open-with-page", label: "Seite öffnen mit:" }); contextMenu.insertBefore(pageMenu, contextMenu.querySelector(":scope > #context-bookmarkpage, :scope > #context-savepage")); this.pageItem = this.createMenuItem(pageMenu, "openPage", FlatMenu ? "Seite öffnen mit $1 " : " $1"); }, createMenuItem: function(menu, method, format) { const frag = document.createDocumentFragment(); let menuitem = []; for (let i of Object.keys(BrowserPath)) { const item = this.$C("menuitem", { label: format.replace("$1", i), class: "menuitem-iconic", image: "moz-icon:file:///" + encodeURIComponent(BrowserPath[i].split("<>")[0]) + "?size=16", value: JSON.stringify([method, i]), }); item.addEventListener("command", this, false); frag.appendChild(item); menuitem[menuitem.length] = item; } if (!FlatMenu) { const menupopup = this.$C("menupopup"); menupopup.appendChild(frag); menu.appendChild(menupopup); menuitem = [menu]; } else { const parent = menu.parentNode; parent.insertBefore(frag, menu); parent.removeChild(menu); } return menuitem; }, $C: function(tag, attrs) { const elem = document.createXULElement(tag); if (attrs) { for (let key of Object.keys(attrs)) elem.setAttribute(key, attrs[key]); } return elem; }, onpopup: function(e) { this.createMenu(); const isHtml = /^(https?|file):/.test(gBrowser.currentURI.spec); const pageItemHidden = !isHtml || gContextMenu.onLink || gContextMenu.onTextInput; const pageItem = this.pageItem; for (let i = 0, l = pageItem.length; i < l; i++) { pageItem[i].hidden = pageItemHidden; } }, handleEvent: function(event) { if (event.type === "command") { const [method, key] = JSON.parse(event.originalTarget.getAttribute("value")); const url = gBrowser.currentURI.spec; this.launch(BrowserPath[key], url); } }, launch: function(browserPath, openURL) { let [path, args] = browserPath.split("<>"); if (args) { args = args.split(" ").map(a => a.replace("$1", openURL)); // Split bei Leerzeichen } else { args = [openURL]; } console.log("Call: " + args); const file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile); file.initWithPath(path); const process = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess); process.init(file); process.run(false, args, args.length, {}); }, }; OpenWith.start(); })();
Und wer Links einfach in einem anderen Browser oder in einem anderen Firefoxprofil öffnen möchte:
JavaScript
Alles anzeigen(function() { "use strict"; if (location != 'chrome://browser/content/browser.xhtml') return; /* Vor Verwendung, Pfad auf eigene Umgebung ändern(\ wird durch \\ ersetzt) Zum Übergeben von Argumenten, wie folgt vorgehen: C:\\Program Files\\Internet Explorer\\iexplore.exe<>$1 Argument Argument ※ $1 wird in URL umgewandelt */ const BrowserPath = { "Nightly": "C:\\Program Files\\Firefox Nightly\\firefox.exe", "Firefox": "C:\\Program Files\\Mozilla Firefox\\firefox.exe", "Vivaldi": "C:\\Users\\Andreas\\AppData\\Local\\Vivaldi\\Application\\vivaldi.exe", "Edge": "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe", "IE": "C:\\Program Files\\Internet Explorer\\iexplore.exe", "Test ohne": "C:\\Program Files\\Mozilla Firefox\\firefox.exe<>$1 -no-remote -P Test ohne -foreground", "Clean": "C:\\Program Files\\Mozilla Firefox\\firefox.exe<>$1 -no-remote -P Clean -foreground", }; const FlatMenu = false; const OpenWith = { start: function() { const cm = document.getElementById("contentAreaContextMenu"); cm.addEventListener("popupshowing", function(e) { if (e.target == this) { OpenWith.onpopup(e); } }, false); }, createMenu: function() { // Nur einmal ausführen if (this.linkItem) { return; } const contextMenu = document.getElementById("contentAreaContextMenu"); // Nur noch das Link-Menü erstellen const linkMenu = this.$C("menu", { id: "context-open-with-link", label: "Link öffnen mit:" }); contextMenu.insertBefore(linkMenu, contextMenu.querySelector(":scope > #context-sep-open")); // Nur noch die Menüeinträge für den Link erstellen this.linkItem = this.createMenuItem(linkMenu, "openLink", FlatMenu? "Link öffnen mit $1 ":" $1"); }, createMenuItem: function(menu, method, format) { const frag = document.createDocumentFragment(); let menuitem = []; for (let i of Object.keys(BrowserPath)) { const item = this.$C("menuitem", { label: format.replace("$1", i), class: "menuitem-iconic", image: "moz-icon:file:///" + encodeURIComponent(BrowserPath[i].split("<>")[0]) + "?size=16", value: JSON.stringify([ method, i ]), }); item.addEventListener("command", this, false); frag.appendChild(item); menuitem[menuitem.length] = item; } if (!FlatMenu) { const menupopup = this.$C("menupopup"); menupopup.appendChild(frag); menu.appendChild(menupopup); menuitem = [ menu ]; } else { const parent = menu.parentNode; parent.insertBefore(frag, menu); parent.removeChild(menu); } return menuitem; }, $C: function(tag, attrs) { const elem = document.createXULElement(tag); if (attrs) { for (let key of Object.keys(attrs)) elem.setAttribute(key, attrs[key]); } return elem; }, onpopup: function(e) { this.createMenu(); // Logik für das Seiten-Menü wurde entfernt. // Das Link-Menü wird nur angezeigt, wenn man auf einem Link ist. const isHtml = /^(https?|file):/.test(gBrowser.currentURI.spec); const linkItemHidden = !isHtml || !gContextMenu.onLink || gContextMenu.onTextInput; const linkItem = this.linkItem; for (let i = 0, l = linkItem.length; i < l; i++) { linkItem[i].hidden = linkItemHidden; } }, handleEvent: function(event) { if (event.type === "command") { // Da es nur noch "openLink" gibt, kann die Logik vereinfacht werden. const [ method, key ] = JSON.parse(event.originalTarget.getAttribute("value")); const url = gContextMenu.linkURL; // Es wird immer die Link-URL sein this.launch(BrowserPath[key], url); } }, launch: function(browserPath, openURL) { let [ path, args ] = browserPath.split("<>"); if (args) { args = args.split(" ").map(a => a.replace("$1", openURL)); } else { args = [ openURL ]; } const file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile); file.initWithPath(path); const process = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess); process.init(file); process.run(false, args, args.length, {}); }, }; OpenWith.start(); })();
Es lassen sich auch parallel betreiben!
-
Bitte Testen!
Hallo Mira, das funktioniert gut so, hast du toll gemacht, danke dafür
Ich werde beide Skripte mal mit meinen Daten befüllen und dann erneut testen.
Dauert aber etwas
-
Beitrag von BrokenHeart (
8. August 2025 um 18:01 )Dieser Beitrag wurde vom Autor aus folgendem Grund gelöscht: Hat sich erledigt... (8. August 2025 um 18:13 ). -
Jetzt ist es so, wenn ich hier klicke:
ergibt das:
Das Profil Clean lässt sich jetzt aufrufen, aber eben das andere nicht.
ob dort bei split() ein Leerzeichen eingetragen ist
Ich hatte das alles geprüft/geändert, hat trotzdem nicht funktioniert.
-
Ah,grrr.
Na klar! "Test ohne" wird als zwei Parameter interpretiert!
Mach mal "Test_ohne" daraus und ändere das auch im Skript.
Oder auch "Test-ohne". Eventuell funktioniert auch "Test.ohne". -
Mach mal "Test_ohne" daraus und ändere das auch im Skript.
Ah,grrr.
Ich habe das Profil mal unter about:profiles geändert:
Damit funktioniert es dann.
-
Oder auch "Test-ohne".
Nachdem ich das alles angepasst hatte, und deine beiden Skripte wieder in einer Datei habe, meine Pfade eingetragen...etc. sieht das jetzt so aus:
Bzw. so:
und alles funktioniert wie gewünscht
Mira, dir nochmals ganz herzlichen Dank für deine Zeit und Ausdauer
PS:
Nur als Info für dich, das reicht auch so schon:
-
In #138 hatte ich bereits die ggf anzupassende Schreibung des Profilnamens angemerkt
-
die ggf anzupassende Schreibung des Profilnamens angemerkt
Ich weiß, trotzdem hat es damit und dem alten Skipt nicht funktioniert. Erst die Änderungen allgmein von Mira führten zum Erfolg.
-
Hauptsache, das Problem ist gelöst
-
ändern und testen?
Dann erhalte ich dieses Popup:
Müsste also erst auswählen welches gestartet werden soll.
Moin,
sorry, das ist später antworte, welche Profile Name ist deine default Firefox Profile.
Für deine Profile Name in Profiles.ini, das Default=1 hinzufügen.
Zum Beispiel so:
-
Hi sam2008 Ich bin zwar nicht Andi, aber ich denke, es wird genau so sein, wie Du es gepostet hast!
Bei ihm ist halt nur die Zahlenfolge eine andere. -
welche Profile Name ist deine default Firefox Profile.
Test ohne
das Default=1 hinzufügen
Dadurch ändere ich dann nur das Standard Profil. Dann öffnet sich das Profil Clean, aber nicht das andere zusätzlich. Mira hat das Problem perfekt für mich gelöst, ich kann jetzt jedes Profil mit dem Skript aufrufen.
-