-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontentScript.js
More file actions
36 lines (33 loc) · 1.06 KB
/
contentScript.js
File metadata and controls
36 lines (33 loc) · 1.06 KB
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
function showPopup(htmlMsg) {
var popup = $(
'<div class="wrapper-spell-checker reset-css-spell-checker">' +
'<div class="header-spell-checker">' +
chrome.i18n.getMessage('checking') +
'<div class="close-spell-checker"></div>' +
'</div>' +
'<div class="content-spell-checker">' +
htmlMsg +
'</div>' +
'</div>'),
close = popup.find('div.close-spell-checker'),
body = $('body');
close.click(function () {
popup.remove();
});
body.click(function (event) {
if ($(event.target).parents('div.wrapper-spell-checker').length === 0) {
popup.remove();
}
});
body.append(popup);
}
/*
* http://developer.chrome.com/extensions/runtime.html#event-onMessage
*
* Событие возникает, когда расширение шлет сообщение.
*
* См. background.js
*/
chrome.runtime.onMessage.addListener(function(msg) {
showPopup(msg.content);
});