Last active
January 1, 2021 16:15
-
-
Save felixr/dec17c245e2c1611f6163d04a25caa19 to your computer and use it in GitHub Desktop.
Revisions
-
felixr revised this gist
Jan 1, 2021 . No changes.There are no files selected for viewing
-
felixr renamed this gist
Jan 1, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
felixr created this gist
Jan 1, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ 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})); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ { "name": "Tab reporter", "description": "reports tab events", "version": "0.1", "permissions": ["tabs", "http://localhost:8118/*"], "background": { "persistent": false, "scripts": ["background.js"] }, "manifest_version": 2 } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ # listen to events janet -e '(import json) (net/server "0.0.0.0" 8118 (fn [conn] (as-> (net/read conn 4096) _ (string/split " " _) (_ 1) (string/slice _ 8) (string/replace-all "%22" "\"" _) (json/decode _) (pp _)) (net/close conn)))'