MozillaZine

Make New Tab use local Home Page

Discussion of general topics about Mozilla Firefox
Benjamin Markson

User avatar
 
Posts: 365
Joined: November 19th, 2011, 3:57 am
Location: en-GB

Post Posted November 24th, 2017, 4:12 pm

Skip here for a more elegant solution.

For reasons I've not quite worked out having my home page appear when I open a new tab doesn't seem to be on the Mozilla allowed list any more but I've pretty much succeeded. I've seen a number of posts about this so sorry if there is a lot of duplication but my post should draw together several solutions and maybe even introduce something new.

I'm using this add-on New Tab Override to get the basic layout into a new tab. If your page is hosted on the internet that may be all you need but if your page is on your local machine then you'll run into a whole lot of other stuff no longer on Mozilla's allowed list.

with userContent.css we can reintroduce those missing (local) image files by using CSS background images:
Code: Select all
@-moz-document url(moz-extension://<uuid>/html/local_file.html)
{
   body
   {
      background: url(myBackground.png);
   }
   #exampleImage
   {
      background-image: url("myImage.png") !important;
      background-repeat: no-repeat !important;
      width: 100px !important;
      height: 100px !important;
   }
}

...and with userChrome.css we can replace the New Tab label, and the favicon (but not quite).
Code: Select all
#tabbrowser-tabs .tabbrowser-tab[label^="New Tab"] .tab-text.tab-label
{
   font-size: 0 !important;
}
#tabbrowser-tabs .tabbrowser-tab[label^="New Tab"] .tab-text.tab-label:after
{
   font-size: 11px !important;
   content: "My Tab Title" !important;
}
#tabbrowser-tabs .tabbrowser-tab[label^="New Tab"] .tab-icon-image
{
   list-style-image: url("myIcon.ico") !important;
}

Getting the favicon to turn up proved quite tricky as the CSS list-style-image trick on its own doesn't want to work. In the end I managed it by also putting a:
Code: Select all
<link rel="icon" href="file:///C:/Users/<user>/AppData/Roaming/Mozilla/Firefox/Profiles/<profileId>/chrome/myIcon.ico"/>
...in the basic page layout being used by the New Tab Override add-on. I don't understand why it needs to be in both places to work.

For me that's it. I suspect if you have a particularly clever/complex home page hosted locally that there may be other challenges I didn't encounter.

Ben.
Last edited by Benjamin Markson on November 25th, 2017, 9:11 am, edited 2 times in total.
XUL is dead. Long live the Google Chrome Clones.

Gingerbread Man

User avatar
 
Posts: 7742
Joined: January 30th, 2007, 10:55 am

Post Posted November 24th, 2017, 7:57 pm

Edit: Bug 1426438 landed today, removing the underlying code this method relies on. It no longer works starting with Firefox 59.

You don't need an add-on, and you don't need to jump through so many hoops to get local resources to load in a new tab.

In <installation folder>\defaults\pref\autoconfig.js (or …\local-settings.js if you prefer)
Code: Select all
//
pref("general.config.filename", "mozilla.cfg");
pref("general.config.obscure_value", 0);

In <installation folder>\mozilla.cfg
Code: Select all
// New Tab page
Components.utils.import("resource:///modules/NewTabURL.jsm");
NewTabURL.override("file:///C:/REPLACE THIS/WITH YOUR OWN/FILE.html");
Last edited by Gingerbread Man on December 21st, 2017, 4:37 am, edited 1 time in total.

Benjamin Markson

User avatar
 
Posts: 365
Joined: November 19th, 2011, 3:57 am
Location: en-GB

Post Posted November 25th, 2017, 2:55 am

I tried but without any luck so far. Does that solution work under FF57?

Ben.
XUL is dead. Long live the Google Chrome Clones.

Gingerbread Man

User avatar
 
Posts: 7742
Joined: January 30th, 2007, 10:55 am

Post Posted November 25th, 2017, 4:58 am

Yes. Did you remember to restart Firefox after saving the files?

Benjamin Markson

User avatar
 
Posts: 365
Joined: November 19th, 2011, 3:57 am
Location: en-GB

Post Posted November 25th, 2017, 5:52 am

Excellent. Thank you. My mistake was that I was relying on config-prefs.js to point to mozilla.cfg because I already had it.

I have no idea what the difference is between config-prefs.js, autoconfig.js, and local-settings.js - they all seem to do similar things but in a randomly different way!

Edit:
Following disabling the New Tab Override add-on you need to restart Firefox for changes to take effect.
It seems that the name of the defaullts\pref file can be any .js you like (I'm actually using config-prefs.js to point to config.js).


Now I don't really understand the point of New Tab Override and why everyone is banging on about New Tabs when your tweak seems to be a perfect workaround to all of the New Tab grief.

Ben.
Last edited by Benjamin Markson on November 25th, 2017, 9:08 am, edited 1 time in total.
XUL is dead. Long live the Google Chrome Clones.

flaneurb
 
Posts: 619
Joined: December 10th, 2011, 3:50 am

Post Posted November 25th, 2017, 6:42 am

Black magic but it works in Linux as well!

Thank, Gingerbread Man!

But will these files have to be created each time Firefox updates?

Gingerbread Man

User avatar
 
Posts: 7742
Joined: January 30th, 2007, 10:55 am

Post Posted November 25th, 2017, 11:02 am

Benjamin Markson wrote:It seems that the name of the defaullts\pref file can be any .js you like (I'm actually using config-prefs.js to point to config.js).

Yes, as long as it's a *.js file, you can name it something other than autoconfig.js. Apparently it's best if it's early in the alphabet:
https://developer.mozilla.org/Firefox/Enterprise_deployment
Benjamin Markson wrote:Now I don't really understand the point of New Tab Override and why everyone is banging on about New Tabs when your tweak seems to be a perfect workaround to all of the New Tab grief.

Ease of use, plus not many are aware of configuration options for system administrators.
flaneurb wrote:But will these files have to be created each time Firefox updates?

On Windows, no. I've had the same ones for years now. Neither the updater or the uninstaller touch them. I can't imagine on Linux the whole folder gets deleted when updating, but you should have a backup of the files, just in case.

You're welcome.

flaneurb
 
Posts: 619
Joined: December 10th, 2011, 3:50 am

Post Posted November 26th, 2017, 3:19 am

Gingerbread Man wrote:...
flaneurb wrote:But will these files have to be created each time Firefox updates?

On Windows, no. I've had the same ones for years now. Neither the updater or the uninstaller touch them. I can't imagine on Linux the whole folder gets deleted when updating, but you should have a backup of the files, just in case.
...

I got Fx59 as well so that'll give me an answer soon enough. I'll post back one way or the other. Thanks!

Edit: the files are still present after an update of Nightly. So all is well!

Mory
 
Posts: 26
Joined: October 21st, 2017, 9:25 am

Post Posted November 26th, 2017, 7:19 am

Gingerbread Man wrote:You don't need an add-on.............


Thanks a lot, working well

takfuji
 
Posts: 13
Joined: April 3rd, 2013, 6:41 pm

Post Posted November 27th, 2017, 4:15 pm

Gingerbread Man,
Very Very thanks for the fix of "newtab homepage problem". Those two small files worked like a magic.
Tak

apu889
 
Posts: 1
Joined: November 30th, 2017, 7:31 am

Post Posted November 30th, 2017, 7:37 am

Gingerbread Man wrote:You don't need an add-on, and you don't need to jump through so many hoops to get local resources to load in a new tab.


just registered on this forum to say thanks! i've been figured this thing all day long. i'm not really into that deep firefox stuff but, is it possible to focusing the cursor on webpage, instead on the url bar (as default) when opening new tab? hope you know what i mean :p

Gingerbread Man

User avatar
 
Posts: 7742
Joined: January 30th, 2007, 10:55 am

Post Posted November 30th, 2017, 12:52 pm

You're welcome.
apu889 wrote:is it possible to focusing the cursor on webpage, instead on the url bar (as default) when opening new tab?

Sorry, I don't know how. All attempts by the page to focus an element are ignored. An add-on can set the focus to the page instead, but that method can't load local files. I got as far as unfocusing the location bar in Scratchpad, but I don't know how to translate that into code for mozilla.cfg. Someone like Mike Kaply, Haggai Nuchi or dickvl might know. If you find a solution, please let us know.

dfoulkes

User avatar
 
Posts: 22329
Joined: June 28th, 2008, 10:31 pm
Location: Mesquite, Nevada

Post Posted December 13th, 2017, 11:04 am

Gingerbread Man wrote:You don't need an add-on, and you don't need to jump through so many hoops to get local resources to load in a new tab.

In <installation folder>\defaults\pref\autoconfig.js (or …\local-settings.js if you prefer)
Code: Select all
//
pref("general.config.filename", "mozilla.cfg");
pref("general.config.obscure_value", 0);

In <installation folder>\mozilla.cfg
Code: Select all
// New Tab page
Components.utils.import("resource:///modules/NewTabURL.jsm");
NewTabURL.override("file:///C:/REPLACE THIS/WITH YOUR OWN/FILE.html");

Note that in my orig. posting... I'm using the portable version of all of this in order to test out version 57. I tried finding the files you mentioned and can not find them... so, am I out of luck with using the portable version? If so, then guess I'll have to install 57 in a diff. install so as not to mess up my ESR version... right? Hey, and thanks for looking at this G-man.
As you can see she's (The CAT) always alert and on the prowl for Meoware !!

flaneurb
 
Posts: 619
Joined: December 10th, 2011, 3:50 am

Post Posted December 13th, 2017, 11:17 am

dfoulkes wrote:... I tried finding the files you mentioned and can not find them... ...

Just create those files with the content Gingerbread Man provided.

Gingerbread Man

User avatar
 
Posts: 7742
Joined: January 30th, 2007, 10:55 am

Post Posted December 13th, 2017, 11:29 am

Edit: Bug 1426438 landed today, removing the underlying code this method relies on. It no longer works starting with Firefox 59.

dfoulkes wrote:I'm using the portable version of all of this in order to test out version 57. I tried finding the files you mentioned and can not find them...

Those files don't exist by default.
  1. Open Notepad.
  2. Paste the following:
    Code: Select all
    //
    pref("general.config.filename", "mozilla.cfg");
    pref("general.config.obscure_value", 0);
  3. Save this to your desktop as "autoconfig.js" and be sure to include the quotation marks in the save box.
  4. From the File menu, choose New, then paste the following:
    Code: Select all
    // New Tab page
    Components.utils.import("resource:///modules/NewTabURL.jsm");
    NewTabURL.override("about:blank");
  5. Save this to your desktop as "mozilla.cfg" and be sure to include the quotation marks in the save box.
  6. Move autoconfig.js from the desktop to <Firefox Portable installation folder>\App\Firefox\defaults\pref, then create a copy in <Firefox Portable installation folder>\App\Firefox64\defaults\pref
  7. Move mozilla.cfg from the desktop to <Firefox Portable installation folder>\App\Firefox\, then create a copy in <Firefox Portable installation folder>\App\Firefox64\

Return to Firefox General


Who is online

Users browsing this forum: Google [Bot] and 4 guests