Hello.
Since TB options are now open in a tab, is there an event/observer notification that can be tracked to be notified when options opened and more specifically when a specific tab in the options is opened?
Thank you.
TB68: detect options open?
- Vano
- Posts: 403
- Joined: December 26th, 2007, 8:21 pm
-
- Posts: 6405
- Joined: February 3rd, 2009, 6:29 pm
Re: TB68: detect options open?
Try using a pref observer. The value of the mail.preferences.advanced.selectedTabIndex pref changes when the selected tab changes in the advanced pane in the options tab.
Maybe use the registerTabMonitor method to listen when the options tab opens. (see tabmail.xml)
I never tried the new tabs api.
Thunderbird WebExtension APIs
http://thunderbird-webextensions.readth ... index.html
Annoying that there is no source code available for Thunderbird 68 online.
Source
http://dxr.mozilla.org/
http://searchfox.org/
Bugs for comm-esr68
http://bugzilla.mozilla.org/show_bug.cgi?id=1574953
http://bugzilla.mozilla.org/show_bug.cgi?id=1577406
Maybe use the registerTabMonitor method to listen when the options tab opens. (see tabmail.xml)
I never tried the new tabs api.
Thunderbird WebExtension APIs
http://thunderbird-webextensions.readth ... index.html
Annoying that there is no source code available for Thunderbird 68 online.
Source
http://dxr.mozilla.org/
http://searchfox.org/
Bugs for comm-esr68
http://bugzilla.mozilla.org/show_bug.cgi?id=1574953
http://bugzilla.mozilla.org/show_bug.cgi?id=1577406
Last edited by morat on October 20th, 2019, 7:28 am, edited 1 time in total.
- Vano
- Posts: 403
- Joined: December 26th, 2007, 8:21 pm
Re: TB68: detect options open?
Thanks.
So far I have this code, it works well, when options tab is already opened and just switched to from another tab. However upon opening options or if TB just started with options tab already opened, my code fail, because tab's window object doesn't fire "load" event
P.S.
This is bootstrap extension, not webextension
So far I have this code, it works well, when options tab is already opened and just switched to from another tab. However upon opening options or if TB just started with options tab already opened, my code fail, because tab's window object doesn't fire "load" event
Code: Select all
let tabMon = {
monitorName: "myTabmon",
_onLoad: function(window)
{
if (window.document.readyState == "complete")
{
myfunc(window);
}
else
{
window.addEventListener("load", function runOnce()
{
log("loaded");
window.removeEventListener("load", runOnce, false);
myfunc(window);
}, true);
}
},
onTabTitleChanged(tab)
{
log("onTabTitleChanged", tab.mode.name, arguments);
},
onTabOpened(tab)
{
log("onTabOpened", tab.mode.name, arguments);
if (tab.mode.name == "preferencesTab")
{
log("----", tab.browser.contentWindow.document.readyState, tab.browser.contentWindow);
this._onLoad(tab.browser.contentWindow);
}
},
onTabPersist(tab)
{
log("onTabPersist", tab.mode.name, arguments);
},
onTabRestored(tab)
{
log("onTabRestored", tab.mode.name, arguments);
},
onTabClosing(tab)
{
log("onTabClosing", tab.mode.name, arguments);
},
onTabSwitched(tab)
{
log("onTabSwitched", tab.mode.name, arguments);
if (tab.mode.name == "preferencesTab")
{
log("----", tab.browser.contentWindow.document.readyState, tab.browser.contentWindow);
this._onLoad(tab.browser.contentWindow);
}
},
};
let tabmail = document.getElementById("tabmail");
if (tabmail)
{
tabmail.registerTabMonitor(tabMon);
}
This is bootstrap extension, not webextension
-
- Posts: 6405
- Joined: February 3rd, 2009, 6:29 pm
Re: TB68: detect options open?
I can't get the DOMContentLoaded or load listener to work. I got the paneSelected listener to work.
These are the preferences that change values when selecting a tab within a selected pane in the options tab.
* mail.preferences.display.selectedTabIndex
* mail.preferences.compose.selectedTabIndex i.e. pref for composition pane
* mail.preferences.chat.selectedTabIndex
* mail.preferences.security.selectedTabIndex
* mail.preferences.applications.selectedTabIndex i.e. pref for attachments pane
* mail.preferences.advanced.selectedTabIndex
Code: Select all
(function () {
var tabMon = {
monitorName: "test_tab_monitor",
_onLoad(aWindow) {
console.log("_onLoad");
aWindow.addEventListener("DOMContentLoaded", function (event) {
console.log("DOMContentLoaded", event);
}, true);
aWindow.addEventListener("load", function (event) {
console.log("load", event);
}, true);
},
onTabTitleChanged(aTab) {
console.log("onTabTitleChanged", aTab); },
onTabSwitched(aTab, aOldTab) {
console.log("onTabSwitched", aTab, aOldTab);
},
onTabOpened(aTab, aIsFirstTab, aWasCurrentTab) {
console.log("onTabOpened", aTab, aIsFirstTab, aWasCurrentTab);
if (aTab.mode.name == "preferencesTab") {
console.log("preferencesTab");
this._onLoad(aTab.browser.contentWindow);
aTab.browser.addEventListener("paneSelected", function (event) {
console.log("paneSelected", event);
// }, {once: true});
}, true);
}
},
onTabClosing(aTab) {
console.log("onTabClosing", aTab);
},
onTabPersist(aTab) {
console.log("onTabPersist", aTab);
},
onTabRestored(aTab, aState, aIsFirstTab) {
console.log("onTabRestored", aTab, aState, aIsFirstTab);
},
};
document.getElementById("tabmail").registerTabMonitor(tabMon);
})();
* mail.preferences.display.selectedTabIndex
* mail.preferences.compose.selectedTabIndex i.e. pref for composition pane
* mail.preferences.chat.selectedTabIndex
* mail.preferences.security.selectedTabIndex
* mail.preferences.applications.selectedTabIndex i.e. pref for attachments pane
* mail.preferences.advanced.selectedTabIndex
- Vano
- Posts: 403
- Joined: December 26th, 2007, 8:21 pm
Re: TB68: detect options open?
Great! Thank you. This worked.