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