# How to get the list url accessed while loading a page via javascript for use inside extension

**URL:** <https://discourse.mozilla.org/t/how-to-get-the-list-url-accessed-while-loading-a-page-via-javascript-for-use-inside-extension/120858>\
**Category:** Development\
**Created:** [July 6, 2023, 5:07pm UTC](https://discourse.mozilla.org/t/how-to-get-the-list-url-accessed-while-loading-a-page-via-javascript-for-use-inside-extension/120858 "2023-07-06T17:07:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanangamudi](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/vanangamudi/32/63015_2.png) [@vanangamudi](https://discourse.mozilla.org/u/vanangamudi)\
**Post date:** [July 6, 2023, 5:07pm UTC](https://discourse.mozilla.org/t/how-to-get-the-list-url-accessed-while-loading-a-page-via-javascript-for-use-inside-extension/120858/1 "2023-07-06T17:07:48Z")

</div>

how to access the list of urls accessed by a particular tab for use within extension?

for example when loading videos from sharepoint, how to get the URL for the videomanifest so that I can write to a local file for further use?

---

<div class="post-metadata">

**Author:** ![metastable](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/metastable/32/61647_2.png) [@metastable](https://discourse.mozilla.org/u/metastable)\
**Post date:** [July 7, 2023, 6:20am UTC](https://discourse.mozilla.org/t/how-to-get-the-list-url-accessed-while-loading-a-page-via-javascript-for-use-inside-extension/120858/2 "2023-07-07T06:20:30Z")

</div>

For example, you can use the `browser.webRequest.onCompleted` event to capture completed requests and the urls by tab.

```javascript
export class TabRequestObserver {
  constructor() {
    this.requestUrlsByTab = new Map();
    browser.tabs.onRemoved.addListener((tabId) => this.requestUrlsByTab.delete(tabId));
    browser.webRequest.onCompleted.addListener((details) => {
      const { tabId, url } = details;
      const urls = this.requestUrlsByTab.get(tabId) ?? [];
      urls.push(url);
      this.requestUrlsByTab.set(tabId, urls);
    }, { urls: ["<all_urls>"] });
  }
  getUrlsByTabId(tabId) {
    return this.requestUrlsByTab.get(tabId) ?? [];
  }
}

```
