Add option to enable the 'SMEI_SORT_DIRECTION' experiment

This option, when enabled, activates the SMEI_SORT_DIRECTION experiment,
which is disabled by default in the Community Console.

This experiment lets user set the sort direction in thread lists, so
threads can be ordered in ascending or descending order.

Fixes: #25
Change-Id: Ie8f6825e70d11ee7d3e20a38a7f20e2a34780d9f
diff --git a/src/_locales/ca/messages.json b/src/_locales/ca/messages.json
index 482d022..87fda39 100644
--- a/src/_locales/ca/messages.json
+++ b/src/_locales/ca/messages.json
@@ -87,6 +87,10 @@
     "message": "Afegeix l'opció per bloquejar diversos fils a la llista de fils de la Consola de la Comunitat.",
     "description": "Feature checkbox in the options page"
   },
+  "options_smei_sortdirection": {
+    "message": "Activa l'experiment <code class=\"help\" title=\"Aquest experiment et permet ordenar la llista de fils de la Consola de la Comunitat en ordre ascendent o descendent.\">SMEI_SORT_DIRECTION</code>.",
+    "description": "Feature checkbox in the options page"
+  },
   "options_profileindicator_header": {
     "message": "Punt indicador",
     "description": "Heading for the profile indicator feature options"
diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json
index ab740c1..65b2640 100644
--- a/src/_locales/en/messages.json
+++ b/src/_locales/en/messages.json
@@ -91,6 +91,10 @@
     "message": "Add the option to lock multiple threads from the Community Console thread list.",
     "description": "Feature checkbox in the options page"
   },
+  "options_smei_sortdirection": {
+    "message": "Enable the <code class=\"help\" title=\"This experiment lets you sort the Community Console thread list in ascending or descending order.\">SMEI_SORT_DIRECTION</code> experiment.",
+    "description": "Feature checkbox in the options page"
+  },
   "options_profileindicator_header": {
     "message": "Indicator dot",
     "description": "Heading for the profile indicator feature options"
diff --git a/src/_locales/es/messages.json b/src/_locales/es/messages.json
index a0e97bf..0e5b0a6 100644
--- a/src/_locales/es/messages.json
+++ b/src/_locales/es/messages.json
@@ -87,6 +87,10 @@
     "message": "Añade la opción para bloquear varios hilos en la lista de hilos de la Consola de la Comunidad.",
     "description": "Feature checkbox in the options page"
   },
+  "options_smei_sortdirection": {
+    "message": "Activa el experimento <code class=\"help\" title=\"Este experimento te permite ordenar la lista de hilos de la Consola de la Comunidad en orden ascendente o descendente.\">SMEI_SORT_DIRECTION</code>.",
+    "description": "Feature checkbox in the options page"
+  },
   "options_profileindicator_header": {
     "message": "Punto indicador",
     "description": "Heading for the profile indicator feature options"
diff --git a/src/common/common.js b/src/common/common.js
index 3426fb0..28a86fd 100644
--- a/src/common/common.js
+++ b/src/common/common.js
@@ -20,6 +20,7 @@
   'ccforcehidedrawer': false,
   'ccdragndropfix': false,
   'batchlock': false,
+  'smei_sortdirection': false,
 };
 
 const specialOptions = [
diff --git a/src/content_scripts/console_inject_start.js b/src/content_scripts/console_inject_start.js
index 52482c5..f0bda9b 100644
--- a/src/content_scripts/console_inject_start.js
+++ b/src/content_scripts/console_inject_start.js
@@ -7,6 +7,11 @@
       startup[4][13] = true;
     }
 
+    if (items.smei_sortdirection) {
+      if (!startup[1][6].includes(8))
+        startup[1][6].push(8);
+    }
+
     document.querySelector('html').setAttribute(
         'data-startup', JSON.stringify(startup));
   }
diff --git a/src/options/options.html b/src/options/options.html
index 6edd040..15716da 100644
--- a/src/options/options.html
+++ b/src/options/options.html
@@ -32,6 +32,7 @@
       <div class="option"><input type="checkbox" id="ccforcehidedrawer"> <label for="ccforcehidedrawer" data-i18n="ccforcehidedrawer"></label></div>
       <div id="dragndrop-wrapper" class="option" hidden><input type="checkbox" id="ccdragndropfix"> <label for="ccdragndropfix" data-i18n="ccdragndropfix"></label></div>
       <div class="option"><input type="checkbox" id="batchlock"> <label for="batchlock" data-i18n="batchlock"></label> <span class="experimental-label" data-i18n="experimental_label"></span></div>
+      <div class="option"><input type="checkbox" id="smei_sortdirection"> <label for="smei_sortdirection" data-i18n="smei_sortdirection"></label> <span class="experimental-label" data-i18n="experimental_label"></span></div>
       <h4 data-i18n="profileindicator_header"></h4>
       <div class="option"><input type="checkbox" id="profileindicator"> <label for="profileindicator" data-i18n="profileindicator"></label> <span class="experimental-label" data-i18n="experimental_label"></span></div>
       <div class="option"><input type="checkbox" id="profileindicatoralt"> <label for="profileindicatoralt" data-i18n="profileindicatoralt"></label> <span class="experimental-label" data-i18n="experimental_label"></span></div>