Last active
January 1, 2021 16:15
-
-
Save felixr/dec17c245e2c1611f6163d04a25caa19 to your computer and use it in GitHub Desktop.
Proof of concept chrome extension to listen to all tab events
This file contains 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 characters
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 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 characters
{ | |
"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 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 characters
# 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)))' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment