Greasy Fork is available in English.

GM_webextPref

A config library powered by webext-pref.

Tính đến 21-08-2018. Xem phiên bản mới nhất.

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://update.greasyfork.org/scripts/371339/622261/GM_webextPref.js

Tác giả
eight
Phiên bản
0.2.0
Đã tạo
19-08-2018
Đã cập nhật
21-08-2018
Giấy phép
MIT

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

Greasy Fork

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,
  body: Array,
  translate?: Object,
  getNewScope?: () => newScopeName: String
});

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

default would be sent to createPref; body, translate, and getNewScope would be sent to createView.

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.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.