How to make addon detect if Firefox is portable version?

Talk about add-ons and extension development.
Post Reply
yajd
Posts: 55
Joined: February 3rd, 2014, 6:02 pm

How to make addon detect if Firefox is portable version?

Post by yajd »

Hi all,
I was wondering how can I detect from my addon if the firefox in use is Firefox portable.

Thanks
User avatar
patrickjdempsey
Posts: 23686
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC
Contact:

Re: How to make addon detect if Firefox is portable version?

Post by patrickjdempsey »

Just an FYI to everyone else, yes this has already been posted to Portable Apps forum:
http://portableapps.com/node/41436
Tip of the day: If it has "toolbar" in the name, it's crap.
What my avatar is about: https://addons.mozilla.org/en-US/seamonkey/addon/sea-fox/
User avatar
LoudNoise
New Member
Posts: 39900
Joined: October 18th, 2007, 1:45 pm
Location: Next door to the west

Re: How to make addon detect if Firefox is portable version?

Post by LoudNoise »

Assuming it is possible, I would simply look at what drive the profile is on. If it is C or D then it is likely to not to be portable. While it is possible that some strange person might put their profile on a G: harddrive I would suspect they are the sort of folks who no one should care about.
Post wrangler
"Choose between the Food Select Feature or other Functions. If no food or function is chosen, Toast is the default."
Noitidart
Posts: 1168
Joined: September 16th, 2007, 8:01 am

Re: How to make addon detect if Firefox is portable version?

Post by Noitidart »

