Wednesday, February 3, 2016

Enabling local "file:///"-links from remote websites in Firefox

When you have a MediaWiki at work, maybe you already know how annoying it is that Firefox protected their browser from local file links on remote webpages. For example, if you try to open a "file:///" or "file://///" URL from a page that was accessed over "http://", like often on a company MediaWiki-site (usually run from a NAS), Firefox will just silently do nothing. There's no error output, no popup, no page opening, nothing...

While this can be semi-solved with some extensions like LocalLink or Local Filesystem Links, these add-ons don't really give you expected functionality. You will probably still have to right click the links and select a menu added by the add-on, and left-clicking the links still won't do anything.

If you are one of those people that's like me and hates this handicap, you'll be looking for other ways of removing it, one that gives back full functionality like they were normal links again.
This is how I eventually did it in 5 easy steps:

1. Make sure any open window of Firefox is closed and Firefox is not running !!


2. Go to your Firefox profile-directory.

   (Should be something like: "C:\Users\<username>\AppData\Roaming\Mozilla\Firefox\Profiles\xxxxxxxx.default")

  If you can't find your profile-directory, do the following:

  - Open Firefox;
  - Open the Menu that's to the right of the search bar;
  - Click the '?';
  - Click 'Troubleshooting information';
  - Under 'Application Basics' you will see 'Profile Folder';
  - Click the 'Show Folder'-button;
  - Make sure to close Firefox again !

3. Locate 'Prefs.js' and open it with notepad.

4. Add these 3 lines to it. (You might want to turn of 'Word Wrap' in notepad and add them alphabetically, but no pressure. ;p):

user_pref("capability.policy.policynames", "localfilelinks");
user_pref("capability.policy.localfilelinks.sites", "http://www.example.com");
user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");

Of course you will need to replace "http://www.example.com" with the website you want this to work on. This can also be either the WINS name or the domain name of a NAS or a local webserver (ex.: "http://myserver" and "http://home.local").

If you want to add more than 1 url, just seperate them with spaces. Something like:

user_pref("capability.policy.localfilelinks.sites", "http://www.example.com http://myserver http://home.local");

This one will enable local file links natively on
 - www.example.com
 - myserver
 - home.local

5. Save and close the "Prefs.js" and start Firefox...

The links will now act like any other link on the chosen websites...
On any other page, the links will still remain dead, so as long as you do this only to sites you trust 100%, there's no security risk involved. ;)

Enjoy! ;)

Greetings,
     ~ Doctor N.