{"id":14984376,"url":"https://github.com/zardoy/read-browser-tabs","last_synced_at":"2025-04-10T20:08:48.359Z","repository":{"id":44920894,"uuid":"328872142","full_name":"zardoy/read-browser-tabs","owner":"zardoy","description":"Get browser tab info","archived":false,"fork":false,"pushed_at":"2021-05-09T10:35:44.000Z","size":942,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T13:27:57.992Z","etag":null,"topics":["browser-tabs","nodejs","typescirpt"],"latest_commit_sha":null,"homepage":"https://npmjs.com/read-browser-tabs","language":"TypeScript","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/zardoy.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}},"created_at":"2021-01-12T04:32:11.000Z","updated_at":"2024-06-27T02:21:57.000Z","dependencies_parsed_at":"2022-09-16T12:40:14.333Z","dependency_job_id":null,"html_url":"https://github.com/zardoy/read-browser-tabs","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zardoy%2Fread-browser-tabs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zardoy%2Fread-browser-tabs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zardoy%2Fread-browser-tabs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zardoy%2Fread-browser-tabs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zardoy","download_url":"https://codeload.github.com/zardoy/read-browser-tabs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248288350,"owners_count":21078903,"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-tabs","nodejs","typescirpt"],"created_at":"2024-09-24T14:08:56.686Z","updated_at":"2025-04-10T20:08:48.339Z","avatar_url":"https://github.com/zardoy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Get Browser Tabs \u0026middot; [![npm version](https://img.shields.io/npm/v/read-browser-tabs?color=limegreen)](https://npmjs.com/package/read-browser-tabs) [![GitHub top language](https://img.shields.io/github/languages/top/zardoy/read-browser-tabs)](https://github.com/zardoy/read-browser-tabs/tree/master/src) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n\n\u003e Supported platforms: macOS only. Supported browsers: Safari, Google Chrome.\n\nEasily retrieve information about active tab from Node.js.\n\n## Usage\n\n```ts\nimport { getActiveTabInfo } from \"read-browser-tabs\";\n\n// if google and chrome are running safari always takes precedence by default\nawait getActiveTabInfo();\n//=\u003e\n// {\n//   erroredBrowsers: [],\n//   tabInfo: {\n//     url: 'https://github.com/zbrateam/Zebra',\n//     title: 'GitHub - zbrateam/Zebra: A Useful Package Manager for iOS',\n//     browserTitle: 'safari'\n//   }\n// }\n\nawait getActiveTabInfo({\n    // try to get data from google chrome and if it's not running then try from safari\n    browsers: [\"google chrome\", \"safari\"]\n});\n//=\u003e\n// {\n//   erroredBrowsers: [],\n//   tabInfo: {\n//     url: 'https://github.com/jsdoc/jsdoc',\n//     title: 'jsdoc/jsdoc: An API documentation generator for JavaScript.',\n//     browserTitle: 'google chrome'\n//   }\n// }\n\n// for example only safari is running\nawait getActiveTabInfo({\n    // but here we are trying to get info from google chrome ONLY\n    browsers: [\"google chrome\"]\n});\n// {\n//   erroredBrowsers: [],\n//   tabInfo: null\n// }\n\n```\n\n## Things to Note\n\n- It usually takes 50 - 300ms to get info. It's a good practice to add timeout for 500ms.\n- When you first run this script from app user will see the message: ![jxa prompt](docs-assets/jxa-prompt.png) \u003c!-- If user click *Don't Allow*, you will get an Error: `Error: Error: An error occurred. (-1743)`. For further runs it won't ask for user again and to avoid this error user must go to preferences and explicitly enable all browsers: ![settings-allow-jxa](docs-assets/settings-allow-jxa.png) Keep in mind that if you are using Electron, you can easily show this window to user. --\u003e\n\n## Why?\n\nI used [get-chrome-tabs](https://www.npmjs.com/package/get-chrome-tabs) in past, but it has a **huge** performance issue, with handling multiple opened windows. That's because it travels over all windows and tabs and of course it takes A LOT of time. This module solves the problem by accessing only the active (focused) tab. And it supports Safari!\n\n### It Could be Better\n\nThis module VERY unreliable, like it can break in any day. Apple created JXA and it's very bad. Sometimes I get `execution error: Error: Error: AppleEvent handler failed.` because of `.properties()`. And it seems there is no official documentation for JXA, so I don't want waste my time any more. That's why this module doesn't have wide browsers support (but it could), I just don't know how to introspect properties on Application instance. Also see [this answer](https://stackoverflow.com/a/41923909/14982288).\n\nPlease, let me know if you have an idea how to make this module work on all platforms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzardoy%2Fread-browser-tabs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzardoy%2Fread-browser-tabs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzardoy%2Fread-browser-tabs/lists"}