-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbootstrap.js
75 lines (57 loc) · 2.54 KB
/
bootstrap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"use strict";
const {utils: Cu, classes: Cc, interfaces: Ci} = Components;
Cu.import("resource://gre/modules/Services.jsm");
const Addon = {}, Buttons = {}, Toolbar = {}, Window = {}, Prefs = {}, TabGroups = {};
function processWindow(win) {
Cu.import("chrome://tabgroupsbtn/content/log.jsm");
logger.debug("processWindow");
Window.initState(win);
Toolbar.createToolbar(win);
Buttons.createContextMenu(win);
Toolbar.createContextMenu(win);
Window.registerEventListeners(win);
if (Prefs.getPref("skip-pending"))
Addon.patchMethod(win.gBrowser, "_blurTab", [
["!aTab.owner.closing &&", "!aTab.owner.closing && !aTab.owner.hasAttribute('pending') &&"],
["if (!tab) {", "if (!tab || tab.hasAttribute('pending')) {"],
["this.selectedTab = tab;", "if (!tab || tab.hasAttribute('pending')) {\n" +
" tab = this.addTab();\n" +
" if (this.tabContainer.getIndexOfItem(aTab) < (this.tabs.length - 1))\n" +
" this.moveTabTo(tab, this.tabContainer.getIndexOfItem(aTab) + 1);\n" +
"}\n" +
"this.selectedTab = tab;"]
]);
TabGroups.initPanorama(win).then(() => {
Buttons.refresh(win);
Toolbar.refresh(win);
});
}
function install(data, reason) {}
function uninstall(data, reason) {
if (reason == ADDON_UNINSTALL)
Services.prefs.getBranch("extensions.tabgroupsbtn.").deleteBranch("");
}
function startup(data, reason) {
Cu.import("chrome://tabgroupsbtn/content/log.jsm");
Cu.import("chrome://tabgroupsbtn/content/addon.jsm", Addon);
Cu.import("chrome://tabgroupsbtn/content/toolbar.jsm", Toolbar);
Cu.import("chrome://tabgroupsbtn/content/buttons.jsm", Buttons);
Cu.import("chrome://tabgroupsbtn/content/window.jsm", Window);
Cu.import("chrome://tabgroupsbtn/content/prefs.jsm", Prefs);
Cu.import("chrome://tabgroupsbtn/content/tabgroups.jsm", TabGroups);
Prefs.setDefaultPrefs();
logger.info("startup", reason);
Addon.addStylesheet("style.css");
Toolbar.registerWidgets();
Buttons.registerWidgets();
Addon.watchWindows(processWindow, "navigator:browser");
}
function shutdown(data, reason) {
Cu.import("chrome://tabgroupsbtn/content/log.jsm");
logger.info("shutdown", reason);
if (reason == APP_SHUTDOWN)
return;
Addon.unload();
for (let module of ["addon", "prefs", "toolbar", "buttons", "window", "tabgroups", "utils", "ui", "log", "stash", "relativetime"])
Cu.unload(`chrome://tabgroupsbtn/content/${module}.jsm`);
}