1
2
3
4
5
6
7
8
9
10
|
// Background script
// for calling the grammar checker engine
let gce = null; // module: grammar checker engine
let text = null;
let tkz = null; // module: tokenizer
let lxg = null; // module: lexicographer
let helpers = null;
|
|
>
|
>
>
|
>
>
>
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
/*
import { echo } from "mymodule";
try {
echo("It works! At last!");
}
catch (e) {
console.error(e);
}
*/
"use strict";
let gce = null; // module: grammar checker engine
let text = null;
let tkz = null; // module: tokenizer
let lxg = null; // module: lexicographer
let helpers = null;
|
109
110
111
112
113
114
115
116
117
118
119
120
|
helpers.logerror(e);
}
return JSON.stringify([]);
}
function handleMessage (oRequest, xSender, sendResponse) {
console.log(`content script sent a message: ${oRequest.content}`);
sendResponse({response: "response from background script"});
}
browser.runtime.onMessage.addListener(handleMessage);
|
|
>
>
>
>
>
>
>
|
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
helpers.logerror(e);
}
return JSON.stringify([]);
}
function handleMessage (oRequest, xSender, sendResponse) {
console.log(`[background] received: ${oRequest.content}`);
sendResponse({response: "response from background script"});
}
browser.runtime.onMessage.addListener(handleMessage);
try {
loadGrammarChecker();
}
catch (e) {
console.error(e);
}
|