-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcontent_script.js
46 lines (40 loc) · 983 Bytes
/
content_script.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
var page = {
version : "1.0.0",
copyCSSS : null,
domOutline : null
};
function initContentScript() {
page.copyCSSS = CopyCSSS();
page.domOutline = DomOutline({
onCaptured : function(element, recurse) {
var hs = page.copyCSSS.copyHTMLStyles(element, recurse);
hs.action = "capture";
chrome.runtime.sendMessage(hs);
},
onClosed : function() {
chrome.runtime.sendMessage({
action : "closed"
});
}
});
chrome.runtime.onMessage
.addListener(function(message, sender, sendResponse) {
switch (message.action) {
case "open":
page.copyCSSS.prepare();
page.domOutline.update({"showchain": message.ShowSelectedTagChain === "true"});
page.domOutline.start();
sendResponse({
count : "2"
});
break;
case "update":
page.domOutline.update({"showchain": message.ShowSelectedTagChain === "true"});
break;
case "close":
page.domOutline.stop();
break;
}
});
}
initContentScript();