Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chrome-tool

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chrome-tool

Useful functions for creating Chrome apps and extensions

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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

Installation:

npm install chrome-tool --save

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 git@github.com:[USERNAME]/chrome-tool.git
make

Watch for changes and recompile:

make watch

Run tests:

npm test

Keywords

FAQs

Package last updated on 17 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc