function handleEvent(name, payload) { fetch('http://localhost:8118/report?'+JSON.stringify({name, payload})); } chrome.tabs.onActivated.addListener( (tabId, windowId) => handleEvent("activated", {tabId, windowId})); chrome.tabs.onActiveChanged.addListener( (tabId, selectInfo) => handleEvent("activeChanged", {tabId, selectInfo})); chrome.tabs.onAttached.addListener( (tabId, attachInfo) => handleEvent("attached", {tabId, attachInfo})); chrome.tabs.onDetached.addListener( (tabId, detachInfo) => handleEvent("detached", {tabId, detachInfo})); chrome.tabs.onCreated.addListener((tab) => handleEvent("created", {tab})); chrome.tabs.onHighlightChanged.addListener( (selectInfo) => handleEvent("highlightChanged", {selectInfo})); chrome.tabs.onHighlighted.addListener( (hightlighInfo) => handleEvent("hightlighted", {hightlighInfo})); chrome.tabs.onMoved.addListener( (tabId, moveInfo) => handleEvent("moved", {tabId, moveInfo})); chrome.tabs.onRemoved.addListener( (tabId, removeInfo) => handleEvent("removed", {tabId, removeInfo})); chrome.tabs.onReplaced.addListener( (addedTabId, removedTabId) => handleEvent("replaced", {addedTabId, removedTabId})); chrome.tabs.onReplaced.addListener( (addedTabId, removedTabId) => handleEvent("replaced", {addedTabId, removedTabId})); chrome.tabs.onSelectionChanged.addListener( (tabId, selectInfo) => handleEvent("selectionChanged", {tabId, selectInfo})); chrome.tabs.onUpdated.addListener( (tabId, changeInfo, tab) => handleEvent("updated", {tabId, changeInfo, tab}));