{"id":15254648,"url":"https://github.com/eight04/gm_webextpref","last_synced_at":"2026-03-10T01:31:13.400Z","repository":{"id":38711022,"uuid":"145156825","full_name":"eight04/GM_webextPref","owner":"eight04","description":"Use webext-pref in userscripts.","archived":false,"fork":false,"pushed_at":"2021-08-18T06:46:10.000Z","size":281,"stargazers_count":8,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T22:11:36.544Z","etag":null,"topics":["userscript","webext-pref"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eight04.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-17T19:03:10.000Z","updated_at":"2024-04-20T13:50:20.000Z","dependencies_parsed_at":"2022-09-14T02:41:42.163Z","dependency_job_id":null,"html_url":"https://github.com/eight04/GM_webextPref","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eight04%2FGM_webextPref","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eight04%2FGM_webextPref/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eight04%2FGM_webextPref/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eight04%2FGM_webextPref/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eight04","download_url":"https://codeload.github.com/eight04/GM_webextPref/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248487692,"owners_count":21112190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["userscript","webext-pref"],"created_at":"2024-09-29T23:05:24.613Z","updated_at":"2026-03-10T01:31:12.430Z","avatar_url":"https://github.com/eight04.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"GM_webextPref\n=============\n\n[![Build Status](https://travis-ci.com/eight04/GM_webextPref.svg?branch=master)](https://travis-ci.com/eight04/GM_webextPref)\n[![codecov](https://codecov.io/gh/eight04/GM_webextPref/branch/master/graph/badge.svg)](https://codecov.io/gh/eight04/GM_webextPref)\n\nUse webext-pref in userscripts. This library includes `createPref`, `createView`, a storage object implemented with GM API, and a dialog service.\n\nInstallation\n------------\n\nYou can `@require` this script from [Greasy Fork](https://greasyfork.org/zh-TW/scripts/371339-gm-webextpref).\n\nThis library is also hosted on npm so you can import it with a build tool:\n\n```\nnpm install gm-webext-pref\n```\n\n```js\nimport GM_webextPref from \"gm-webext-pref\";\n```\n\nGrant\n-----\n\nThis script uses following permissions:\n\n\u003c!--$inline.start(\"cmd:userscript-meta \\\\| node filter-grant.mjs|trim|markdown:codeblock,js\")--\u003e\n```js\n// @grant GM_getValue\n// @grant GM.getValue\n// @grant GM_setValue\n// @grant GM.setValue\n// @grant GM_deleteValue\n// @grant GM.deleteValue\n// @grant GM_addValueChangeListener\n// @grant GM_registerMenuCommand\n// @grant GM.registerMenuCommand\n```\n\u003c!--$inline.end--\u003e\n\nDemo\n----\n\nhttps://rawgit.com/eight04/GM_webextPref/master/demo/demo.html\n\nUsage\n-----\n\n```js\nconst pref = GM_webextPref({\n  default: {\n    useImage: true,\n    excludeElements: \"code, .highlight\"\n  },\n  body: [\n    {\n      key: \"useImage\",\n      type: \"checkbox\",\n      label: \"Use image\"\n    },\n    {\n      key: \"excludeElements\",\n      type: \"text\",\n      label: \"Exclude elements\"\n    }\n  ]\n});\n\npref.ready()\n  .then(() =\u003e {\n    console.log(pref.get(\"useImage\")); // true\n  });\n```\n  \nAPI\n----\n\nThis module exports a single function.\n\n### GM_webextPref\n\n```js\nconst pref = GM_webextPref({\n  default: Object,\n  separator?: String,\n  css?: String,\n  ...options\n});\n```\n\nCreate a `pref` object. `pref` inherits all methods from the pref object returned by `createPref`.\n\n`default` and `separator` would be sent to [`createPref`](https://github.com/eight04/webext-pref#createpref).\n\n`css` would be injected to the dialog for customization.\n\nOther `options` would be passed to [`createUI`](https://github.com/eight04/webext-pref-ui#createui) and [`createBinding`](https://github.com/eight04/webext-pref-ui#createbinding).\n\nIf `GM_registerMenuCommand` exists, the function would register a menu command like:\n\n```js\nGM_registerMenuCommand(GM_info.script.name + \" - Configure\", pref.openDialog);\n```\n\nSo that users can open the config dialog through monkey menu.\n\n#### pref.openDialog\n\n```js\npref.openDialog();\n```\n\nOpen the config dialog.\n\nChangelog\n---------\n\n* 0.4.2 (Aug 18, 2021)\n\n  - Add: pass more options to `createBinding`, `createUI`, and `createPref`.\n  - Add: `css` option.\n\n* 0.4.1 (Aug 17, 2021)\n\n  - Add: support GM4 menu.\n\n* 0.4.0 (Aug 19, 2020)\n\n  - Update dependencies: webext-pref@0.6, webext-pref-ui@0.2\n  - Add: small UI that works better with small screen.\n\n* 0.3.0 (Aug 25, 2018)\n\n  - Update webext-pref to 0.5.0. Now the script requires `GM_deleteValue/GM.deleteValue` APIs.\n\n* 0.2.1 (Aug 24, 2018)\n\n  - Update webext-pref to 0.4.1. Add navbar tooltips.\n\n* 0.2.0 (Aug 21, 2018)\n\n  - Update webext-pref to 0.4.0. Drop `translate` arg.\n\n* 0.1.5 (Aug 20, 2018)\n\n  - Update webext-pref to 0.3.5. Fixed navbar error.\n\n* 0.1.4 (Aug 19, 2018)\n\n  - Add: style help text.\n\n* 0.1.3 (Aug 19, 2018)\n\n  - Fix: import/export buttons.\n  - Enhance: larger title.\n\n* 0.1.2 (Aug 19, 2018)\n\n  - Add: style checkbox children.\n\n* 0.1.1 (Aug 19, 2018)\n\n  - Fix: missing metadata.\n\n* 0.1.0 (Aug 19, 2018)\n\n  - First release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feight04%2Fgm_webextpref","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feight04%2Fgm_webextpref","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feight04%2Fgm_webextpref/lists"}