get-chrome-tabs
Get information of the currently opened Chrome tabs, for example URLs and titles
const getChromeTabs = ; async /* => [ { windowIndex: 0, windowVisible: true, url: 'https://github.com/', title: 'GitHub', active: true, loading: false }, { windowIndex: 0, windowVisible: true, url: 'https://www.npmjs.com/package/get-chrome-tabs', title: 'get-chrome-tabs - npm', active: false, loading: false }, { windowIndex: 1, windowVisible: true, url: 'https://example.org/', title: 'Example Domain', active: true, loading: false }] */;
Installation
npm install get-chrome-tabs
API
const getChromeTabs = ;
getChromeTabs([option])
option: Object
Return: Promise<Array<Object>>
macOS with JXA support is required.
Each object included in the resultant array has the following properties:
- windowIndex
integer
– An index of the window which contains the tab (0
(foremost),1
, ...) - windowVisible
boolean
– Whether the window which contains the tab is visible or not - url
string
– A URL currently opened by the tab - title
string
– The tab title - active
boolean
– Whether the tab is currently selected or not. Each window has one active tab. - loading
boolean
- Whether the tab is loading or not
It will be rejected when Chrome is not running.
option.app
Type: string
(either 'canary'
or 'chromium'
)
Instead of Chrome (default), refer to Chrome Canary or Chromium.
// When Chrome is not running but Chrome Canary is running async { try await ; catch err errmessage; //=> 'Tried to get tabs of Chrome, but Chrome is currently not running.' await ; //=> [{windowIndex: 0, windowVisible: true, ...}, ...]};
License
ISC License © 2018 Shinnosuke Watanabe