Any Imacros Command/Script To Retrieve Firefox Profile Name

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
ysl78
Posts: 2
Joined: Mon Jan 29, 2018 4:27 pm

Any Imacros Command/Script To Retrieve Firefox Profile Name

Post by ysl78 » Mon Jan 29, 2018 4:56 pm

Hi,

Anyone know Imacros command or script which able to retrieve current running firefox profile name.Thanks.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Any Imacros Command/Script To Retrieve Firefox Profile

Post by chivracq » Mon Jan 29, 2018 6:12 pm

ysl78 wrote:Hi,

Anyone know Imacros command or script which able to retrieve current running firefox profile name.Thanks.
CIM...! :mrgreen: (Read my Sig...)

Hum..., interesting Qt but it doesn't look very complicated to find a Solution, all Info/Data you are looking for is displayed on 'about:profiles' for example...:

Code: Select all

VERSION BUILD=8970419 RECORDER=FX
TAB T=1

URL GOTO=about:profiles
WAIT SECONDS=0.5

TAG POS=1 TYPE=TH ATTR=TXT:Root*
SET !EXTRACT NULL
TAG POS=R1 TYPE=TD ATTR=* EXTRACT=TXT
SET Root_Prf EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('Profiles\'); y=x[1].split(' '); z=y[0]; z;")

TAG POS=1 TYPE=TH ATTR=TXT:Local*
SET !EXTRACT NULL
TAG POS=R1 TYPE=TD ATTR=* EXTRACT=TXT
SET Local_Prf EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('Profiles\'); y=x[1].split(' '); z=y[0]; z;")

PROMPT Root_Profile:<SP>_{{Root_Prf}}_<BR>Local_Profile:<SP>_{{Local_Prf}}_
(Tested on iMacros for FF v8.9.7, FF v55.0.3, Win10_x64.)

I only have 1 (Default) Profile on my FF Env., you might need to adjust the 'POS=n' for the Header or the 'POS=Rn' for the Path if you have several Profiles...

Hum..., and this Script doesn't seem to work on Pale Moon (where I do have several Profiles...) (PM v26.3.3 + iMacros for FF v8.8.2) as PM doesn't seem to support 'about:profiles'.
Last edited by chivracq on Thu Jul 05, 2018 9:39 pm, edited 1 time in total.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Any Imacros Command/Script To Retrieve Firefox Profile

Post by chivracq » Wed Feb 21, 2018 8:25 pm

Pfff...!, there is no need to kind of spam the Forum by opening a Duplicate Thread (which will be deleted or merged with this one if it gets any Replies...), you could better follow up in this current one, even after 3 weeks...! :roll:

Duplicate Thread:
- Extract Number From Firefox Profiles Name Directory Path
ysl78 wrote:I am using function below to extract number from Firefox profiles name directory path:

Code: Select all

function profile(){
profile =  "CODE:";
profile +=  "VERSION BUILD=8970419 RECORDER=FX" + "\n";
profile +=  "TAB T=1" + "\n";
profile +=  "URL GOTO=about:cache" + "\n";
profile +=  "WAIT SECONDS=1" + "\n";
profile +=  "TAG POS=1 TYPE=h2 ATTR=TXT:disk" + "\n";
profile +=  "SET !EXTRACT NULL" + "\n";
profile +=  "TAG POS=R4 TYPE=TD ATTR=* EXTRACT=TXT" + "\n";
profile +=  "SET !VAR2 EVAL(\"var s='{{!EXTRACT}}'; var x,y,z,v,w; x=s.split(' '); y=x[1].split(' '); z=y[0];w=z.substr(0,8);v=w.match(/\\d+/g);v\")" + "\n";
profile +=  "SET !extract {{!VAR2}}" + "\n";
iimPlay(profile);
var ret = iimGetExtract();
return ret;
}
I am able to extract desire number "534 " from "C:\Users\USER\AppData\Local\Mozilla\Firefox\Profiles\2r33c5ze.Default User534\cache2 " with EVAL in function above. But when I try run same function on other profiles "C:\Users\USER\AppData\Local\Mozilla\Firefox\Profiles\rfbztnlf.Default User535\cache2 " , it failed to give me number "535", it will give me back whole "C:\Users\USER\AppData\Local\Mozilla\Firefox\Profiles\rfbztnlf.Default User535\cache2 " . May i know any wrong with my EVAL expression to extract desire number?
Sorry, but no Follow-up on a Thread (while I notice you are clearly using "my" Syntax) and opening Duplicates (=SPAM...!) is a "Show-Stopper" for me to help Users any further... :roll:
And your new Thread still doesn't comply with the '(F)CIM' part, even if "v8.9.7 for FF" is "vaguely" mentioned in your Script...

Delete the Duplicate and follow up in this current Thread, and mention clearly your FCI, and I might still have a look... (hum..., in 3 weeks time of course...! :wink: )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Any Imacros Command/Script To Retrieve Firefox Profile

Post by chivracq » Thu Feb 22, 2018 9:01 pm

Hum, mini-Update anyway, for "other" Users who might follow/find this Thread, the 'about:cache' is indeed maybe more "practical" than the 'about:profiles' I had used in my own Example, and it works as well on Pale Moon (PM v26.3.3) while 'about:profiles' didn't work on PM v26.3.3.

But this Screen only mentions the current Profile in use for the Browser Instance.
(I do have 3 PM Profiles and the 2 other ones are not listed... I'm not sure about 'about:profiles' as I only had (and still have) 1 FF Profile when I had tested 3 weeks ago, and 'about:profiles' only works on FF...)

Still wondering a bit btw what could be the "Use" for retrieving the Profile Name from a Script, maybe for a Conditional 'CLEAR' of the Cookies if using the same Script on different Profiles, hum..., mouaw..., I don't know really... :?
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Any Imacros Command/Script To Retrieve Firefox Profile

Post by chivracq » Thu Jul 05, 2018 3:49 pm

And some other Update, now 6 months later... 8)

(Pity @OP in this Thread never followed up on their Thread (=> Spanking deserved...! :shock: ), except opening a Duplicate 3 weeks later (=> Double Spanking deserved...! :shock: :shock: ), which like expected got deleted by the Forum Admin :D , tja...! :roll: )

But OK, I was saying...:
chivracq wrote:Still wondering a bit btw what could be the "Use" for retrieving the Profile Name from a Script, maybe for a Conditional 'CLEAR' of the Cookies if using the same Script on different Profiles, hum..., mouaw..., I don't know really... :?
=> Here is some new/current Thread with a possible Use/Need for identifying the current FF-Profile...:
- Fiddler + imacros multi-threading
(The Thread is just "starting" [2018-07-05], but it will probably be/become "Interesting", I think, ah-ah...! 8) )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
truongfiu-vn
Posts: 3
Joined: Mon Jan 14, 2019 9:51 am
Contact:

Re: Any Imacros Command/Script To Retrieve Firefox Profile Name

Post by truongfiu-vn » Mon Jul 01, 2019 6:48 am

I found the best method to get name of current profile. Using some script from about:profiles page. It's long, but very fast.

Code: Select all

function getCurrentProfile() {
  "use strict";

  const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;

  Cu.import("resource://gre/modules/Services.jsm");
  Cu.import("resource://gre/modules/XPCOMUtils.jsm");

  XPCOMUtils.defineLazyServiceGetter(
    this,
    "ProfileService",
    "@mozilla.org/toolkit/profile-service;1",
    "nsIToolkitProfileService"
  );

  const bundle = Services.strings.createBundle(
    "chrome://global/locale/aboutProfiles.properties");

  function findCurrentProfile() {
    let cpd;
    try {
      cpd = Cc["@mozilla.org/file/directory_service;1"]
              .getService(Ci.nsIProperties)
              .get("ProfD", Ci.nsIFile);
    } catch (e) {}

    if (cpd) {
      let itr = ProfileService.profiles;
      while (itr.hasMoreElements()) {
        let profile = itr.getNext().QueryInterface(Ci.nsIToolkitProfile);
        if (profile.rootDir.path == cpd.path) {
          return profile;
        }
      }
    }

    try {
      return ProfileService.selectedProfile;
    } catch (e) {
      return null;
    }
  }

  function display(profileData) {

    let nameStr = bundle.formatStringFromName("name", [profileData.profile.name], 1);

    if (profileData.isCurrentProfile) {
      let currentProfileStr = bundle.GetStringFromName("currentProfile");
      return nameStr;
    }

  }

  let defaultProfile;
  try {
    defaultProfile = ProfileService.defaultProfile;
  } catch (e) {}

  let currentProfile = findCurrentProfile() || defaultProfile;

  let iter = ProfileService.profiles;
  while (iter.hasMoreElements()) {
    let profile = iter.getNext().QueryInterface(Ci.nsIToolkitProfile);
    let cprofile = display({ profile, isDefault: profile == defaultProfile, isCurrentProfile: profile == currentProfile });
    if (cprofile!=undefined) return cprofile;
  }
}

currentProfile = getCurrentProfile();
iimDisplay(currentProfile );
truongbuidp@gmail.com From VN
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Any Imacros Command/Script To Retrieve Firefox Profile Name

Post by chivracq » Mon Jul 01, 2019 8:28 am

truongfiu-vn wrote:
Mon Jul 01, 2019 6:48 am
I found the best method to get name of current profile. Using some script from about:profiles page. It's long, but very fast.

Code: Select all

function getCurrentProfile() {
  "use strict";

  const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;

  Cu.import("resource://gre/modules/Services.jsm");
  Cu.import("resource://gre/modules/XPCOMUtils.jsm");

  XPCOMUtils.defineLazyServiceGetter(
    this,
    "ProfileService",
    "@mozilla.org/toolkit/profile-service;1",
    "nsIToolkitProfileService"
  );

  const bundle = Services.strings.createBundle(
    "chrome://global/locale/aboutProfiles.properties");

  function findCurrentProfile() {
    let cpd;
    try {
      cpd = Cc["@mozilla.org/file/directory_service;1"]
              .getService(Ci.nsIProperties)
              .get("ProfD", Ci.nsIFile);
    } catch (e) {}

    if (cpd) {
      let itr = ProfileService.profiles;
      while (itr.hasMoreElements()) {
        let profile = itr.getNext().QueryInterface(Ci.nsIToolkitProfile);
        if (profile.rootDir.path == cpd.path) {
          return profile;
        }
      }
    }

    try {
      return ProfileService.selectedProfile;
    } catch (e) {
      return null;
    }
  }

  function display(profileData) {

    let nameStr = bundle.formatStringFromName("name", [profileData.profile.name], 1);

    if (profileData.isCurrentProfile) {
      let currentProfileStr = bundle.GetStringFromName("currentProfile");
      return nameStr;
    }

  }

  let defaultProfile;
  try {
    defaultProfile = ProfileService.defaultProfile;
  } catch (e) {}

  let currentProfile = findCurrentProfile() || defaultProfile;

  let iter = ProfileService.profiles;
  while (iter.hasMoreElements()) {
    let profile = iter.getNext().QueryInterface(Ci.nsIToolkitProfile);
    let cprofile = display({ profile, isDefault: profile == defaultProfile, isCurrentProfile: profile == currentProfile });
    if (cprofile!=undefined) return cprofile;
  }
}

currentProfile = getCurrentProfile();
iimDisplay(currentProfile );
Main "Purpose" of my Post is to quote this User (Vietnamese IP), starting to "act" a bit strange... :?
(Only User with a Vietnamese IP I think, that I granted Access to the Forum since Jan 2018... (=> 99.9% Spammers... :roll: ))
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
User avatar
thecoder2012
Posts: 446
Joined: Sat Aug 15, 2015 5:14 pm
Location: Internet
Contact:

Re: Any Imacros Command/Script To Retrieve Firefox Profile Name

Post by thecoder2012 » Wed Jul 03, 2019 2:06 pm

Profiles? Useless in my eyes. I love my privacy. I have no profile (except default) or disk cache (too slow with NVMe SSD). :shock:
chivracq wrote:
Wed Feb 21, 2018 8:25 pm
Duplicate Thread:
- Extract Number From Firefox Profiles Name Directory Path
Not longer. Errormessage "The requested topic does not exist.". :lol:
truongfiu-vn wrote:
Mon Jul 01, 2019 6:48 am
I found the best method to get name of current profile. Using some script from about:profiles page. It's long, but very fast.
I'm unsure but new background window is faster with imacros and js. See my other post.
chivracq wrote:
Mon Jan 29, 2018 6:12 pm
Hum..., and this Script doesn't seem to work on Pale Moon (where I do have several Profiles...) (PM v26.3.3 + iMacros for FF v8.8.2) as PM doesn't seem to support 'about:profiles'.
I'm unsure. I have no profiles but I can create a new profile under 'about:profiles'.
palemoon_profiles.jpg
Okay 'about:cache' is not better in my browser (pale moon 28.6.0, 64-bit):
palemoon_cache.jpg
Join 9kw.eu Captcha Service now and let your iMacros continue downloads and scripts while you sleep. - Custom iMacros? Contact me! :idea:
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Any Imacros Command/Script To Retrieve Firefox Profile Name

Post by chivracq » Tue Feb 04, 2020 3:51 pm

Hum..., taking "Advantage" of @OP checking the Forum right now to bump this Thread which was quite interesting... :P

Pity @OP (= @ysl78) never bothered to follow up, even though I asked them several times to do so... :(
Don't be "surprised" if me and other Advanced Users don't want to help you again, next time you'll open a Thread on the Forum..., tja...! :roll:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply