aboutsummaryrefslogtreecommitdiff
path: root/src/pages/settings.js
blob: 6e00ed343982ec4f18b3ceab6776225b6b34f6b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import './settings.scss';
import messages from '../content/messages';

document.addEventListener('DOMContentLoaded', () => {
  let form = document.getElementById('vimvixen-settings-form');
  form.addEventListener('submit', (e) => {
    e.preventDefault();
    browser.storage.local.set({
      settings: {
        json: e.target.elements['plain-json'].value
      }
    }).then(() => {
      return browser.runtime.sendMessage({
        type: messages.SETTINGS_RELOAD
      });
    });
  });

  browser.storage.local.get('settings').then((value) => {
    form.elements['plain-json'].value = value.settings.json;
  }, console.error);
});