URL "about:newtab" still shows default and not custom new tab

(Thomas Werner) #1

Hi everyone,

currently i write my first extension to create a new tab page, its finished and working great. But i want that my homepage is my new tab page as well, not only for new tabs.

My first idea was to set “about:newtab” as homepage, but why the url still shows the default one and not my new custom tab, i thought its “overwritten”?

My next idea was to open the preferences, my custom new tab page and clicking “Use Current Pages”. Firefox adds automatically a url like “moz-extension:///tab.html”. Is this the only way? Does the “” changes, e.g. on next update of the addon? Is there any other way?

In Chrome i just tick the radio button “New Tab page” for homepage. Does someone has any hint that i can add to the FAQ?

Thx + BR Thomas

(Thomas Werner) #2

Found “chrome_settings_overrides” to set homepage to new tab page, but cannot be changed after installation of add-on by user. Any hint to make it optional for users?

(Jérémie Bertrand) #3

I am also interested by this :slight_smile:
I think one way could be to modify the browser.startup.homepage settings in about:config, but webextension doesn’t allow such settings modification.

(Juraj Masiar) #4

There is several options:

  1. you generate “homepage link” for the user using browser.extension.getURL('newTab.html') and then tell them to use it in Firefox Options page.
  2. you override homepage in chrome_settings_overrides - but this cannot be changed afterwards by user so not a good idea.
  3. you can detect opening homepage by listening to events like tabs.onUpdated (or tabs.onCreated) and when you detect about:newtab, you change that to your add-on. However to make this work properly it may require some complex logic (sometimes tab opens as about:blank and then changes to something else). Also it may introduce new set of issues like wrong focus on page instead of address bar.

I’m using the first option with short text about how to do that and a button to copy that URL to clipboard.

(Thomas Werner) #5

Thx for your answer, but for me it looks more than workarounds/hacks. In Chrome its much easier, no “chrome_settings_overrides.homepage” needed, chrome://newtab shows the default or custom new tab page and the user has the option “New Tab as Homepage” or just enter “chrome://newtab” (commonly knows) as homepage url.

Thats why i decided to use “chrome_settings_overrides.homepage” in hope that it works without adding complex code like checking url to make an redirect to custom new tab page which could cause trouble, or offering any strange url which the user has to copy etc… not very user friendly.

I would give it a try, but does it show only the custom page or tries to load default new tab page for under a second and then it redirects… would be not nice and a ugly workaround, but i will see. But what happens if Firefox changes this, because for me “about:newtab” behaviour is a bug.

My next problem is that “chrome_settings_overrides.homepage” seems to be not stable. It works most of the time, but sometimes after starting Firefox it shows default “about:newtab” or nothing, and not the page defined in “chrome_settings_overrides.homepage”. Verified, because it does not contain any code of my “newtab.html”, thats why i think its not an issue with the extension, because same code works great in Chrome.

But i will try and keep you posted. Thx again… BR

(Juraj Masiar) #6

Regarding opening very first Firefox window - I’m pretty sure this is a Firefox bug. Because add-ons are loaded asynchronously there is a chance that Firefox will open first tab faster than load add-ons overriding it and so it display the default page.

I agree the chrome_settings_overrides.homepage way suppose to be the right one, but Firefox needs to fix this as well (allow users to change it without disabling whole add-on).