Git Product home page Git Product logo

chrome-tool's Introduction

chrome-tool

Build Status Dependencies Development Dependencies

Compatible with Chrome 45 and higher. For older versions you might need to polyfill these:

  • Object.assign
  • Promise
  • Map

npm

Tabs

import { Tabs } from 'chrome-tool';

The API works like chrome.tabs.* except that it returns promises.

Functions:

  • Tabs.get(tabId: number): Promise
  • Tabs.getCurrent(): Promise
  • Tabs.create(createProperties): Promise
  • Tabs.duplicate(tabId: number): Promise
  • Tabs.query(queryInfo): Promise
  • Tabs.highlight(highlightInfo): Promise
  • Tabs.update(tabId?: number, updateProperties): Promise
  • Tabs.move(tabIds: number | number[], moveProperties): Promise
  • Tabs.reload(tabId?: number, reloadProperties?): Promise
  • Tabs.remove(tabIds: number | number[]): Promise
  • Tabs.detectLanguage(tabId?: number): Promise
  • Tabs.captureVisibleTab(windowId?: number, options?): Promise
  • Tabs.executeScript(tabId?: number, details): Promise
  • Tabs.insertCSS(tabId?: number, object details): Promise
  • Tabs.setZoom(tabId?: number, zoomFactor: number): Promise
  • Tabs.getZoom(tabId?: number): Promise
  • Tabs.setZoomSettings(tabId?: number, zoomSettings): Promise
  • Tabs.getZoomSettings(tabId?: number): Promise

Events:

  • Tabs.onCreated(callback): void
  • Tabs.onUpdated(callback): void
  • Tabs.onMoved(callback): void
  • Tabs.onSelectionChanged(callback): void
  • Tabs.onActiveChanged(callback): void
  • Tabs.onActivated(callback): void
  • Tabs.onHighlightChanged(callback): void
  • Tabs.onHighlighted(callback): void
  • Tabs.onDetached(callback): void
  • Tabs.onAttached(callback): void
  • Tabs.onRemoved(callback): void
  • Tabs.onReplaced(callback): void
  • Tabs.onZoomChange(callback): void

Custom functions:

  • Tabs.getHighlighted(): Promise
  • Tabs.getActive(): Promise
  • Tabs.open(openerTab: { id: number }, url: string): Promise
  • Tabs.count(): Promise
  • Tabs.moveHighlighted(direction: number): Promise
  • Tabs.moveToNewWindow(tabs: Tab[], incognito: boolean): Promise
  • Tabs.moveToWindow(tabs: Tab[], targetWindowId: number): Promise
  • Tabs.closeOthers(): Promise

Windows

import { Windows } from 'chrome-tool';

The API works like chrome.windows.* except that it returns promises.

Functions:

  • Windows.get(windowId, getInfo?): Promise
  • Windows.getCurrent(getInfo?): Promise
  • Windows.getLastFocused(getInfo?): Promise
  • Windows.getAll(getInfo?): Promise
  • Windows.create(createData?): Promise
  • Windows.update(windowId, updateInfo): Promise
  • Windows.remove(windowId): Promise

Events:

  • Windows.onCreated(callback): void
  • Windows.onRemoved(callback): void
  • Windows.onFocusChanged(callback): void

Custom functions:

  • Windows.open(windows: string[][], reuseThreshold = 1): void
    • windows: 2-dimensional array of URLs to open as windows
    • reuseThreshold: Re-uses the current window if its number of tabs is less than or equal

Runtime

import { Runtime } from 'chrome-tool';

The API works like chrome.runtime.* except that it returns promises.

Functions:

  • Runtime.getBackgroundPage(): Promise
  • Runtime.openOptionsPage(): Promise
  • Runtime.getManifest(): any
  • Runtime.getURL(string path): string
  • Runtime.setUninstallURL(url: string): Promise
  • Runtime.reload(): void
  • Runtime.requestUpdateCheck(): Promise
  • Runtime.restart(): void
  • Runtime.connect(extensionId?: string, connectInfo?): Port
  • Runtime.connectNative(application: string): Port
  • Runtime.sendNativeMessage(application: string, message): Promise
  • Runtime.getPlatformInfo(): Promise
  • Runtime.getPackageDirectoryEntry(): Promise

Modified functions (these work differently than described in Chrome's docs):

  • sendMessage(operation: string, message): Promise
  • onMessage(operation: string, callback): void

Events:

  • Runtime.onStartup(callback): void
  • Runtime.onInstalled(callback): void
  • Runtime.onSuspend(callback): void
  • Runtime.onSuspendCanceled(callback): void
  • Runtime.onUpdateAvailable(callback): void
  • Runtime.onConnect(callback): void
  • Runtime.onConnectExternal(callback): void
  • Runtime.onMessageExternal(callback): void
  • Runtime.onRestartRequired(callback): void

StorageSync

import { StorageSync } from 'chrome-tool';

The API works like chrome.storage.sync.* except that it returns promises.

Functions:

  • StorageSync.get(keys?: string | string[] | object): Promise
  • StorageSync.getBytesInUse(keys?: string | string[]): Promise
  • StorageSync.set(items): Promise
  • StorageSync.remove(keys: string | string[]): Promise
  • StorageSync.clear(): Promise

Events:

  • StorageSync.onChanged(callback): void

BrowserAction

import { BrowserAction } from 'chrome-tool';

The API works like chrome.browserAction.* except that it returns promises.

Functions:

  • BrowserAction.getTitle(details: object): Promise
  • BrowserAction.getPopup(details: object): Promise
  • BrowserAction.getBadgeText(details: object): Promise
  • BrowserAction.getBadgeBackgroundColor(details: object): Promise
  • BrowserAction.setTitle(details: object): void
  • BrowserAction.setPopup(details: object): void
  • BrowserAction.setBadgeText(details: object): void
  • BrowserAction.setBadgeBackgroundColor(details: object): void
  • BrowserAction.setIcon(details: object): Promise
  • BrowserAction.enable(tabId?: number): void
  • BrowserAction.disable(tabId?: number): void

Events:

  • BrowserAction.onClicked(callback): void

Management

import { getExtensionInfo } from 'chrome-tool/management';

Functions:

Internationalization

import { getString } from 'chrome-tool/i18n';

ContextMenuItem

import { ContextMenuItem } from 'chrome-tool/i18n';

chrome.contextMenus.*

let item = new ContextMenuItem(id?: string, contexts?: string[], onclick?: function);
item.show();
item.hide();
item.setVisible(visibility: boolean);

Contributing

Download source and compile:

git clone [email protected]:[USERNAME]/chrome-tool.git
make

Watch for changes and recompile:

make watch

Run tests:

npm test

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.