OLD | NEW |
| (Empty) |
1 /* | |
2 * This Source Code is subject to the terms of the Mozilla Public License | |
3 * version 2.0 (the "License"). You can obtain a copy of the License at | |
4 * http://mozilla.org/MPL/2.0/. | |
5 */ | |
6 | |
7 (function() | |
8 { | |
9 const Cu = Components.utils; | |
10 | |
11 let rand = Components.stack.filename.replace(/.*\?/, ""); | |
12 let module = "chrome://elemhidehelper/content/actor.jsm?" + rand; | |
13 let {shutdown, getNodeInfo, togglePreview, forgetNode} = Cu.import(module, {})
; | |
14 | |
15 addMessageListener("ElemHideHelper:Shutdown", onShutdown); | |
16 addMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); | |
17 addMessageListener("ElemHideHelper:Preview", onTogglePreview); | |
18 | |
19 function onShutdown() | |
20 { | |
21 shutdown(); | |
22 try { | |
23 Cu.unload(module); | |
24 } catch (e) { | |
25 Cu.reportError(e); | |
26 } | |
27 | |
28 removeMessageListener("ElemHideHelper:Shutdown", onShutdown); | |
29 removeMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); | |
30 removeMessageListener("ElemHideHelper:Preview", onTogglePreview); | |
31 } | |
32 | |
33 function onGetNodeInfo(message) | |
34 { | |
35 let nodeInfo = getNodeInfo(message.objects.element); | |
36 nodeInfo.messageId = message.data; | |
37 sendAsyncMessage("ElemHideHelper:GetNodeInfo:Response", nodeInfo); | |
38 } | |
39 | |
40 function onTogglePreview(message) | |
41 { | |
42 togglePreview(message.data.nodeID, message.data.stylesheetData); | |
43 if (message.data.forgetNode) | |
44 forgetNode(message.data.nodeID); | |
45 } | |
46 })(); | |
OLD | NEW |