
var EXPORT = ['urlEditor'];

elementGetter(this, 'addInput', 'hBookmark-urlEditor-add-input', document);
elementGetter(this, 'listbox', 'hBookmark-urlEditor-listbox', document);

var urlEditor = {
    get strings() {
        if (!Config._strings) {
            Config._strings = new Strings("chrome://hatenabookmark/locale/urlEditor.properties");
        }
        return Config._strings;
    },
    init: function() {
    },
    add: function() {
        let url = addInput.value;
        url = url.replace(/\s+/g, '');
        if (!url.length) return;

        try {
            new RegExp(url);
        } catch(e) {
            return alert(urlEditor.strings.get('regexError') + "\n" + url);
        }
        addInput.value = '';
        listbox.appendItem(url, url);
    },
    remove: function() {
        let i = listbox.selectedIndex;
        if (i >= 0)
            listbox.removeItemAt(i);
    },
    accept: function() {
        let res = [];
        for (var i = 0;  i < listbox.getRowCount(); i++) {
            let item = listbox.getItemAtIndex(i);
            res.push(item.value);
        }
        Application.prefs.get('extensions.hatenabookmark.statusbar.counterIgnoreList').value = uneval(res);
    },
    reset: function() {
        if (window.confirm(urlEditor.strings.get('defaultConfirm'))) {
            let current = Application.prefs.get('extensions.hatenabookmark.statusbar.counterIgnoreList').value;
            Application.prefs.get('extensions.hatenabookmark.statusbar.counterIgnoreList').reset();
            urlEditor.init();
            Application.prefs.get('extensions.hatenabookmark.statusbar.counterIgnoreList').value = current;
        }
    },
    init: function() {
        let list;
        try {
            list = eval(Application.prefs.get('extensions.hatenabookmark.statusbar.counterIgnoreList').value);
        } catch(e) {
            Application.prefs.get('extensions.hatenabookmark.statusbar.counterIgnoreList').reset();
            list = eval(Application.prefs.get('extensions.hatenabookmark.statusbar.counterIgnoreList').value);
        }
        while(listbox.getRowCount()) listbox.removeItemAt(0);
        list.forEach(function(v) listbox.appendItem(v, v));
    },
};



@@ -1,13 +1,12 @@
-%0A
 var EXPORT =
@@ -1108,37 +1108,39 @@
         
-Application.prefs.get
+PrefService.setCharPref
 ('extens
@@ -1187,25 +1187,17 @@
 oreList'
-).value =
+,
  uneval(
@@ -1200,16 +1200,17 @@
 val(res)
+)
 ;%0A    %7D,
@@ -1325,39 +1325,65 @@
 let 
-current = Application.prefs.get
+defaults = PrefService.getDefaultBranch(null).getCharPref
 ('ex
@@ -1435,22 +1435,16 @@
 reList')
-.value
 ;%0A      
@@ -1449,37 +1449,39 @@
         
-Application.prefs.get
+PrefService.setCharPref
 ('extens
@@ -1524,32 +1524,34 @@
 rIgnoreList'
-).reset(
+, defaults
 );%0A         
@@ -1575,116 +1575,8 @@
 ();%0A
-            Application.prefs.get('extensions.hatenabookmark.statusbar.counterIgnoreList').value = current;%0A
     
@@ -1667,37 +1667,39 @@
  = eval(
-Application.prefs.get
+PrefService.getCharPref
 ('extens
@@ -1739,38 +1739,32 @@
 nterIgnoreList')
-.value
 );%0A        %7D cat
@@ -1757,32 +1757,33 @@
 %0A        %7D catch
+ 
 (e) %7B%0A          
@@ -1788,93 +1788,229 @@
     
-Application.prefs.get('extensions.hatenabookmark.statusbar.counterIgnoreList').reset(
+let defaults = PrefService.getDefaultBranch(null).getCharPref('extensions.hatenabookmark.statusbar.counterIgnoreList');%0A            PrefService.setCharPref('extensions.hatenabookmark.statusbar.counterIgnoreList', defaults
 );%0A 
@@ -2036,29 +2036,31 @@
 val(
-Application.prefs.get
+PrefService.getCharPref
 ('ex
@@ -2112,22 +2112,16 @@
 reList')
-.value
 );%0A     
@@ -2257,10 +2257,8 @@
   %7D,%0A%7D;%0A
-%0A%0A

Replace Application.prefs (FUEL) with PrefService