GM_webextPref

A config library powered by webext-pref.

目前為 2018-08-19 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/371339/621764/GM_webextPref.js

作者
eight
版本
0.1.1
建立日期
2018-08-19
更新日期
2018-08-19
尺寸
29.1 KB
授權條款
MIT

GM_webextPref
=============

[![Build Status](https://travis-ci.org/eight04/gm-webext-pref.svg?branch=master)](https://travis-ci.org/eight04/gm-webext-pref)
[![codecov](https://codecov.io/gh/eight04/gm-webext-pref/branch/master/graph/badge.svg)](https://codecov.io/gh/eight04/gm-webext-pref)

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

Installation
------------

[Greasy Fork镜像](http://example.com)

Usage
-----

```js
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

```js
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:

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

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

#### pref.openDialog

```js
pref.openDialog();
```

Open the config dialog.

Changelog
---------

* 0.1.1 (Aug 19, 2018)

- Fix: missing metadata.

* 0.1.0 (Aug 19, 2018)

- First release.

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址