Works only in Gecko 20.0 and higher because used API doesn't exist in older versions!
- We just inherit private state from selected tab and tries preserve private state of dropped link-like things, this is simple to implement, but may confuse a bit…
- If you use "New Private Tab" + "New Tab" buttons after tabs toolbar, you need to manually remove "New Private Tab" button before disabling or uninstalling Private Tab. Or you can remove "New Tab" button, press OK in Customize Toolbar dialog and then place "New Tab" directly after tabs.
- Can't open new private tab, if installed Scriptify-based extension: please use Greasemonkey or Scriptish instead (#110)
You can use .tabbrowser-tab[privateTab-isPrivate]
(private tab), #main-window[privateTab-selectedTabIsPrivate]
(selected tab is private) and #main-window[privateTab-isPrivate]
(built-in private window) selectors in styles for userChrome.css/Stylish.
Example styles:
- change underline of private tabs
- change icon
- change background color
- add overlay icon
- add icons to menu items
- hide some menu items
You can modify keyboard shortcuts through about:config page, see notes about extensions.privateTab.key.* preferences in defaults/preferences/prefs.js.
Try new clean Firefox profile to ensure that there are no conflicts with another extensions or some specific configuration.
Options in about:config:
- extensions.privateTab.debug – enable debug logs
- extensions.privateTab.debug.verbose – additionally enable detailed debug logs (not needed in most cases)
Then use Browser Console (formerly Error Console, Ctrl+Shift+J) to see messages like [Private Tab] …
.
You can listen for following events:
event.type | event.target | event.detail | Description |
---|---|---|---|
PrivateTab:PrivateChanged | tab | 1 – private tab 0 – not private |
Changed private state of the tab |
PrivateTab:OpenInNewTab | tab | 1 – may be opened as child tab | Link was opened in new private tab |
PrivateTab:OpenNewTab | tab | 1 – opened using middle-click (or left-click with any modifier) |
Opened new (empty) private tab |
boolean privateTab.isTabPrivate(in DOMNode tab)
boolean privateTab.toggleTabPrivate(in DOMNode tab[, in boolean isPrivate])
void privateTab.readyToOpenTab(in boolean isPrivate)
void privateTab.readyToOpenTabs(in boolean isPrivate)
boolean privateTab.hasClosedTabs
void privateTab.forgetClosedTabs()
boolean privateTab.tabLabelIsEmpty(in string tabLabel[, in boolean isEmpty])
Investigates that the tab are private (true
) or not (false
), example:
// Close all (visible) private tabs:
Array.slice(gBrowser.visibleTabs || gBrowser.tabs).forEach(function(tab) {
if(privateTab.isTabPrivate(tab))
gBrowser.removeTab(tab);
});
Changes tab private state:
Toggle: privateTab.toggleTabPrivate(tab)
Make private: privateTab.toggleTabPrivate(tab, true)
Make not private: privateTab.toggleTabPrivate(tab, false)
// Make all (visible) tabs private:
Array.forEach(
gBrowser.visibleTabs || gBrowser.tabs,
function(tab) {
if(!privateTab.isTabPrivate(tab))
privateTab.toggleTabPrivate(tab, true);
}
);
Allows to open private or not private tab (independent of any inheritance mechanism), example:
// Open in private tab:
privateTab.readyToOpenTab(true);
gBrowser.addTab("https://mozilla.org/");
// Open in not private tab:
privateTab.readyToOpenTab(false);
gBrowser.addTab("https://mozilla.org/");
Allows to open many private or not private tabs (independent of any inheritance mechanism), example:
// Open in private tabs:
privateTab.readyToOpenTabs(true);
gBrowser.addTab("https://mozilla.org/");
gBrowser.addTab("https://addons.mozilla.org/");
// ...
privateTab.stopToOpenTabs();
Only for extensions.privateTab.rememberClosedPrivateTabs = true, Private Tab 0.1.7.4+.
Return true, if there is at least one private tab in undo close list, example:
if(privateTab.hasClosedTabs)
alert("We have at least one closed private tabs");
else
alert("We don't have closed private tabs");
Only for extensions.privateTab.rememberClosedPrivateTabs = true, Private Tab 0.1.7.4+.
Forget about all closed private tabs in window, example:
// Forget about all closed private tabs in window
privateTab.forgetClosedTabs();
Mark tab label as empty (or non-empty), example:
// Mark tab label/URI as empty:
if("tabLabelIsEmpty" in privateTab) // Private Tab 0.1.7.2+
privateTab.tabLabelIsEmpty("chrome://speeddial/content/speeddial.xul", true);
// Check state:
var isEmpty = privateTab.tabLabelIsEmpty("chrome://speeddial/content/speeddial.xul");
// Restore state (e.g. for restartless extensions):
privateTab.tabLabelIsEmpty("chrome://speeddial/content/speeddial.xul", false);
Note: used global storage for labels (not per-window)! So, it's enough to call this function only once.
Check for Private Tab installed (and enabled):
if("privateTab" in window) {
// Do something with "privateTab" object
}