LEFT | RIGHT |
| 1 "use strict"; |
| 2 |
1 chrome.runtime.onMessage.addListener((message, sender, sendResponse) => | 3 chrome.runtime.onMessage.addListener((message, sender, sendResponse) => |
2 { | 4 { |
3 return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != -1; | 5 return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != -1; |
4 }); | 6 }); |
5 | 7 |
6 ext.onExtensionUnloaded = (() => | |
7 { | 8 { |
8 let port = null; | 9 let port = null; |
9 | 10 |
10 return { | 11 ext.onExtensionUnloaded = { |
11 addListener: listener => | 12 addListener(listener) |
12 { | 13 { |
13 if (!port) | 14 if (!port) |
14 port = chrome.runtime.connect(); | 15 port = chrome.runtime.connect(); |
15 | 16 |
16 // When the extension is reloaded, disabled or uninstalled the | 17 // When the extension is reloaded, disabled or uninstalled the |
17 // background page dies and automatically disconnects all ports | 18 // background page dies and automatically disconnects all ports |
18 port.onDisconnect.addListener(listener); | 19 port.onDisconnect.addListener(listener); |
19 }, | 20 }, |
20 removeListener: listener => | 21 removeListener(listener) |
21 { | 22 { |
22 if (port) | 23 if (port) |
23 { | 24 { |
24 port.onDisconnect.removeListener(listener); | 25 port.onDisconnect.removeListener(listener); |
25 | 26 |
26 if (!port.onDisconnect.hasListeners()) | 27 if (!port.onDisconnect.hasListeners()) |
27 { | 28 { |
28 port.disconnect(); | 29 port.disconnect(); |
29 port = null; | 30 port = null; |
30 } | 31 } |
31 } | 32 } |
32 } | 33 } |
33 }; | 34 }; |
34 })(); | 35 } |
LEFT | RIGHT |