Giter Site home page Giter Site logo

shinnn / get-chrome-tabs Goto Github PK

View Code? Open in Web Editor NEW
15.0 1.0 3.0 80 KB

Get information of the currently opened Chrome tabs, for example URLs and titles

License: ISC License

JavaScript 100.00%
nodejs javascript chrome chromium open-scripting-architecture jxa tabs promise osa browser

get-chrome-tabs's Introduction

get-chrome-tabs

npm version Build Status Coverage Status

Get information of the currently opened Chrome tabs, for example URLs and titles

 

const getChromeTabs = require('get-chrome-tabs');

(async () => getChromeTabs() /* => [
  {
    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

Use npm.

npm install get-chrome-tabs

API

const getChromeTabs = require('get-chrome-tabs');

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 getChromeTabs();
  } catch (err) {
    err.message; //=> 'Tried to get tabs of Chrome, but Chrome is currently not running.'
  }

  await getChromeTabs({app: 'canary'}); //=> [{windowIndex: 0, windowVisible: true, ...}, ...]
})();

License

ISC License © 2018 - 2019 Shinnosuke Watanabe

get-chrome-tabs's People

Contributors

shinnn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

get-chrome-tabs's Issues

Is this library still maintained?

I'm frustrated that it takes a lot of time to read info about all tabs, especially when a lot of windows are opened. I want an option to read tabs only from the most top window.

You can test it by opening 43 chrome windows. NodeJS process will just crash.

@shinnn Can we completely refactor this in TypeScript or will you accept the corresponding PR?

Question

Is it possible to auto swich tab from app?

For example if user is watching on some browser tab youtube video and at some point he gots online chat message in other tab of the same browser then somehow he must auto switch from youtube tab to the tab where is the online chat

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.