I am currently working on a small extension for Chrome. I need same websql database for the extension, but I get different databases based on where I create them.
If I create the database in the content page, I get the database created for a particular page where user is.
If I create database in the background page then I get extension’s own database. But it is invisible to content pages.
I wish I could access the EXTENSION’s database from content pages, without resorting to clunky message passing mechanism. Is there a way to do that?
This is not possible, same thing as with
localStorage. Different scripts represent different contexts.All extension scripts can communicate with background page though. Try creating a proxy API to the database on the background page. This should be simple enough.
I would implement it like this (content script):
and on the other end (background page):
Above code is not tested, it’s just a sketch.