Merge pull request #133 from bakulf/pb
Addon enabled when PB is by default
This commit is contained in:
commit
a8d343bd7b
2 changed files with 31 additions and 10 deletions
12
index.js
12
index.js
|
@ -29,6 +29,7 @@ const { attachTo } = require("sdk/content/mod");
|
|||
const { ContextualIdentityService } = require("resource://gre/modules/ContextualIdentityService.jsm");
|
||||
const { getFavicon } = require("sdk/places/favicon");
|
||||
const { modelFor } = require("sdk/model/core");
|
||||
const prefService = require("sdk/preferences/service");
|
||||
const self = require("sdk/self");
|
||||
const { Style } = require("sdk/stylesheet/style");
|
||||
const tabs = require("sdk/tabs");
|
||||
|
@ -77,6 +78,7 @@ const ContainerService = {
|
|||
"createIdentity",
|
||||
"removeIdentity",
|
||||
"updateIdentity",
|
||||
"getPreference",
|
||||
];
|
||||
|
||||
// Map of identities.
|
||||
|
@ -548,6 +550,16 @@ const ContainerService = {
|
|||
});
|
||||
},
|
||||
|
||||
// Preferences
|
||||
|
||||
getPreference(args) {
|
||||
if (!("pref" in args)) {
|
||||
return Promise.reject("getPreference must be called with pref argument.");
|
||||
}
|
||||
|
||||
return Promise.resolve(prefService.get(args.pref));
|
||||
},
|
||||
|
||||
// Styling the window
|
||||
|
||||
configureWindows() {
|
||||
|
|
|
@ -1,14 +1,23 @@
|
|||
browser.tabs.onCreated.addListener(tab => {
|
||||
if (tab.incognito) {
|
||||
disableAddon(tab.id);
|
||||
}
|
||||
});
|
||||
browser.runtime.sendMessage({
|
||||
method: "getPreference",
|
||||
pref: "browser.privatebrowsing.autostart"
|
||||
}).then(pbAutoStart => {
|
||||
|
||||
browser.tabs.query({}).then(tabs => {
|
||||
for (let tab of tabs) { // eslint-disable-line prefer-const
|
||||
if (tab.incognito) {
|
||||
disableAddon(tab.id);
|
||||
}
|
||||
// We don't want to disable the addon if we are in auto private-browsing.
|
||||
if (!pbAutoStart) {
|
||||
browser.tabs.onCreated.addListener(tab => {
|
||||
if (tab.incognito) {
|
||||
disableAddon(tab.id);
|
||||
}
|
||||
});
|
||||
|
||||
browser.tabs.query({}).then(tabs => {
|
||||
for (let tab of tabs) { // eslint-disable-line prefer-const
|
||||
if (tab.incognito) {
|
||||
disableAddon(tab.id);
|
||||
}
|
||||
}
|
||||
}).catch(() => {});
|
||||
}
|
||||
}).catch(() => {});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue