Greasy Fork

Greasy Fork is available in English.

GM_webextPref

A config library powered by webext-pref.

当前为 2018-08-19 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/371339/621764/GM_webextPref.js

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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