I develop a Chrome extension where I capture some data from the user journey on a website. The data is cached in a local variable of the content script added to the webpage. The background script (service worker) queries data from the content script when the user clicks a button in the extension popup.
But the website is not fully a single-page application (SPA) and therefore whenever there is a page navigation, the cached data is lost and I cannot build the whole journey.
Question: Is there a way, I can get the data cached on the page before navigation and send it back to the navigated page?
Few considerations:
The size of data is huge and might exceed the storage limits of browser local storage or session storage, i.e. 5MB.
I persist the data in content script instead of background script for efficiency as the flux rate of data is high and there can be multiple such tabs open at a time.