mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
lets use storage.sync and browser_style (#210)
This commit is contained in:
@@ -10,8 +10,14 @@
|
||||
"manifest_version": 2,
|
||||
"name": "Favourite colour",
|
||||
"options_ui": {
|
||||
"page": "options.html"
|
||||
"page": "options.html",
|
||||
"browser_style": true
|
||||
},
|
||||
"permissions": ["storage"],
|
||||
"version": "1.0"
|
||||
"version": "1.1",
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "favourite-colour-examples@mozilla.org"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
|
||||
<body>
|
||||
<form>
|
||||
<fieldset>
|
||||
<legend>Options</legend>
|
||||
<p>Favourite colour</p>
|
||||
<label>Favourite colour</label>
|
||||
<input type="text" id="colour" >
|
||||
<button type="submit">Save</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
<script src="options.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
function saveOptions(e) {
|
||||
browser.storage.local.set({
|
||||
browser.storage.sync.set({
|
||||
colour: document.querySelector("#colour").value
|
||||
});
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
function restoreOptions() {
|
||||
var gettingItem = browser.storage.local.get('colour');
|
||||
var gettingItem = browser.storage.sync.get('colour');
|
||||
gettingItem.then((res) => {
|
||||
document.querySelector("#colour").value = res.colour || 'Firefox red';
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user