diff options
-rw-r--r-- | manifest.json | 10 | ||||
-rw-r--r-- | src/settings/index.js | 19 | ||||
-rw-r--r-- | src/settings/settings.html | 15 | ||||
-rw-r--r-- | src/settings/settings.scss | 7 | ||||
-rw-r--r-- | webpack.config.js | 6 |
5 files changed, 54 insertions, 3 deletions
diff --git a/manifest.json b/manifest.json index dfb4ae9..7c60cdd 100644 --- a/manifest.json +++ b/manifest.json @@ -15,11 +15,15 @@ ] }, "permissions": [ + "history", "sessions", - "tabs", - "history" + "storage", + "tabs" ], "web_accessible_resources": [ "build/console.html" - ] + ], + "options_ui": { + "page": "build/settings.html" + } } diff --git a/src/settings/index.js b/src/settings/index.js new file mode 100644 index 0000000..f2bba32 --- /dev/null +++ b/src/settings/index.js @@ -0,0 +1,19 @@ +import './settings.scss'; + +let form = document.getElementById('vimvixen-settings-form'); + +form.addEventListener('submit', (e) => { + let value = { + json: e.target.elements['plain-json'].value + }; + e.preventDefault(); + browser.storage.local.set(value); +}); + +document.addEventListener('DOMContentLoaded', () => { + browser.storage.local.get().then((value) => { + if (value.json) { + form.elements['plain-json'].value = value.json; + } + }, console.error); +}); diff --git a/src/settings/settings.html b/src/settings/settings.html new file mode 100644 index 0000000..1719d6c --- /dev/null +++ b/src/settings/settings.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset='utf-8'> + </head> + <body> + <form id='vimvixen-settings-form' class='vimvixen-settings-form'> + <label for='plain-json'>Settings by plain json: </label> + <textarea + name='plain-json'></textarea> + <button type='submit'>Save</button> + </form> + <script src='settings.js'></script> + </body> +</html> diff --git a/src/settings/settings.scss b/src/settings/settings.scss new file mode 100644 index 0000000..5a0f08c --- /dev/null +++ b/src/settings/settings.scss @@ -0,0 +1,7 @@ +.vimvixen-settings-form { + textarea[name=plain-json] { + font-family: monospace; + width: 100%; + resize: vertical; + } +} diff --git a/webpack.config.js b/webpack.config.js index ba08975..bf121d1 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -7,6 +7,7 @@ const dist = path.resolve(__dirname, 'build'); module.exports = { entry: { index: path.join(src, 'content'), + settings: path.join(src, 'settings'), background: path.join(src, 'background'), console: path.join(src, 'console', 'console.js') }, @@ -46,6 +47,11 @@ module.exports = { template: path.join(src, 'console', 'console.html'), filename: path.join(dist, 'console.html'), inject: false + }), + new HtmlWebpackPlugin({ + template: path.join(src, 'settings', 'settings.html'), + filename: path.join(dist, 'settings.html'), + inject: false }) ] }; |