Skip to content

Adds private tabs, restartless extension for Firefox (20.0+) and SeaMonkey (2.17+)

License

Notifications You must be signed in to change notification settings

hellojole/Private_Tab

 
 

Repository files navigation

Works only in Gecko 20.0 and higher because used API doesn't exist in older versions!

Known issues:

  • 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)

Styles:

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:

Keyboard shortcuts:

You can modify keyboard shortcuts through about:config page, see notes about extensions.privateTab.key.* preferences in defaults/preferences/prefs.js.

Troubleshooting:

Try new clean Firefox profile to ensure that there are no conflicts with another extensions or some specific configuration.

Debug logs:

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] ….

API for other extensions:

Events:

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
API functions:

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])

privateTab.isTabPrivate()

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);
});
privateTab.toggleTabPrivate()

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);
	}
);
privateTab.readyToOpenTab()

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/");
privateTab.readyToOpenTabs()

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();
privateTab.hasClosedTabs

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");
privateTab.forgetClosedTabs()

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();
privateTab.tabLabelIsEmpty()

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.

Backward compatibility:

Check for Private Tab installed (and enabled):

if("privateTab" in window) {
	// Do something with "privateTab" object
}

About

Adds private tabs, restartless extension for Firefox (20.0+) and SeaMonkey (2.17+)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 77.2%
  • HTML 13.5%
  • Batchfile 7.1%
  • Shell 2.2%