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