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 🙏

© 2024 – Pkg Stats / Ryan Hefner

gm-webext-pref

v0.4.2

Published

A config library powered by webext-pref.

Downloads

5

Readme

GM_webextPref

Build Status codecov

Use webext-pref in userscripts. This library includes createPref, createView, a storage object implemented with GM API, and a dialog service.

Installation

You can @require this script from Greasy Fork.

This library is also hosted on npm so you can import it with a build tool:

npm install gm-webext-pref
import GM_webextPref from "gm-webext-pref";

Grant

This script uses following permissions:

// @grant GM_getValue
// @grant GM.getValue
// @grant GM_setValue
// @grant GM.setValue
// @grant GM_deleteValue
// @grant GM.deleteValue
// @grant GM_addValueChangeListener
// @grant GM_registerMenuCommand
// @grant GM.registerMenuCommand

Demo

https://rawgit.com/eight04/GM_webextPref/master/demo/demo.html

Usage

const pref = GM_webextPref({
  default: {
    useImage: true,
    excludeElements: "code, .highlight"
  },
  body: [
    {
      key: "useImage",
      type: "checkbox",
      label: "Use image"
    },
    {
      key: "excludeElements",
      type: "text",
      label: "Exclude elements"
    }
  ]
});

pref.ready()
  .then(() => {
    console.log(pref.get("useImage")); // true
  });

API

This module exports a single function.

GM_webextPref

const pref = GM_webextPref({
  default: Object,
  separator?: String,
  css?: String,
  ...options
});

Create a pref object. pref inherits all methods from the pref object returned by createPref.

default and separator would be sent to createPref.

css would be injected to the dialog for customization.

Other options would be passed to createUI and createBinding.

If GM_registerMenuCommand exists, the function would register a menu command like:

GM_registerMenuCommand(GM_info.script.name + " - Configure", pref.openDialog);

So that users can open the config dialog through monkey menu.

pref.openDialog

pref.openDialog();

Open the config dialog.

Changelog

  • 0.4.2 (Aug 18, 2021)

    • Add: pass more options to createBinding, createUI, and createPref.
    • Add: css option.
  • 0.4.1 (Aug 17, 2021)

    • Add: support GM4 menu.
  • 0.4.0 (Aug 19, 2020)

  • 0.3.0 (Aug 25, 2018)

    • Update webext-pref to 0.5.0. Now the script requires GM_deleteValue/GM.deleteValue APIs.
  • 0.2.1 (Aug 24, 2018)

    • Update webext-pref to 0.4.1. Add navbar tooltips.
  • 0.2.0 (Aug 21, 2018)

    • Update webext-pref to 0.4.0. Drop translate arg.
  • 0.1.5 (Aug 20, 2018)

    • Update webext-pref to 0.3.5. Fixed navbar error.
  • 0.1.4 (Aug 19, 2018)

    • Add: style help text.
  • 0.1.3 (Aug 19, 2018)

    • Fix: import/export buttons.
    • Enhance: larger title.
  • 0.1.2 (Aug 19, 2018)

    • Add: style checkbox children.
  • 0.1.1 (Aug 19, 2018)

    • Fix: missing metadata.
  • 0.1.0 (Aug 19, 2018)

    • First release.