複数のprofile を 使う
ProfileManager を 別途起動することが面倒になったので作ってみた。
completer は 現在利用しているprofile のあるディレクトリに ある ディレクトリ 一覧が出ます。
"DefProfRt"経由でないのは、FirefoxPortable を利用しているからです。
private[fox] は引数なしだと 現在のprofileに".private"を付与して開きます。
firefox は、 引数なしは何もしません。
(function(){ const name = "firefox"; //https://developer.mozilla.org/index.php?title=Ja/Code_snippets/File_I%2F%2FO#section_3 const list = [ "ProfD", "DefProfRt", "UChrm", "DefRt", "PrfDef", "ProfDefNoLoc", "APlugns", "AChrom", "ComsD", "CurProcD", "Home", "TmpD", "ProfLD", //"resource:app ", ]; let properties = Cc["@mozilla.org/file/directory_service;1"] .getService(Ci.nsIProperties); let propertiesFile={}; for(let [,attr] in Iterator(list)){ let id = attr; propertiesFile.__defineGetter__(id,function() properties.get(id,Ci.nsIFile).QueryInterface(Ci.nsILocalFile)); } function exec_firefox(){ let file,proc; try{ file = propertiesFile.CurProcD; file.appendRelativePath("firefox.exe"); if(!file || !file.exists()){ liberator.echoerr(<>not found firefox.exe!</>); return; } proc = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess); proc.init(file); let(args=Array.splice(arguments,0)){ proc.run(false, args, args.length); } }catch(ex){ liberator.echoerr(ex); } } //https://developer.mozilla.org/ja/Command_Line_Options function exec_firefox_private(args){ let profile = args[0]; let path; if(profile){ let d = propertiesFile.ProfD.parent; d.append(profile); path = d.path; }else{ path = propertiesFile.ProfD.path+".private"; } exec_firefox( "-private", "--no-remote", "-profile", path ); } function exec_firefox_normal(args){ let profile = args[0]; if(!profile) return; let path = propertiesFile.ProfD.parent; path.append(profile); exec_firefox( "--no-remote", "-profile", path.path ); } function simpleEnumrator(enumlator){ while(enumlator.hasMoreElements()){ yield enumlator.getNext(); } } function completer_profile(context){ var dir = propertiesFile.ProfD.parent; let it = dir.directoryEntries; context.completions = [ [f.leafName, f.path] for(f in simpleEnumrator(dir.directoryEntries)) if(f.QueryInterface(Ci.nsIFile) && f.isDirectory()) ]; } commands.addUserCommand(["private[fox]"],"run firefox",exec_firefox_private,{ argCount: "1" ,completer: completer_profile },true); commands.addUserCommand(["firefox"],"run firefox",exec_firefox_normal,{ argCount: "1" ,completer: completer_profile },true); })();