npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chrome-extension-helper

v0.13.2

Published

A library of constructs for Google Chrome extensions

Readme

chrome-extension-helper

npm version npm downloads License
Build Status Code Climate js-myterminal-style Coverage Status
ko-fi
NPM

A library of constructs for Google Chrome extensions

Wrappers

  • Storage: chrome.storage.local & chrome.storage.sync
  • Notifications: chrome.notifications

How to Use

Directly from a web page

One can use chrome-extension-helper directly from a web-page by attaching script file to the DOM.

<!-- Attaching the chrome-extension-helper script -->
<script type="text/javascript" src="path/to/library/chrome-extension-helper.js"></script>

<!-- Usage -->
<script type="text/javascript">
    chromeExtensionHelper.storage.initializeStorage();
</script>

With Webpack, Browserify or RequireJS

Install chrome-extension-helper from NPM

npm install chrome-extension-helper --save-dev

Consume as an ES6 module

import * as helpers from 'chrome-extension-helper';

or

import helpers from 'chrome-extension-helper';

or

import { storage } from 'chrome-extension-helper';

Consume as a CommonJS module

var helpers = require('chrome-extension-helper');

Consume as an AMD

require(['chrome-extension-helper'], function (helpers) {
    // Consume helpers
}

Included wrappers

Note: The API is tentative and is very likely to change by a great degree in upcoming versions.

Storage

This wrapper around chrome.storage includes a couple of methods to make working with Chrome extension storage a little convenient.

import { storage } from 'chrome-extension-helper';

The first step should be initialization.

storage.initializeStorage(onError);

When there is an error accessing storage, the function onError is called with a string specifying a reason for the error.

Once the initialization is done, local or synced properties can be instantiated. Whether you create a local property or a synced property, the constructor is exactly the same but the difference lies in behavior, which is exactly the difference between chrome.storage.local and chrome.storage.sync respectively.

Below is an example of how a synced property can be created.

const colorMode = storage.createSyncedProperty(
    'color-mode', // Key used in store
    colorModes, // A set of possible values for the property
    value => {
        const bodyDom = document.body;

        bodyDom.className = bodyDom.className
            .replace(/ (light|dark)/, '')
            + ` ${value}`;

        document.querySelector('#color-mode').innerText = value;
    } // A handler to reflect a change on the UI
);

The above snippet creates a synced property with the supplied name in store, that can have the specified possible values and a change to the property (locally or from a different extension instance, as this is a synced property) will be automatically reflected on the UI according to the passed handler. The returned property has the following properties/methods attached:

  • name - The name of the property
  • values - An array of possible values for the property
  • set - A function that takes in a new value and a callback that is passed with the value when the update is complete
  • get - A function that is called with the current value once it is retrieved from storage
  • load (optional) - A handler that accepts a value and can handle change to the value. Currently, it is used internally to reflect changes on the UI and is not supposed to be used from external code.
  • read - A function that reads the current value of the property and loads it using the loader. Internally, it's as simple as calling a get and using the value in a load.

Notifications

This wrapper around chrome.notifications currently only includes a single method for being able to create a basic notification with a title, message and an icon.

import { notifications } from 'chrome-extension-helper';

const showError = message => {
    notifications.showSimpleNotification(
        'error',
        {
            iconUrl: 'icons/error.png',
            title: 'There was an error!',
            message
        }
    );
}

Below are the required parameters:

  • id - This is required to create a notification, could be any unique string
  • An object containing iconUrl, title and message. Due to a limitation, the icon being used needs to be defined in the manifest file as you can see here.

To-do

  • Implement more wrappers
  • Write unit-tests