Make Mozilla Firefox desktop APP , Firefox –app argument

You probably reached to this article from this [chrome App] article. If not please visit [chrome App] 

Firefox App Screenshot

There might be some question in your mind

  1. What is Firefox/Chrome/ App ?
  2. What is difference between a webpage open in web browser and in Firefox/Chrome App?
  3. When do you want to make an Firefox/Chrome app?

All of this question is discussed in this article [why to make chrome/firefox app of your webpage

Does Mozilla Firefox supports –app argument like chrome?

No, Mozilla Firefox doesn’t support –app argument and it doesn’t have any similar argument. But don’t worry there is a workaround which gives the exact same result like chrome. Take a look at the above screenshot it is a Firefox app, it looks like same as chrome App right? So,lets learn how to make Firefox app.

How to make Firefox App?

  • I am a blogger/ Youtuber / Alien  
                       [follow this link to get App specially designed for you ]

  • I am a developer / Martian and I want to achieve this feature for Google chrome.
              [follow this link to get instructions for achieving this feature in Google Chrome]

  • I am a developer / Martian and I want to achieve this feature for Mozilla Firefox

So, lets build our Firefox App

Our building process is basically divided in three steps  And our goal is in one click it will open our webpage as App.
How to build Firefox app

Step 1

We have to create a Mozilla profile . A profile is like a user, Mozilla Firefox can have multiple profiles and each profile can have different setting [click this to know more about Mozilla Firefox profile]

Why do we need to create profile?

       We need our special settings to our App to work, and we don’t want to change the user’s main profile’s settings.It is very easy to create a Firfox profile

           For our convenience we will create two variables, one for Firefox path and another for profile directory where Firefox will store all the profile related data (which we will create), and we will also dump a configuration file in this directory.

set ffPath=”c:Program FilesMozilla Firefoxfirefox.exe”
set profileDir=”%APPDATA%MozillaFirefoxProfilesmozilaProfile” 

here,  %APPDATA% is system’s application data directory where all application stores its  files.

Step 1

Syntax : Firefox_path  – CreateProfile “path_to_store_profile_data”

%ffPath% -CreateProfile %profileDir%

            Outcome of this command is, It  will create a firefox profile and will store all the profile related data in ‘%profileDir%’ directory.

Step 2

               Now we have created a Mozilla profile, currently this profile will have all default settings/configuration, now we will override some default setting/configuration. Firefox reads the configuration from ‘pref.js’ file and we will modify this file, for our convince we have written all the needed configuration in a separate file we will just override the original file on the profile directory. 

xcopy /Y prefs.js %profileDir%

This will override the original prefs.js file with our file, which has all the needed configurations.

content of the prefs.js  file is 

/*Firefox  will open this URL as a welcome URL on the startUp , which will be closed automatically*/ 
pref(“datareporting.policy.firstRunURL”, “data:text,<script>window.close();</script>”); 
/*stop blocking popup*/ 
pref(“dom.disable_open_during_load”, false); 
/*give power to JS to close the window*/ 
pref(“dom.allow_scripts_to_close_windows”, true); 
pref(“”, true); 
/*Don’t give notification for setting Firefox  as default browser */
pref(“”, false);
/*On popup dont show URL bar*/ 
pref(“dom.disable_window_open_feature.location”, false);

 copy this contents and save is as prefs.js 

Step 3

We will do couple of things in this step.
  • Open Firefox with the profile that we have created as a new instance with a special URL which will inject some JavaScript and that will launch the our webpage as an App.
Syntax : Firefox_path -new-instance  -profile “profile_path” –url “url_you_want_to_open”

%ffPath% -new-instance -profile  “%profileDir%” -url “data:text <script>‘′,’_blank’, ‘width=680,h0ight=650’);window.close();</script>”

     Here the URL is a Special URL to run some JavaScript while loading the URL itself, this technique is also called JavaScript injecting, basically the JS specified in the URL will open a popup and kill the current browser. 

      Now combine all the steps in single bat file. Copy the below code and paste in a text editor and save it as .bat file and click it, make sure to change the Firefox path of your machine in line 2. Each line is discussed bellow.

@echo offset ffPath=”c:Program FilesMozilla Firefoxfirefox.exe”set profileDir=”%APPDATA%MozillaFirefoxProfilesmozilaProfile”taskkill /F /Fi “Windowtitle eq*”rd /S/Q %profileDir%mkdir %profileDir%%ffPath% -CreateProfile %profileDir%xcopy /Y prefs.js %profileDir% > nulstart ” ” %ffPath% -new-instance -profile  “%profileDir%” -url “data:text,<script>‘′,’_blank’, ‘width=680,h0ight=650’);window.close();</script>”

Line 1: @echo off
don’t display anything on the prompt

Line 2: set ffPath=”c:Program FilesMozilla Firefoxfirefox.exe”
variable to store Firefox path

Line 3: set profileDir=”%APPDATA%MozillaFirefoxProfilesmozilaProfile”
variable to store profile directory path, which uses another variable %APPDATA% to get system application data directory

Line 4: taskkill /F /Fi “Windowtitle eq*”
It will kill the previous app

Line 5: rd /S/Q mozilaProfile
Remove the previous profile directory, to start fresh

line 6: mkdir %profileDir%
create directory “mozilaProfile” inside  “%APPDATA%MozillaFirefoxProfiles

Line 7: %ffPath% -CreateProfile %profileDir%
create a new Firefox profile and dump all the profile data inside ‘%profileDir%‘ directory

Line 8: xcopy /Y prefs.js %profileDir% > nul
override profile’s prefs.js with our file which will contain all our settings. Here ” > nul” is optional it is only used to stop displaying anything on prompt

line 9: start ” ” %ffPath% -new-instance -profile  “%profileDir%” -url “data:text,<script>‘′,’_blank’, ‘width=680,h0ight=650’);window.close();</script>”

start ” ” is used to release the command prompt without waiting Firefox to close
rest of the command  is  to Start Firefox as a new instance  with “%profileDir%” as a profile directory and open the URL.

Yes this is too much, but this is the only way you can achieve this App feature.Thanks for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *