MozillaZine


Manage tabs on open/close

User Help for Mozilla Thunderbird
semigeek
 
Posts: 195
Joined: April 16th, 2014, 8:54 pm
Location: Colorado

Post Posted September 18th, 2021, 4:09 pm

I don't want the last session's tabs restored when I reopen Thunderbird (68). There seems to be no setting to control this?

I have the "Manually Sort Folders" add-on set to start each time on Inbox, but other tabs remain open also, and if one of them was selected on close, that's where I go on restart.

There used to be a "Don't restore tabs" add-on but it doesn't work after TB 60.

tanstaafl
Moderator

User avatar
 
Posts: 48194
Joined: July 30th, 2003, 5:06 pm

Post Posted September 18th, 2021, 5:52 pm

A crude hack would be to modify your shortcut to run a two line batch file. The first line deletes the session.json file in the profile. The second line runs Thunderbird.


session.json stores the default windows layout. This includes data on what tabs are open. Thunderbird (3.0 and later) deletes this file after reading the settings. Its re-created and the layout saved when Thunderbird terminates normally.

morat
 
Posts: 4855
Joined: February 3rd, 2009, 6:29 pm

Post Posted September 18th, 2021, 6:00 pm

You can overwrite the atStartupRestoreTabs function using the userChromeJS extension. (for advanced users only)

That's what the DontRestoreTabs addon does.

DontRestoreTabs (obsolete)
http://addons.thunderbird.net/thunderbird/addon/663190

Code: Select all
/* Thunderbird userChrome.js */

// Thunderbird 68 uses the messenger.xul page.
// Thunderbird 78 uses the messenger.xhtml page.
// Thunderbird 91 uses the messenger.xhtml page.

(function () {
  if (location == "chrome://messenger/content/messenger.xul" ||
      location == "chrome://messenger/content/messenger.xhtml") {
    setTimeout(function () {
      try {
        atStartupRestoreTabs = function (aDontRestoreFirstTab) {
          return false;
        };
      } catch (e) {
        Components.utils.reportError(e);
      }
    }, 10);
  }
})();

userChromeJS by jikamens (compatible with TB 68 and TB 78 and TB 91)
http://addons.thunderbird.net/thunderbird/addon/986610

Instructions:

1. install userChromeJS extension
2. close email client
3. create or edit the userChrome.js file in the chrome folder
4. open email client

I tested the code in TB 78 and it works for me.

Reference
http://searchfox.org/comm-esr60/search?q=atStartupRestoreTabs
http://searchfox.org/comm-esr68/search?q=atStartupRestoreTabs

semigeek
 
Posts: 195
Joined: April 16th, 2014, 8:54 pm
Location: Colorado

Post Posted September 19th, 2021, 10:11 am

tanstaafl wrote:A crude hack would be to modify your shortcut to run a two line batch file. The first line deletes the session.json file in the profile. The second line runs Thunderbird.

I've found that deleting session.json results in NO mail folder being open on restart, whereas I do always want Inbox (which I set in the MSF add-on).

morat wrote:You can overwrite the atStartupRestoreTabs function using the userChromeJS extension...

Thanks. Before I try this, could you confirm that it won't have the same effect just described?

morat
 
Posts: 4855
Joined: February 3rd, 2009, 6:29 pm

Post Posted September 19th, 2021, 10:44 am

Are you saying that deleting the session.json file causes the Manually Sort Folders 'choose the default startup folder' feature to fail? The hack doesn't delete the session.json file so I guess it works like the DontRestoreTabs addon in Thunderbird 60.

semigeek
 
Posts: 195
Joined: April 16th, 2014, 8:54 pm
Location: Colorado

Post Posted September 19th, 2021, 3:06 pm

morat wrote:Are you saying that deleting the session.json file causes the Manually Sort Folders 'choose the default startup folder' feature to fail?

Yes. Without session.json, Thunderbird opens to Local Folders instead of what's selected in MSF, Inbox. (What's more puzzling about MSF is that if another tab just happened to be selected on closing, MSF doesn't even change the focus to Inbox instead on reopening. That's why I want the other tabs to close.)

I looked up the userChromeJS add-on... it's marked "experimental" and has two user reviews, one of whom had problems with it. I'm starting to think I can just continue to manage tabs manually.

guylifshitz2
New Member
 
Posts: 1
Joined: October 17th, 2021, 12:21 pm

Post Posted October 18th, 2021, 11:15 am

I worked with another person on an add-on that does what morat describes above, but it doesn't require adding files manually with userChromeJS, the add-on handles everything on its own. You just install and restart Thunderbird, and it will prevent tabs from loading on start.

The add-on is not yet accepted in the official Thunderbird add-ons. I submitted a version which hopefully will be accepted, but for now you can find the add-on and install it via "Install Add-on from file" (select the dontRestoreTabsRevival.xpi file).

Code: https://github.com/guylifshitz/DontRest ... ob/master/
Add-on XPI file: https://github.com/guylifshitz/DontRest ... evival.xpi


Extra news: apparently there will be a change the the add-ons API soon which will make this code irrelevant within a few months. I was told "We are working on a WebExtension API to handle sessions. ETA: End of November". We will try to return to this project at the end of the year and see if this add-on needs updating.

Return to Thunderbird Support


Who is online

Users browsing this forum: No registered users and 5 guests