Search code examples
firefox-addon-webextensionsgreasemonkey-4firefox-57+

Blank Private Browsing Page in Firefox


I would like to write an WebExtension to have a blank private browsing page, inspired by an old extension: https://github.com/iPotable/BlankPrivateBrowsingPage

I thought I could use chrome_url_overrides for any chrome page. So I tried:

{
  "manifest_version": 2,
  "name": "Blank private browsing page",
    "chrome_url_overrides" : {
       "chrome://browser/content/aboutPrivateBrowsing.xhtml": "index.html"
  },
  "version": "0.1"
}

But it seems that it can be used only for certain chrome pages, right?

See: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/chrome_url_overrides

A second option that I tried was a UserScript:

// ==UserScript==
// @name Blank aboutPrivateBrowsing page
// @include chrome://browser/content/aboutPrivateBrowsing.xhtml
// ==/UserScript==

window.location.href="about:blank";

But seems that Greasemonkey can not handle chrome URLs.

Can anyone think of another solution?


Solution

  • Currently, you cannot override about:newtab in private mode. However, what you should be able to do inside a WebExtension:

    Then you will have more or less the same.

    Code:

    function handleUpdated(tabId, changeInfo, tabInfo) {
        if(changeInfo.favIconUrl){
            //console.log("favIconUrl updated is " + changeInfo.favIconUrl);
    
            if (tabInfo.incognito && changeInfo.favIconUrl.indexOf("privatebrowsing") > -1){
                //console.log("opening about:blank..");
                browser.tabs.update({url: "about:blank"});
            }
        }
    }
    
    browser.tabs.onUpdated.addListener(handleUpdated);
    

    The code above sadly gives a noticable graphical glitch. Instead of favIconUrl you can probably use tab.title == "New Tab" as well (but that will only work for English versions of Firefox).