Git Product home page Git Product logo

private_tab's Introduction

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…

Styles:

You can use .tabbrowser-tab[privateTab-isPrivate] (private tab) and #main-window[privateTab-isPrivate] (built-in private window) selectors in styles for userChrome.css/Stylish.
Example styles:

API for other extensions:

Events:

You can listen for following events:

event.type event.targetevent.detail Description
PrivateTab:PrivateChangedtab 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 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)

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();
Backward compatibility:

Check for Private Tab installed (and enabled):

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

private_tab's People

Contributors

infocatcher avatar cye3s avatar stis avatar arbiger avatar charishi avatar mdr-ksk avatar ikurrina avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.