forked from Extended-Thunder/userChromeJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexperiments.js
215 lines (196 loc) · 12.2 KB
/
experiments.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
"use strict";
var { ExtensionSupport } = ChromeUtils.importESModule(
"resource:///modules/ExtensionSupport.sys.mjs",
);
var { ExtensionParent } = ChromeUtils.importESModule(
"resource://gre/modules/ExtensionParent.sys.mjs",
);
const EXTENSION_NAME = "userChromeJS@kamens.us";
var extension = ExtensionParent.GlobalManager.getExtension(EXTENSION_NAME);
// Implements the functions defined in the experiments section of schema.json.
var userChromeJS = class extends ExtensionCommon.ExtensionAPI {
onStartup() {}
onShutdown(isAppShutdown) {
if (isAppShutdown) return;
// Looks like we got uninstalled. Maybe a new version will be installed
// now. Due to new versions not taking effect
// (https://bugzilla.mozilla.org/show_bug.cgi?id=1634348)
// we invalidate the startup cache. That's the same effect as starting
// with -purgecaches (or deleting the startupCache directory from the
// profile).
Services.obs.notifyObservers(null, "startupcache-invalidate");
}
getAPI(context) {
context.callOnClose(this);
return {
userChromeJS: {
addWindowListener() {
var suffixes = ["xul", "xhtml"];
// Many of these were found just by scanning the code. They may not all be relevant.
// Some of these may be obsolete, especially as they are being changed to tabs these days.
// ignoring much of comm/mailnews/jar.mn for now
// ignoring most/all of comm/suite/* for now
// mostly comm/mail/base/jar.mn
var prefix = "chrome://messenger/content/";
var windows = [
"about3Pane", // ??? // comm/mail/base/jar.mn
"aboutDialog", // comm/mail/base/jar.mn
"aboutMessage", // comm/mail/base/jar.mn
"aboutRights", // comm/mail/base/jar.mn
"aboutSupport", // comm/mail/components/about-support/jar.mn
"about-support/aboutSupport", // comm/mail/components/about-support/jar.mn
"accountcreation/accountSetup", // comm/mail/components/accountcreation/jar.mn
"AccountManager", // comm//mailnews/jar.mn
"AccountWizard", // comm//mailnews/jar.mn
"activity", // comm//mail/components/activity/jar.mn
"am-e2e", // comm/mail/components/unifiedtoolbar/jar.mn
"am-im", // comm/mail/components/im/jar.mn
"am-mdn", // comm/mail/extensions/smime/jar.mn
"browserRequest", // comm/mail/base/jar.mn
"cloudfile/selectDialog", // comm/mail/components/cloudfile/jar.mn
"commonDialog", // comm/mail/base/jar.mn ??? override global/content ???
"compactFoldersDialog", // comm/mail/base/jar.mn
"customizeToolbar", // comm/mail/base/jar.mn
"downloads/aboutDownloads", // comm/mail/components/downloads/jar.mn
"extensionPopup", // comm/mail/extensions/jar.mn
"FilterEditor", // comm/mailnews/jar.mn (Main Window) Tools -> Message Filters, New & Edit Buttons
"FilterListDialog", // comm/mail/base/jar.mn (Main Window) Tools -> Message Filters
"folderProps", // comm//mailnews/jar.mn
"glodaFacetView", // comm/mail/base/jar.mn
"glodaFacetViewWrapper", // comm/mail/base/jar.mn
"junkLog", // comm//mailnews/jar.mn
"mailViewList", // comm/mail/extensions/mailviews/jar.mn
"mailViewSetup", // comm/mail/extensions/mailviews/jar.mn
"messageWindow", // comm/mail/base/jar.mn
"messenger", // comm/mail/base/jar.mn
"certpicker", // comm/mail/extensions/smime/jar.mn
"migrationProgress", // comm/mail/base/jar.mn
"multimessageview", // comm/mail/base/jar.mn
"newFolderDialog", // comm//mailnews/jar.mn
"newmailaccount/accountProvisioner", // comm/mail/components/newmailaccount/jar.mn
"newTagDialog", // comm/mail/base/jar.mn
"policies/aboutPolicies", // comm/mail/components/enterprisepolicies/jar.mn
"profileDowngrade", // comm/mail/base/jar.mn
"removeAccount", // comm//mailnews/jar.mn
"renameFolderDialog", // comm//mailnews/jar.mn
"sanitize", // comm/mail/base/jar.mn ??? comm/suite/components/sanitize/jar.mn ???
"SearchDialog", // comm/mail/base/jar.mn
"subscribe", // comm//mailnews/jar.mn
"systemIntegrationDialog", // comm/mail/base/jar.mn
"troubleshootMode", // comm/mail/base/jar.mn
"viewLog", // comm/mailnews/jar.mn (Main Window) Tools -> Message Filters: "Filter Log" Button
"viewSource", // comm/mail/base/jar.mn
"virtualFolderListEdit", // comm//mailnews/jar.mn
"virtualFolderProperties" // comm//mailnews/jar.mn
];
var urls = suffixes
.map((s) => windows.map((w) => prefix + w + "." + s))
.flat(1);
// comm/mail/base/jar.mn - I don't understand the "Override" of "global/content" with "messenger/content"
urls.push("chrome://global/content/commonDialog.xhtml");
// Message Compose:
// comm/mail/components/compose/jar.mn
prefix = "chrome://messenger/content/messengercompose/";
windows = [
"EdAdvancedEdit", /* (Message Compose) "Advanced Property Editor": "Advanced Edit..." Button on multiple Dialogs */
"EdColorPicker", /* (Message Compose) "Text Color" & "Page Background Color" Color Buttons on Formatting Toolbar */
"EdColorProps", /* (Message Compose) "Page Colors and Background": Format -> Page Colors and Background */
"EdConvertToTable", /* (Message Compose) "Convert To Table": Format -> Table -> Create Table from Selection */
"EdDictionary", /* (Message Compose) "Personal Dictionary": Options -> Check Spelling, "Edit..." Button */
"EdHLineProps", /* (Message Compose) NOT USED??? Horizontal Line Properties? */
"EdImageProps", /* (Message Compose) "Image Properties": Insert -> Image */
"EdInsertChars", /* (Message Compose) "Insert Character": Insert -> Characters and Symbols */
"EdInsertMath", /* (Message Compose) "Insert Math": Insert -> Math */
"EdInsertTable", /* (Message Compose) "Insert Math": Insert -> Math */
"EdInsertTOC", /* (Message Compose) "Table of Contents": Insert -> Table of Contents -> Insert/Update */
"EdInsSrc", /* (Message Compose) "Insert HTML": Insert -> HTML (HTML & BODY have NO Attributes for CSS Selector) */
"EdLinkProps", /* (Message Compose) "Link Properties": Insert -> Link */
"EdListProps", /* (Message Compose) "List Properties": Format -> List -> List Properties */
"EdNamedAnchorProps", /* (Message Compose) "Named Anchor Properties": Insert -> Named Anchor */
"EdReplace", /* (Message Compose) "Find and Replace": Edit -> Find and Replace */
"EdSpellCheck", /* (Message Compose) "Check Spelling": Tools -> Check Spelling */
"EdTableProps", /* (Message Compose) "Table Properties": Format -> Table -> Table Properties */
"messengercompose"
];
var mc_urls = suffixes
.map((s) => windows.map((w) => prefix + w + "." + s))
.flat(1);
Array.prototype.push.apply(urls, mc_urls);
// Calendar:
// comm/calendar/base/jar.mn
prefix = "chrome://calendar/content/";
windows = [
"calendar-alarm-dialog",
"calendar-conflicts-dialog",
"calendar-creation", /* (Main Window) File -> New -> Calendar */
"calendar-error-prompt",
"calendar-event-dialog",
"calendar-event-dialog-attendees",
"calendar-event-dialog-recurrence",
"calendar-event-dialog-reminder",
"calendar-event-dialog-timezone",
"calendar-ics-file-dialog",
"calendar-invitations-dialog",
"calendar-itip-identity-dialog",
"calendar-migration-dialog",
"calendar-occurrence-prompt",
"calendar-properties-dialog",
"calendar-providerUninstall-dialog",
"calendar-summary-dialog",
"calendar-uri-redirect-dialog",
"chooseCalendarDialog",
"publishDialog",
"preferences/editCategory"
];
var cal_urls = suffixes
.map((s) => windows.map((w) => prefix + w + "." + s))
.flat(1);
Array.prototype.push.apply(urls, cal_urls);
// urls.push("chrome://calendar/content/calendar-event-dialog.xhtml");
urls.push("chrome://messenger-newsblog/content/am-newsblog.xhtml"); // comm//mailnews/extensions/newsblog/jar.mn
urls.push("chrome://messenger-newsblog/content/feed-subscriptions.xhtml"); // comm//mailnews/extensions/newsblog/jar.mn
urls.push("chrome://messenger-newsblog/content/feedAccountWizard.xhtml"); // comm//mailnews/extensions/newsblog/jar.mn
urls.push("chrome://messenger-smime/content/certFetchingStatus.xhtml"); // comm/mail/extensions/smime/jar.mn
urls.push("chrome://messenger-smime/content/msgCompSecurityInfo.xhtml"); // comm/mail/extensions/smime/jar.mn
urls.push("chrome://mozapps/content/update/history.xhtml"); // toolkit/mozapps/update/jar.mn
urls.push("chrome://mozapps/content/update/updateElevation.xhtml"); // toolkit/mozapps/update/jar.mn
urls.push("chrome://mozapps/content/profile/createProfileWizard.xhtml"); // toolkit/profile/jar.mn
urls.push("chrome://mozapps/content/profile/profileDowngrade.xhtml"); // toolkit/profile/jar.mn
urls.push("chrome://mozapps/content/profile/profileSelection.xhtml"); // toolkit/profile/jar.mn
// Adds a listener to detect new windows.
ExtensionSupport.registerWindowListener(EXTENSION_NAME, {
chromeURLs: urls,
onLoadWindow: paint,
});
},
reload(windowId) {
let window = context.extension.windowManager.get(windowId);
console.log(window);
paint(window.window);
},
},
};
}
close() {
ExtensionSupport.unregisterWindowListener(EXTENSION_NAME);
}
};
function paint(win) {
if (!win.document.location || win.document.location.protocol != "chrome:") {
return;
}
var file = Services.dirsvc.get("UChrm", Components.interfaces.nsIFile);
file.append("userChrome.js");
if (!file.exists()) {
return;
}
var url = Services.io
.getProtocolHandler("file")
.QueryInterface(Components.interfaces.nsIFileProtocolHandler)
.getURLSpecFromActualFile(file);
Services.scriptloader.loadSubScriptWithOptions(url, {
target: win.document.defaultView,
charset: "UTF-8",
ignoreCache: true,
});
}