{"id":15711426,"url":"https://github.com/tdriley/webext-helpers","last_synced_at":"2026-04-28T08:35:17.223Z","repository":{"id":218247691,"uuid":"739921189","full_name":"tdriley/webext-helpers","owner":"tdriley","description":"Cross-browser helper utility functions for MV3 \u0026 MV2 web extensions.","archived":false,"fork":false,"pushed_at":"2024-01-22T02:32:23.000Z","size":1633,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T21:42:51.534Z","etag":null,"topics":["browser","browser-extensions","cross-browser","extension-chrome","extension-firefox","functions","helpers","manifest-v2","manifest-v3","mv2","mv2-to-mv3","mv3","utility","webext","webextensions"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tdriley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-07T00:11:55.000Z","updated_at":"2025-02-20T05:36:22.000Z","dependencies_parsed_at":"2024-01-20T18:26:18.431Z","dependency_job_id":"913b21a7-d7b0-43a9-9829-27fc5a507ab5","html_url":"https://github.com/tdriley/webext-helpers","commit_stats":null,"previous_names":["tdriley/webext-helpers"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdriley%2Fwebext-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdriley%2Fwebext-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdriley%2Fwebext-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdriley%2Fwebext-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tdriley","download_url":"https://codeload.github.com/tdriley/webext-helpers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246358193,"owners_count":20764365,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","browser-extensions","cross-browser","extension-chrome","extension-firefox","functions","helpers","manifest-v2","manifest-v3","mv2","mv2-to-mv3","mv3","utility","webext","webextensions"],"created_at":"2024-10-03T21:12:56.327Z","updated_at":"2026-04-28T08:35:12.198Z","avatar_url":"https://github.com/tdriley.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webext-helpers\nCross-browser helper utility functions for MV3 \u0026 MV2 web extensions.\n\nPlease submit any issues or feature requests at [https://github.com/tdriley/webext-helpers/issues](https://github.com/tdriley/webext-helpers/issues)\n\n## Usage\nFirst install as a project dependency: \n\n```npm install webext-helpers --save```\n\n## Functions\n - `setBrowserNamespace`\n\nNormalise the top-level web extension namespace as `browser`, so you can access `chrome.whatever.func()` as `browser.whatever.func()` in all browsers.\n\n```javascript\n    import { setBrowserNamespace } from \"webext-helpers\"\n\n    setBrowserNamespace()\n\n    // All web extension function calls can now start with browser.\n```\n\n - `getCurrentTab`\n\nGet the currently active tab in the current window. Requires the `tabs` permission in `manifest.json`.\n\n```javascript\n    import { getCurrentTab } from \"webext-helpers\"\n\n    const activeTab = await getActiveTab()\n    // Do what you want with the active tab.\n    console.log(activeTab.url)\n```\n\n - `promback`\n\nAllows you to use `Promise` syntax with any web extension function (useful for browser differences in MV2 where Firefox expects promises and Chrome expects callbacks). You should provide the function ref and an array of arguments to call it with.\n\n```javascript\n    import { promback } from \"webext-helpers\"\n\n    promback( browser.tabs.create, [{ url: 'https://github.com/tdriley/webext-helpers#readme' }]).then(data=\u003e {\n        console.log(data)\n        // data will be whatever is resolved by the promise (Firefox), or whatever is provided to the callback func (Chrome).\n    })\n```\n\n - `goToTab`\nCheck if there is a tab open in the current window with the provided URL. If not, open a new tab with the URL. Requires the `tabs` permission in `manifest.json`.\n\n```javascript\n    import { goToTab } from \"webext-helpers\"\n\n    const result = await goToTab('https://github.com/tdriley/webext-helpers#readme')\n\n    // result will be an object containing `result` and `tab` props. The `result` prop will be \"switched\" if the tab was switched, or \"opened\" if the tab was opened. The `tab` prop will be the tab object of the tab that was switched to or opened.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdriley%2Fwebext-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftdriley%2Fwebext-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdriley%2Fwebext-helpers/lists"}