-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.js
78 lines (61 loc) · 2.22 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
76
77
78
// see:
// https://developer.mozilla.org/en-US/Add-ons/Firefox_for_Android/Walkthrough
// https://developer.mozilla.org/en-US/Add-ons/Firefox_for_Android/Initialization_and_Cleanup#template_code
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import('resource://gre/modules/Services.jsm');
var menuId;
function loadIntoWindow(window) {
if (!window)
return;
menuId = window.NativeWindow.menu.add("Nice reader mode", null, function() {
hideReaderToolbar(window);
});
}
function unloadFromWindow(window) {
if (!window)
return;
window.NativeWindow.menu.remove(menuId);
}
function hideReaderToolbar(window) {
// fjkejiofjweofj fjewofjwoefji;
var readerToolbar = window.content.document.getElementById("reader-toolbar");
readerToolbar.style.display = "none";
}
var windowListener = {
onOpenWindow: function(aWindow) {
// Wait for the window to finish loading
let domWindow = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
domWindow.addEventListener("UIReady", function onLoad() {
domWindow.removeEventListener("UIReady", onLoad, false);
loadIntoWindow(domWindow);
}, false);
},
onCloseWindow: function(aWindow) {},
onWindowTitleChange: function(aWindow, aTitle) {}
};
function startup(aData, aReason) {
// Load into any existing windows
let windows = Services.wm.getEnumerator("navigator:browser");
while (windows.hasMoreElements()) {
let domWindow = windows.getNext().QueryInterface(Ci.nsIDOMWindow);
loadIntoWindow(domWindow);
}
// Load into any new windows
Services.wm.addListener(windowListener);
}
function shutdown(aData, aReason) {
// When the application is shutting down we normally don't have to clean
// up any UI changes made
if (aReason == APP_SHUTDOWN)
return;
// Stop listening for new windows
Services.wm.removeListener(windowListener);
// Unload from any existing windows
let windows = Services.wm.getEnumerator("navigator:browser");
while (windows.hasMoreElements()) {
let domWindow = windows.getNext().QueryInterface(Ci.nsIDOMWindow);
unloadFromWindow(domWindow);
}
}
function install(aData, aReason) {}
function uninstall(aData, aReason) {}