Stop being the product.
Become the owner.
or
sign uplog in
Storing data from two domains in a single IndexedDB data store

You might know different client-side data storage methods in #JavaScript : #cookies , #localStorage , #sessionStorage , and perhaps even #IndexedDB . All share the same limitation: they won't let you store data across domains.

But if you can write and use a browser extension, these come with another data storage bucket. Browser extensions come with a manifest.json file that lets you specify all the domains you want to work with. #Chrome Chrome.storage will let you store and read data across domains.

I used chrome.storage.local as a temporary data storage place. I use the #Dexie library to create my IndexedDB data store, database, and to insert the records. I monkey patched Dexie's add() and bulkPut() methods to send a message to background.js. Upon receiving the message, background.js clears chrome.local.storage and inserts what we inserted in IndexedDB.

Then, when I switch to another tab showing my second domain, background.js responds to chrome.tabs.onActivated and calls a function on that page with the data from chrome.local.storage . That function does a bulk insert of the data in a second IndexedDB data store and database.

And voilà, you now have the data from both domains in a single IndexedDB data store.
#programming #technology #js #dev
source
A little sweet treat for the evening TV watching. 😋

Anyone want some? 😊

#cookies
loved
14
laughed
3
shocked
3
loved
10
shocked
7
laughed
4