Revert "feat!: remove features related to the old thread page view"

This reverts commit 879d44aef99524c84719d91c628e772fba9335cb.

Reason for revert: It turns out the old reply editor can still be used
in the new thread page view by pressing the "R" key, and this can/will
make the CC communicate with the draft endpoints to save/retrieve
information.

Apart from this, some PEs were using the "old thread page" option as
well, even if it doesn't load all replies.

Finally, this revert also contains some changes to the modifications to
the data startup object so they work correctly (since now we have to use
StartupDataStorage, otherwise changes might not be saved).

Bug: twpowertools:124
Change-Id: Ie8153b9c8ef150b2417cb19b73bde0a5593876e2
diff --git a/src/options/bgHandler.js b/src/options/bgHandler.js
index 828eb22..c97c935 100644
--- a/src/options/bgHandler.js
+++ b/src/options/bgHandler.js
@@ -3,23 +3,42 @@
 // content scripts or injected scripts but instead in the background
 // script/service worker.
 //
-// An example was the "blockdrafts" feature, which when enabled enabled the
+// An example is the "blockdrafts" feature, which when enabled should enable the
 // static ruleset blocking *DraftMessages requests.
-//
-// The "blockdrafts" feature was removed, but this logic has been kept in case
-// it is needed in the future.
 
 import {isOptionEnabled} from '../common/options/optionsUtils.js';
 
 // List of features controled in the background:
-export var bgFeatures = [];
+export var bgFeatures = [
+  'blockdrafts',
+];
+
+const blockDraftsRuleset = 'blockDrafts';
 
 export function handleBgOptionChange(feature) {
   isOptionEnabled(feature)
-      // eslint-disable-next-line no-unused-vars
       .then(enabled => {
-        // eslint-disable-next-line no-empty
-        switch (feature) {}
+        switch (feature) {
+          // #!if ['chromium', 'chromium_mv3'].includes(browser_target)
+          case 'blockdrafts':
+            chrome.declarativeNetRequest.getEnabledRulesets(rulesets => {
+              if (rulesets === undefined) {
+                throw new Error(
+                    chrome.runtime.lastError.message ??
+                    'Unknown error in chrome.declarativeNetRequest.getEnabledRulesets()');
+              }
+
+              let isRulesetEnabled = rulesets.includes(blockDraftsRuleset);
+              if (!isRulesetEnabled && enabled)
+                chrome.declarativeNetRequest.updateEnabledRulesets(
+                    {enableRulesetIds: [blockDraftsRuleset]});
+              if (isRulesetEnabled && !enabled)
+                chrome.declarativeNetRequest.updateEnabledRulesets(
+                    {disableRulesetIds: [blockDraftsRuleset]});
+            });
+            break;
+            // #!endif
+        }
       })
       .catch(err => {
         console.error(
diff --git a/src/options/optionsCommon.js b/src/options/optionsCommon.js
index badeaf1..6d41a39 100644
--- a/src/options/optionsCommon.js
+++ b/src/options/optionsCommon.js
@@ -19,6 +19,9 @@
       case 'ccdarktheme_mode':
         return document.getElementById(opt).value || 'switch';
 
+      case 'interopthreadpage_mode':
+        return document.getElementById(opt).value || 'previous';
+
       default:
         console.warn('Unrecognized option: ' + opt);
         return undefined;
@@ -223,6 +226,25 @@
                 .appendChild(select);
             break;
 
+          case 'interopthreadpage_mode':
+            var select = document.createElement('select');
+            select.id = 'interopthreadpage_mode';
+
+            const threadPageModes = ['previous', 'next'];
+            for (const mode of threadPageModes) {
+              let modeOption = document.createElement('option');
+              modeOption.value = mode;
+              modeOption.textContent = chrome.i18n.getMessage(
+                  'options_interopthreadpage_mode_' + mode);
+              if (items.interopthreadpage_mode == mode)
+                modeOption.selected = true;
+              select.appendChild(modeOption);
+            }
+
+            document.getElementById('interopthreadpage_mode--container')
+                .appendChild(select);
+            break;
+
           default:
             console.warn('Unrecognized option: ' + opt);
             break;
diff --git a/src/options/optionsPage.json5 b/src/options/optionsPage.json5
index 3234770..9435ece 100644
--- a/src/options/optionsPage.json5
+++ b/src/options/optionsPage.json5
@@ -16,6 +16,9 @@
         {codename: 'perforumstats'},
         {codename: 'batchlock'},
         {codename: 'autorefreshlist'},
+        // #!if ['chromium', 'chromium_mv3'].includes(browser_target)
+        {codename: 'blockdrafts'},
+        // #!endif
       ],
     },
     {
@@ -31,6 +34,7 @@
       options: [
         {codename: 'fixedtoolbar'},
         {codename: 'redirect'},
+        {codename: 'loaddrafts', experimental: true},
         {codename: 'increasecontrast'},
         {codename: 'stickysidebarheaders'},
         {codename: 'ccforcehidedrawer'},
@@ -40,6 +44,7 @@
         {codename: 'enhancedannouncementsdot'},
         {codename: 'repositionexpandthread', experimental: true},
         {codename: 'imagemaxheight'},
+        {codename: 'interopthreadpage'},
         {codename: 'uispacing'},
       ],
     },