/then-chrome

Promise-based chrome-api

Primary LanguageJavaScript

then-chrome

Build Status npm version Code Climate

Promise-based chrome api.

usage

var chromeApi = require('then-chrome');

// get tabs list
chromeApi.tabs.query({currentWindow: true})
   .then(console.log); // tabs list

// get all cookies by name   
chromeApi.cookies.getAll({name: 'cookieName'})
   .then(console.log); // cookie list
   
// detect language by tab
chromeApi.tabs.detectLanguage(10)
   .then(console.log); // en
   .catch(console.warn); // catch chrome.runtime.lastError value

Sycn methods are wrapped too

var chromeApi = require('then-chrome');

chromeApi.i18n.getMessage('title')
   .then(console.log); // 'extension title'

install

npm install then-chrome

or

git clone https://github.com/acvetkov/then-chrome.git
cd then-chrome
npm install

build

npm run build

test

npm test

Supported methods

  1. chrome.alarms
  2. chrome.cookies
  3. chrome.bookmarks
  4. chrome.browserAction
  5. chrome.contextMenus
  6. chrome.history
  7. chrome.i18n
  8. chrome.management
  9. chrome.notifications
  10. chrome.pageAction
  11. chrome.permissions
  12. chrome.runtime
  13. chrome.tabs
  14. chrome.topSites
  15. chrome.webNavigation
  16. chrome.windows