Make some of the options dynamic

This change modifies the logic of several features so they aren't
enabled/disabled depending on the options state when the page is loaded
but dynamically.

So, for instance, when the thread list avatars feature is switched from
enabled to disabled, when browsing the Community Console, newly loaded
thread lists won't have the avatars, without having to reload the whole
Community Console.

This will make "kill switches" more effective, since they will be able
to take effect without having to reload the Community Console page.

The options which still haven't been made dynamic are features which add
CSS tweaks to the Community Console. For those features (like the dark
mode) a future CL will make them dynamic.

Bug: twpowertools:61
Change-Id: I72b511dd3b2622a2e9c633850e29806953e4b284
diff --git a/src/contentScripts/communityConsole/start.js b/src/contentScripts/communityConsole/start.js
index d4c4bd6..ae26cec 100644
--- a/src/contentScripts/communityConsole/start.js
+++ b/src/contentScripts/communityConsole/start.js
@@ -1,20 +1,21 @@
 import {injectScript, injectStylesheet} from '../../common/contentScriptsUtils.js';
+import {getOptions} from '../../common/optionsUtils.js';
 
 import AutoRefresh from './autoRefresh.js';
 
 const SMEI_UNIFIED_PROFILES = 9;
 
-chrome.storage.sync.get(null, function(items) {
+getOptions(null).then(options => {
   /* IMPORTANT NOTE: Remember to change this when changing the "ifs" below!! */
-  if (items.loaddrafts || items.disableunifiedprofiles) {
+  if (options.loaddrafts || options.disableunifiedprofiles) {
     var startup =
         JSON.parse(document.querySelector('html').getAttribute('data-startup'));
 
-    if (items.loaddrafts) {
+    if (options.loaddrafts) {
       startup[4][13] = true;
     }
 
-    if (items.disableunifiedprofiles) {
+    if (options.disableunifiedprofiles) {
       var index = startup[1][6].indexOf(SMEI_UNIFIED_PROFILES);
       if (index > -1) startup[1][6].splice(index, 1);
     }
@@ -25,13 +26,12 @@
 
   // Initialized here instead of in main.js so the first |ViewForumResponse|
   // event is received if it happens when the page loads.
-  if (items.autorefreshlist)
-    window.TWPTAutoRefresh = new AutoRefresh();
+  window.TWPTAutoRefresh = new AutoRefresh();
 
-  if (items.ccdarktheme) {
-    switch (items.ccdarktheme_mode) {
+  if (options.ccdarktheme) {
+    switch (options.ccdarktheme_mode) {
       case 'switch':
-        if (items.ccdarktheme_switch_status == true)
+        if (options.ccdarktheme_switch_status == true)
           injectStylesheet(chrome.runtime.getURL('css/ccdarktheme.css'));
         break;