MozillaZine

How to make addon detect if Firefox is portable version?

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

Post Posted May 8th, 2014, 10:59 am

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

Thanks

patrickjdempsey

User avatar
 
Posts: 22763
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC

Post Posted May 8th, 2014, 5:26 pm

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/

LoudNoise
Moderator

User avatar
 
Posts: 39094
Joined: October 18th, 2007, 1:45 pm
Location: Next door to the west

Post Posted May 8th, 2014, 6:12 pm

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
“It's tough to make predictions, especially about the future.”
― Yogi Berra

Noitidart
 
Posts: 1042
Joined: September 16th, 2007, 8:01 am

Post Posted May 8th, 2014, 7:19 pm

Not everyone uses C though :(

This is turning out to be quite tough :(

LoudNoise
Moderator

User avatar
 
Posts: 39094
Joined: October 18th, 2007, 1:45 pm
Location: Next door to the west

Post Posted May 8th, 2014, 7:27 pm

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
“It's tough to make predictions, especially about the future.”
― Yogi Berra

rais
 
Posts: 1083
Joined: May 25th, 2011, 8:57 pm

Post Posted May 8th, 2014, 8:13 pm

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: 1042
Joined: September 16th, 2007, 8:01 am

Post Posted May 8th, 2014, 9:07 pm

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 :)

LoudNoise
Moderator

User avatar
 
Posts: 39094
Joined: October 18th, 2007, 1:45 pm
Location: Next door to the west

Post Posted May 8th, 2014, 9:19 pm

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
“It's tough to make predictions, especially about the future.”
― Yogi Berra

rais
 
Posts: 1083
Joined: May 25th, 2011, 8:57 pm

Post Posted May 8th, 2014, 9:31 pm

! 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

Vano

User avatar
 
Posts: 368
Joined: December 26th, 2007, 8:21 pm

Post Posted May 9th, 2014, 6:54 am

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.

patrickjdempsey

User avatar
 
Posts: 22763
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC

Post Posted May 9th, 2014, 9:17 am

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: 1042
Joined: September 16th, 2007, 8:01 am

Post Posted May 10th, 2014, 2:01 am

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: 1753
Joined: February 3rd, 2009, 6:29 pm

Post Posted May 10th, 2014, 8:59 am

@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.

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 0 guests