3

My Firefox 40.0.3 home page is a local html file with links I frequently visit. How can I set a particular link in that file to always open in Private Browsing mode?

For example, I want to know if it's possible to modify
<a href="http://www.somewhere.com/">Somewhere</a>
so that when I click on the "Somewhere" link, it'll automatically open in a private browsing window.

(I know I can right-click on the link and then choose "Open Link in New Private Browsing Window" but I sometimes forget and click it directly.)

I'd prefer a solution that doesn't require an extension.

Edit: I came across a forum post indicating that what I want may not be possible: How to start firefox from command line as private browsing.

So, in case there's no direct way to do what I want, I'll use this script and bind it to a convenient keyboard shortcut:

#! /usr/bin/env bash

firefox -private-window http://www.somewhere.com/
4

1. The easy, totally insecure answer

The closest I could find for your specific case (Firefox on Linux, local homepage) is to simply point the link to a shell script that incorporates the command you are using:

firefox -private-window http://www.somewhere.com/

For example, I made a test script on my desktop and was able to run it by using the link

file:///home/foobar/Desktop/test.sh

and then pointing Firefox to always open shell scripts with /bin/bash.

I cannot stress enough what a huge security risk this implies!! I'm only posting this because it's a valid solution to your question, but you probably shouldn't use it if the computer is connected to the internet in any way (which kind of defeats the point). The reason being, if Firefox is set up to open shell scripts automatically, any webpage exploiting this vulnerability in your system can gain unrestricted user access, well beyond what a regular browser allows.

To see what I mean, just take your pick on one of these commands* and imagine clicking a link that pointed to it. :)

(*) oh, but don't actually run them.

2. The (significantly) more technical but effective workaround
This is superuser.com, after all

Disclaimer: you may have a little too much fun working on this solution.

Stemming off of the first answer, this solution works wonders if you know a little bit of programming. As a bonus, it works on both Linux and Windows, as long as you have the knowledge to code an executable for your platform. It fixes the security hole in the first answer by limiting the possible exploitations.

Basically, instead of relying on bash to run a shell script (which means big security issue), create your own program that opens files with your own extension (let's call it .firefoxlink). Inside the custom .firefoxlink file, it should specify the URL to open in private browsing mode.

Your program would read the file and then start a new firefox instance, just like the shell script does, using the -private-browsing flag. But with the advantage that that is the only thing it can do. No hacker risk.

Then, same steps as before. Assign .firefoxlink files to always open in your custom program, so that everytime you create a link to a .firefoxlink file, it opens the link in a private window.

So what ?

Neither solution is perfect. The first one is something I would never implement on my computers, and the second... well, I just did, but it does require some extra technical knowledge that may be beyond some power users, or simply too much time for such a small problem.

  • Thanks for taking a look. As you pointed out, setting a browser to open scripts may not be the best of things to do. I guess I'll stick to assigning a keybind (in Openbox) to firefox -private-window http://www.somewhere.com/. – Justice for Monica Sep 19 '15 at 11:22
  • @DKBose I added a solution which is much much sturdier. I don't really see any problems with it, so I hope this helps! – LS97 Sep 19 '15 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.