0

I'm writing a Quasar BEX browser addon and have some data in chrome.storage.local (and Vuex; I'd like to use a local database for datastorage in the future if possible) that should be tied to a specific tab and remain linked to it even after restarting the browser. A specific tab should display specific data even after a browser restart (just like normal tabs do when restoring a browser session).

To associate specific data with specific tabs I need a unique identifier of the tab that persists or can be persisted across browser restarts.


The tabId is reset after each browser restart and sessions.setTabValue() also only uses tabId.

This doesn't work here because index is not unique either / reset after browser restart and that tab "fingerprint" (and url) should usually be the same for all of the BEX tabs.

The only idea I have for how this could be solved is changing the URL by appending a UID after a hash (like url#some-id). However, changing the URL didn't work by setting document.location.href or window.location or window.location.hash (in a background-hooks method of the Quasar BEX) – it stays the plain extension url in the URL address bar and only changes those variables (so if I were to close the browser the URL is unchanged). window.history.pushState({}, null, newUrl); didn't change the URL in the address bar either. Edit: maybe the URL is changed and persists after a restart but doesn't display in the address bar for extension URLs?

The URL is the extension URL (it starts with moz-extension://).

mYnDstrEAm
  • 751
  • 2
  • 8
  • 26

1 Answers1

0

I am new to writing browser extensions so this may not be the best answer.

Tab ids may be different when the browser restarts, but the tab index should be the same. If you keep track of both the tab id, and the tab index and update both in your storage when a tab changes position, then I would think you would have the information after restart.

When restarted the same set of tabs get reopened in the same position. If you look at the tab with the correct index, then get its id you will be able to interact with it. You will be able to correlate storage by tab index upon startup, then update the tab id in storage.

julie
  • 172
  • 1
  • 6