I need to build a Chrome extension that captures clicked elements on a webpage in the background.
For example, whenever the user visits any url containing github.com, the extension would be triggered and store all the elements which have been clicked on, in a list in the chrome.storage API.
I'm asking here because most of the material on how to make Chrome extensions is based on Manifest 2, which is now outdated. Any help is highly appreciated.
So far I've not been able to trigger the extension to start listening on the background.
// background.js
chrome.action.onClicked.addListener(tab => {
chrome.tabs.executeScript({
code: "console.log(event.target.id);"
});
});