# Is there a way to read/write tab history?

**URL:** <https://discourse.mozilla.org/t/is-there-a-way-to-read-write-tab-history/80531>\
**Category:** Development\
**Created:** [May 23, 2021, 9:34am UTC](https://discourse.mozilla.org/t/is-there-a-way-to-read-write-tab-history/80531 "2021-05-23T09:34:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lionelw](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/lionelw/32/28836_2.png) [@lionelw](https://discourse.mozilla.org/u/lionelw)\
**Post date:** [May 23, 2021, 9:34am UTC](https://discourse.mozilla.org/t/is-there-a-way-to-read-write-tab-history/80531/1 "2021-05-23T09:34:52Z")

</div>

The [history webextension API](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/history) seems to only deal with general browser history, not a tab’s history. And the [DOM window.history API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) is very limited, unable to extract tab history entries without actually navigating through it, or to add ‘back’ entries, or to add entries that are not the same domain as the current page.

Am I missing anything? Currently I see no other way than to:

- (read) visit each tab history entry via `window.history.back` in a content script, just to collect each url
- (write) call `browser.tabs.update` for each url, each call checked with `browser.webNavigation.onHistoryStateUpdated` before moving on to the next; essentially manually building up a tab’s history stack

…which all seems rather laborious…

---

<div class="post-metadata">

**Author:** ![Adam](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@Adam](https://discourse.mozilla.org/u/Adam)\
**Post date:** [May 28, 2021, 10:29pm UTC](https://discourse.mozilla.org/t/is-there-a-way-to-read-write-tab-history/80531/2 "2021-05-28T22:29:36Z")

</div>

> **[1378651 - Allow accessing back-forward history for each tab](https://bugzilla.mozilla.org/show_bug.cgi?id=1378651)**
>
> NEW (nobody) in WebExtensions - General. Last updated 2021-05-25.

  

> **[1381922 - Allow modifying/restoring back-forward history for each tab](https://bugzilla.mozilla.org/show_bug.cgi?id=1381922)**
>
> NEW (nobody) in WebExtensions - General. Last updated 2021-05-25.
