rename from some options to favourite colour

This commit is contained in:
Andy McKay
2016-04-19 09:47:12 -07:00
parent 66e77bbaea
commit 39617d6174
5 changed files with 25 additions and 2 deletions

View File

@@ -0,0 +1,4 @@
# Favourite Colour
Shows and stores your favourite color, in chrome.storage.local
in the about:addons page for the addon.

View File

@@ -0,0 +1,5 @@
function handleClick() {
chrome.runtime.openOptionsPage();
}
chrome.browserAction.onClicked.addListener(handleClick);

View File

@@ -1,7 +1,7 @@
{
"applications": {
"gecko": {
"id": "favourite-colour@mozilla.org",
"id": "some-options@mozilla.org",
"strict_min_version": "47.0a1"
}
},
@@ -16,7 +16,7 @@
"manifest_version": 2,
"name": "Favourite colour",
"options_ui": {
"page": "options.html",
"page": "options.html"
},
"permissions": ["storage"],
"version": "1.0"

View File

@@ -0,0 +1,14 @@
function saveOptions(e) {
chrome.storage.local.set({
colour: document.querySelector("#colour").value
});
}
function restoreOptions() {
chrome.storage.local.get('colour', (res) => {
document.querySelector("#colour").value = res.colour || 'Firefox red';
});
}
document.addEventListener('DOMContentLoaded', restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);