Not everyone uses C though :(

This is turning out to be quite tough :(
User avatar
LoudNoise
New Member
Posts: 39900
Joined: October 18th, 2007, 1:45 pm
Location: Next door to the west

Re: How to make addon detect if Firefox is portable version?

Post by LoudNoise »

A vast majority use C: , those who don't are using D:. . Should someone who uses a hard drive to store a profile but does not use either of these drives then it is time to figure out how to make an exception. Before then, it can safely be ignored.
Post wrangler
"Choose between the Food Select Feature or other Functions. If no food or function is chosen, Toast is the default."
rais
Posts: 1083
Joined: May 25th, 2011, 8:57 pm

Re: How to make addon detect if Firefox is portable version?

Post by rais »

yajd wrote:Hi all,
I was wondering how can I detect from my addon if the firefox in use is Firefox portable.

when you startup Portable, it says PORTABLE in the splash screen.
when you click Show Folder, and xxxxxxxx.default does not show up in the left panel, it's Portable.

I don't know how you can use these facts, but those are the facts
Noitidart
Posts: 1168
Joined: September 16th, 2007, 8:01 am

Re: How to make addon detect if Firefox is portable version?

Post by Noitidart »

rais wrote:
yajd wrote:Hi all,
I was wondering how can I detect from my addon if the firefox in use is Firefox portable.

when you startup Portable, it says PORTABLE in the splash screen.
when you click Show Folder, and xxxxxxxx.default does not show up in the left panel, it's Portable.

I don't know how you can use these facts, but those are the facts

No way that's very interesting! Where do you find this show folder button?


LoudNoise wrote:A vast majority use C: , those who don't are using D:. . Should someone who uses a hard drive to store a profile but does not use either of these drives then it is time to figure out how to make an exception. Before then, it can safely be ignored.

Ah thanks man for the input ill keep it in mind if i can't figure out anything else :)
User avatar
LoudNoise
New Member
Posts: 39900
Joined: October 18th, 2007, 1:45 pm
Location: Next door to the west

Re: How to make addon detect if Firefox is portable version?

Post by LoudNoise »

There is a rational way and then there is an overly involve way. I sincerely doubt if the rational way would cause you any harm. Unless your extension is something that is world changing this should be something that you take to heart.
Post wrangler
"Choose between the Food Select Feature or other Functions. If no food or function is chosen, Toast is the default."
rais
Posts: 1083
Joined: May 25th, 2011, 8:57 pm

Re: How to make addon detect if Firefox is portable version?

Post by rais »

! Where do you find this show folder button?

click Help
click Troubleshooting Info

the Show Folder button is 7 ± inches down from the top of the page
User avatar
Vano
Posts: 403
Joined: December 26th, 2007, 8:21 pm

Re: How to make addon detect if Firefox is portable version?

Post by Vano »

LoudNoise wrote:A vast majority use C: , those who don't are using D:. . Should someone who uses a hard drive to store a profile but does not use either of these drives then it is time to figure out how to make an exception. Before then, it can safely be ignored.
Majority doesn't mean everyone and one should do as much as possible for everyone, not majority.

The difference between portable and non portable is not location of executable file but profile.
Non-portable is using profile.ini file located in (on windows) %APPDATA%\Mozilla\Firefox\ which contains path to the profile. That profile would in relative path to profile.ini in %APPDATA%\Mozilla\Firefox\Profiles\XXXX
If you check the path of current profile against the path in that profile.ini and it's in %APPDATA%\Mozilla\Firefox\Profiles\XXXX then it's 100% non-portable.
For the rest treat it as portable.

On Linux is probably different story, since the default path may vary distribution-to-distribution.
User avatar
patrickjdempsey
Posts: 23686
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC
Contact:

Re: How to make addon detect if Firefox is portable version?

Post by patrickjdempsey »

rais wrote:when you click Show Folder, and xxxxxxxx.default does not show up in the left panel, it's Portable.

I don't know how you can use these facts, but those are the facts


That is NOT a fact. If the folder under Show Folder is not an "xxx.default" folder, that just means someone is using a non-default profile. Developers for instance often use several profiles so they can have different sets of addons, or clear cookies for testing. And in fact, many of the reasons people like to use "portable" are the same reasons someone might use multiple profiles, and those profiles can be on any drive.
Tip of the day: If it has "toolbar" in the name, it's crap.
What my avatar is about: https://addons.mozilla.org/en-US/seamonkey/addon/sea-fox/
Noitidart
Posts: 1168
Joined: September 16th, 2007, 8:01 am

Re: How to make addon detect if Firefox is portable version?

Post by Noitidart »

Thanks all for the input, i worked hard on trying to find a way but now decided that I'll just make a sperate release called ProfilistPortable. In the future i place to allow setting default profile and cuz protable doesnt support profiles.ini it will take a lot of different code to support portable. Combining this code with regular will just be messy.

I think this way is better so i get some stats on which OS'es are using portable. It's supposed to be Windows only but we'll see :)

Anyways thanks again.
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: How to make addon detect if Firefox is portable version?

Post by morat »

@yajd
@Noitidart

I don't get using UAppData...

http://portableapps.com/node/41436#comment-215532

UAppData = C:\Users\%USERNAME%\AppData\Roaming\Mozilla\Firefox
CurWorkD = [Drive]:\...\FirefoxPortable\App\Firefox

John T. Haller wrote:You could see if the PROGRAMFILES environment variable is a part of the CurWorkD. That will detect about 99% of local installs as local.

Code: Select all

var file = Components.classes["@mozilla.org/file/directory_service;1"].
  getService(Components.interfaces.nsIProperties).
  get("CurWorkD", Components.interfaces.nsIFile);
var environment = Components.classes["@mozilla.org/process/environment;1"].
  getService(Components.interfaces.nsIEnvironment);
if (file.path.indexOf(environment.get("ProgramFiles")) != 0) alert("Firefox Portable");
else alert("Firefox");

John T. Haller wrote:One other possibility, if you can check for the existence of a file, to look for FirefoxPortable.exe either in CurWorkD or two directories above CurWorkD.

Code: Select all

var file = Components.classes["@mozilla.org/file/directory_service;1"].
  getService(Components.interfaces.nsIProperties).
  get("CurWorkD", Components.interfaces.nsIFile);
var file1 = file.clone();
var file2 = file.clone().parent.parent;
file1.append("FirefoxPortable.exe");
file2.append("FirefoxPortable.exe");
if (file1.exists() || file2.exists()) alert("Firefox Portable");
else alert("Firefox");

I rather the FirefoxPortable.exe solution.
Post Reply