您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
A config library powered by webext-pref.
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/371339/621764/GM_webextPref.js
GM_webextPref
=============
[](https://travis-ci.org/eight04/gm-webext-pref)
[](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.