1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
+
+
+
+
|
// Modify page
/* jshint esversion:6, -W097 */
/* jslint esversion:6 */
/* global GrammalectePanel, GrammalecteMenu, GrammalecteTextFormatter, GrammalecteLexicographer, GrammalecteGrammarChecker, GrammalecteMessageBox, showError, MutationObserver, chrome, document, console */
/*
JS sucks (again, and again, and again, and again…)
Not possible to load content from within the extension:
https://bugzilla.mozilla.org/show_bug.cgi?id=1267027
No SharedWorker, no images allowed for now…
*/
|
︙ | | |
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
+
+
|
oGCPanel: null,
oMessageBox: null,
xRightClickedNode: null,
xObserver: null,
sExtensionUrl: null,
listenRightClick: function () {
// Node where a right click is done
// Bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1325814
document.addEventListener('contextmenu', function (xEvent) {
this.xRightClickedNode = xEvent.target;
}.bind(this), true);
|
︙ | | |
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
-
+
+
-
+
+
|
this.lMenu.length = 0; // to clear an array
this.listenRightClick();
this.createMenus();
},
createTFPanel: function () {
if (this.oTFPanel === null) {
this.oTFPanel = new GrammalecteTextFormatter("grammalecte_tf_panel", "Formateur de texte", 760, 600, false);
this.oTFPanel = new GrammalecteTextFormatter("grammalecte_tf_panel", "Formateur de texte", 760, 615, false);
//this.oTFPanel.logInnerHTML();
this.oTFPanel.insertIntoPage();
window.setTimeout(function(self){
this.oTFPanel.adjustHeight();
self.oTFPanel.adjustHeight();
}, 50, this);
}
},
createLxgPanel: function () {
if (this.oLxgPanel === null) {
this.oLxgPanel = new GrammalecteLexicographer("grammalecte_lxg_panel", "Lexicographe", 500, 700);
this.oLxgPanel.insertIntoPage();
|
︙ | | |
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
-
+
+
+
+
+
+
+
+
|
}
return xNode;
}
catch (e) {
showError(e);
}
}
}
};
/*
Connexion to the background
*/
let xGrammalectePort = browser.runtime.connect({name: "content-script port"});
xGrammalectePort.onMessage.addListener(function (oMessage) {
let {sActionDone, result, dInfo, bEnd, bError} = oMessage;
let sText = "";
switch (sActionDone) {
case "init":
oGrammalecte.sExtensionUrl = oMessage.sUrl;
// Start
oGrammalecte.listenRightClick();
oGrammalecte.createMenus();
oGrammalecte.observePage();
break;
case "parseAndSpellcheck":
if (!bEnd) {
oGrammalecte.oGCPanel.addParagraphResult(result);
} else {
oGrammalecte.oGCPanel.stopWaitIcon();
}
break;
|
︙ | | |
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
|
329
330
331
332
333
334
335
|
-
-
-
-
-
-
-
-
|
case "rescanPage":
oGrammalecte.rescanPage();
break;
default:
console.log("[Content script] Unknown command: " + sActionDone);
}
});
/*
Start
*/
oGrammalecte.listenRightClick();
oGrammalecte.createMenus();
oGrammalecte.observePage();
|