{"id":29603286,"url":"https://github.com/micz/thunderbird-addon-options-manager","last_synced_at":"2025-09-09T06:29:54.531Z","repository":{"id":233051333,"uuid":"785710435","full_name":"micz/Thunderbird-Addon-Options-Manager","owner":"micz","description":"A simple Javascript manager to automatically handle the options for your Thunderbird Addon","archived":false,"fork":false,"pushed_at":"2025-06-10T20:55:13.000Z","size":68,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-19T12:57:27.537Z","etag":null,"topics":["javascript","thunderbird","thunderbird-addons","thunderbird-extension","tutorial"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/micz.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-12T13:09:52.000Z","updated_at":"2025-06-10T20:54:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"9079c07e-10e0-4e0b-951a-4490e2accb64","html_url":"https://github.com/micz/Thunderbird-Addon-Options-Manager","commit_stats":null,"previous_names":["micz/thunderbird-addon-options-manager"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/micz/Thunderbird-Addon-Options-Manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micz%2FThunderbird-Addon-Options-Manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micz%2FThunderbird-Addon-Options-Manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micz%2FThunderbird-Addon-Options-Manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micz%2FThunderbird-Addon-Options-Manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/micz","download_url":"https://codeload.github.com/micz/Thunderbird-Addon-Options-Manager/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micz%2FThunderbird-Addon-Options-Manager/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266135685,"owners_count":23881803,"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":["javascript","thunderbird","thunderbird-addons","thunderbird-extension","tutorial"],"created_at":"2025-07-20T14:06:50.269Z","updated_at":"2025-07-20T14:06:50.837Z","avatar_url":"https://github.com/micz.png","language":"JavaScript","funding_links":["https://www.paypal.com/donate/?business=UHN4SXPGEXWQL\u0026no_recurring=1\u0026item_name=Thunderbird+Addon+Option+Manager\u0026currency_code=EUR"],"categories":[],"sub_categories":[],"readme":"# Thunderbird Addon Options Manager\n\nThis guide explains how to use the provided files to manage the options page in a Thunderbird extension.\n\u003cbr\u003eThese files facilitate the handling of user preferences, providing a framework for both the presentation and persistence of settings.\n\n\n\n\u003cbr\u003e\n\n\n\n\n## Overview\n\n- **`th-addon-options.js`**: Contains logic for saving user preferences. It imports default settings from `th-addon-options-default.js` and provides methods to handle form submissions and preference storage.\n- **`th-addon-options-default.js`**: Defines default preferences for the extension. This can be customized to include any number of default settings your extension requires.\n- **`th-addon-options-onload.js`**: Loads the needed scripts in the option page.\n- **`th-addon-options.html`**: The HTML options example page.\n- **`th-addon-options.css`**: The CSS file to style your option page.\n\n\n\n\u003cbr\u003e\n\n\n\n\n## Setup\n\n1. **Include the Files**: Ensure that all four files are included in your extension's directory structure, ideally within a folder dedicated to options or preferences.\n2. **Define the options page**: Add your options page in the `manifest.json` extension's file, adding the needed section:\n```javascript\n\"options_ui\": {\n\t\t\"page\": \"PATH/TO/THE/FILES/th-addon-options.html\"\n\t}\n```\n\n\u003cbr\u003e\n\n\n\n\n### Change the options page\n\nModify the `th-addon-options.html` file to show all your needed settings.\n\n\n\n\u003cbr\u003e\n\n\n\n### Defining Default Preferences\n\nModify `th-addon-options-default.js` to include all the default settings for your extension.\n\u003cbr\u003eFor example:\n\n```javascript\nexport const prefs_default = {\n    'example_setting': true,\n    'number_of_days': 7\n};\n```\n\n\n\u003cbr\u003e\n\n\n\n\n### Saving Preferences\n\n`th-addon-options.js` is set up to save and load preferences when each of them is modified.\n\u003cbr\u003eEnsure your options inputs have the `option-input` class.\n\u003cbr\u003eFor example, for a checkbox:\n\n```html\n\u003cinput type=\"checkbox\" id=\"example_setting\" name=\"example_setting\" class=\"option-input\" /\u003e\n```\n\nSee more examples in the `th-addon-options.html` file.\n\nDefine your options page in the `th-addon-options.html` file and the default values in the `th-addon-options-default.js` file.\n\u003cbr\u003eAfter that, everythig is handled automatically.\n\n\u003e [!IMPORTANT]\n\u003e Only the inputs with the `option-input` class are loaded and saved when modified. Without this class they are ignored.\n\n\n\n\u003cbr\u003e\n\n\n\n\n## Usage\n\nIn your extension javscript files you have to import the needed objects like this:\n\n```javascript\nimport { ADDON_prefs } from '\u003cPATH/TO/THE/FILES/th-addon-options.js';\n```\n\nGet a single preference using the `getPref` method:\n\n```javascript\nlet string_pref = await ADDON_prefs.getPref(\"string_pref\");\n```\n\nThe method will load the string_pref value if present, or the default one, to the `string_pref` variable.\n\n\u003cbr\u003e\n\nOtherwise you can get many preferences at once using the `getPrefs` method:\n\n```javascript\nlet prefs = await ADDON_prefs.getPrefs([\"test_number\",\"test_string\"]);\n```\n\nThe method will load the values if present, or the default ones, to an object like:\n\n```javascript\n{\"test_number\":81,\"test_string\":\"hola!\"}\n```\n\n\n\n\u003cbr\u003e\n\n\n\n\n## Saving a single preference\nIf you need to save a single preference without using the automatic method described above, you can use the `setPref` async method.\n\n```javascript\nADDON_prefs.setPref(\"test_string\", pref_value);\n```\n\n\"test_string\" is the preference id, to be used to retrieve it when needed, and `pref_value` is a variable containing the value to be saved.\n\n\n\n\u003cbr\u003e\n\n\n\n\n## Using an external logger\nBy default the methods will log to `console`.\nYou can define a custom logger, assigning it to the `logger` proprierty:\n\n```javascript\nADDON_prefs.logger = myCustomLogger\n```\nThe custom logger must implement the `log` method: `myCustomLogger.log(log_message)`.\n\n\n\u003cbr\u003e\n\n## Support this work!\nAre you using this code in your Thunderbird addon?\n\u003cbr\u003eConsider to support the development making a small donation. [Click here!](https://www.paypal.com/donate/?business=UHN4SXPGEXWQL\u0026no_recurring=1\u0026item_name=Thunderbird+Addon+Option+Manager\u0026currency_code=EUR)\n\n\n\n\n\u003cbr\u003e\n\n\n\n\n## Find out who is using this code!\n\nCheck the [list of add-ons](WHO_IS_USING_IT.md) that are using this code and list also your one!\n\n\n\n\u003cbr\u003e\n\n\n\n\n## How to contribute\n\nFeel free to fork the repository and make a pull request to improve the code or this guide.\n\n\n\n\n\u003cbr\u003e\n\n\n\n\n## LICENSE\n\nThis code is distributed under the [MPL 2.0 license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicz%2Fthunderbird-addon-options-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicz%2Fthunderbird-addon-options-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicz%2Fthunderbird-addon-options-manager/lists"}