Deprecate forceMarkAsRead option

The workaround applied by this option is no longer necessary since the
issue being worked around has already been fixed in the Community
Console.

Bug: twpowertools:14
Change-Id: I20a28937cfb8ce8e186c1ddfed95f294473c4a40
diff --git a/docs/features.es.md b/docs/features.es.md
index 0772e2f..c7a9363 100644
--- a/docs/features.es.md
+++ b/docs/features.es.md
@@ -152,42 +152,6 @@
 
 Nótese que esto solo aplica a a la Consola de la Comunidad.
 
-### Marca hilos como vistos automáticamente (opción temporal)
-> **Opción:** _Cada vez que abras un hilo en la Consola de la Comunidad, enviar
-automáticamente una petición para marcarlo como leído. Esta es una opción
-temporal usada como <i>workaround</i> de
-[este bug](https://support.google.com/s/community/forum/51488989/thread/114559215)._
-
-*** promo
-**Nota:** Cuando este problema se arregle por parte de Google, una actualización
-a la extensión quitará esta opción y su funcionalidad.
-***
-
-En estos momentos hay un problema en la Consola de la Comunidad: cuando uno abre
-un hilo para leerlo, este no se marca automáticamente como leído. Esto está en
-proceso de ser arreglado por parte de Google, pero hasta que salga el arreglo,
-esta opción sirve como un _workaround_ (solución temporal).
-
-Cuando esta opción está activada, cada vez que abres un hilo en la Consola de la
-Comunidad ocurre lo siguiente:
-
-1. La extensión enviará una petición autenticada a la API para obtener el
-contenido del hilo siendo visualizado. Esto se usa para obtener el ID del último
-mensaje del hilo.
-
-2. La extensión enviará una petición autenticada a la API para cambiar el estado
-del hilo a leído. Para marcar el hilo como leído, la API necesita que se pase el
-ID del foro, el ID del hilo y el ID del último mensaje que se ha cargado, y este
-último valor se obtiene de la llamada anterior a la API.
-
-*** promo
-**Nota:** Debido a la naturaleza de la API, la primera petición también cargará
-varios detalles innecesarios como los contenidos de los primeros mensajes. Esto
-significa que la petición no es muy eficiente. Por esta razón, recomiendo
-desactivar esta opción una vez nos notifiquen que el problema ha sido arreglado
-por Google, para no poner una carga extra a los servidores de Google.
-***
-
 ## Punto indicador
 > **Opciones:** _Muestra si el autor del hilo ha participado en otros hilos_,
 _Muestra el número de preguntas y respuestas escritas por el autor del hilo
diff --git a/docs/features.md b/docs/features.md
index 35f9c93..a2b2b33 100644
--- a/docs/features.md
+++ b/docs/features.md
@@ -145,40 +145,6 @@
 
 Note that this only applies to the Community Console.
 
-### Automatically mark threads as read (temporary option)
-> **Option name:** _Each time you open a thread in the Community Console,
-automatically send a request to mark it as read. This is a temporary option used
-to work around
-[this bug](https://support.google.com/s/community/forum/51488989/thread/114559215)._
-
-*** promo
-**Note:** When this issue is fixed by Google, an update to the extension will
-remove this option and its underlying functionality.
-***
-
-Currently there's an issue in the Community Console: when opening threads, they
-are not being marked as read automatically. This is in the process of being
-fixed by Google, but until the fix is out, this option serves as a workaround.
-
-When this option is enabled, each time you open a thread in the Community
-Console, the following will happen:
-
-1. The extension will send an authenticated request to the API to get the
-contents of the thread being viewed. This is used to retrieve the ID of the last
-message.
-2. The extension will send an authenticated request to the API to change the
-read status of the thread. In order to mark a thread as read, the API requires
-the caller to pass the forum ID, thread ID, and the ID of the last message which
-has loaded, and this last value is retrieved from the previous call to the API.
-
-*** promo
-**Note:** Due to the nature of the API, the first request will also load many
-unnecessary details such as the contents of the first messages. This means that
-this call is not very efficient. For this reason, I recommend turning this
-feature off once we are notified that the issue has been fixed by Google, so we
-don't put extra load on Google servers.
-***
-
 ## Indicator dot
 > **Option names:** _Show whether the OP has participated in other threads_,
 _Show the number of questions and replies written by the OP within the last `n`
diff --git a/src/common/optionsPrototype.json5 b/src/common/optionsPrototype.json5
index 191d0e1..64d1745 100644
--- a/src/common/optionsPrototype.json5
+++ b/src/common/optionsPrototype.json5
@@ -80,10 +80,6 @@
     defaultValue: false,
     context: 'options',
   },
-  'forcemarkasread': {
-    defaultValue: false,
-    context: 'options',
-  },
 
   // Experiments:
   'threadlistavatars': {
@@ -118,4 +114,8 @@
     defaultValue: false,
     context: 'deprecated',
   },
+  'forcemarkasread': {
+    defaultValue: false,
+    context: 'deprecated',
+  },
 }
diff --git a/src/contentScripts/communityConsole/forceMarkAsRead.js b/src/contentScripts/communityConsole/forceMarkAsRead.js
deleted file mode 100644
index c573788..0000000
--- a/src/contentScripts/communityConsole/forceMarkAsRead.js
+++ /dev/null
@@ -1,81 +0,0 @@
-import {CCApi} from '../../common/api.js';
-import {getAuthUser} from '../../common/communityConsoleUtils.js';
-
-var authuser = getAuthUser();
-
-// Send a request to mark the current thread as read
-export function markCurrentThreadAsRead() {
-  console.debug(
-      '[forceMarkAsRead] %cTrying to mark a thread as read.',
-      'color: #1a73e8;');
-
-  var threadRegex =
-      /\/s\/community\/?.*\/forum\/([0-9]+)\/?.*\/thread\/([0-9]+)/;
-
-  var url = location.href;
-  var matches = url.match(threadRegex);
-  if (matches !== null && matches.length > 2) {
-    var forumId = matches[1];
-    var threadId = matches[2];
-
-    console.debug('[forceMarkAsRead] Thread details:', {forumId, threadId});
-
-    return CCApi(
-               'ViewThread', {
-                 1: forumId,
-                 2: threadId,
-                 // options
-                 3: {
-                   // pagination
-                   1: {
-                     2: 0,  // maxNum
-                   },
-                   3: false,   // withMessages
-                   5: false,   // withUserProfile
-                   6: true,    // withUserReadState
-                   9: false,   // withRequestorProfile
-                   10: false,  // withPromotedMessages
-                   11: false,  // withExpertResponder
-                 },
-               },
-               true, authuser)
-        .then(thread => {
-          if (thread?.[1]?.[6] === true) {
-            console.debug(
-                '[forceMarkAsRead] This thread is already marked as read, but marking it as read anyways.');
-          }
-
-          var lastMessageId = thread?.[1]?.[2]?.[10];
-
-          console.debug('[forceMarkAsRead] lastMessageId is:', lastMessageId);
-
-          if (lastMessageId === undefined)
-            throw new Error(
-                'Couldn\'t find lastMessageId in the ViewThread response.');
-
-          return CCApi(
-              'SetUserReadStateBulk', {
-                1: [{
-                  1: forumId,
-                  2: threadId,
-                  3: lastMessageId,
-                }],
-              },
-              true, authuser);
-        })
-        .then(_ => {
-          console.debug(
-              '[forceMarkAsRead] %cSuccessfully set as read!',
-              'color: #1e8e3e;');
-        })
-        .catch(err => {
-          console.error(
-              '[forceMarkAsRead] Error while marking current thread as read: ',
-              err);
-        });
-  } else {
-    console.error(
-        '[forceMarkAsRead] Couldn\'t retrieve forumId and threadId from the current URL.',
-        url);
-  }
-}
diff --git a/src/contentScripts/communityConsole/main.js b/src/contentScripts/communityConsole/main.js
index 69b3bb7..3924af6 100644
--- a/src/contentScripts/communityConsole/main.js
+++ b/src/contentScripts/communityConsole/main.js
@@ -5,7 +5,6 @@
 import {addBatchLockBtn, nodeIsReadToggleBtn} from './batchLock.js';
 import {injectDarkModeButton, isDarkThemeOn} from './darkMode.js';
 import {applyDragAndDropFix} from './dragAndDropFix.js';
-import {markCurrentThreadAsRead} from './forceMarkAsRead.js';
 import {injectPreviousPostsLinks} from './profileHistoryLink.js';
 import {unifiedProfilesFix} from './unifiedProfiles.js';
 
@@ -39,9 +38,6 @@
 
   // Unified profile iframe
   'iframe',
-
-  // Thread component
-  'ec-thread',
 ];
 
 function handleCandidateNode(node) {
@@ -131,11 +127,6 @@
         unifiedProfilesFix.checkIframe(node)) {
       unifiedProfilesFix.fixIframe(node);
     }
-
-    // Force mark thread as read
-    if (options.forcemarkasread && node.tagName == 'EC-THREAD') {
-      markCurrentThreadAsRead();
-    }
   }
 }
 
diff --git a/src/static/_locales/ca/messages.json b/src/static/_locales/ca/messages.json
index 967853a..aa91d18 100644
--- a/src/static/_locales/ca/messages.json
+++ b/src/static/_locales/ca/messages.json
@@ -107,10 +107,6 @@
     "message": "Desactiva a la força l'experiment <code class=\"help\" title=\"Aquest experiment, quan està actiu, introdueix un rediseny de la interfície dels perfils que també unifica tots els perfils en un únic.\">SMEI_UNIFIED_PROFILES</code> a la Consola de la Comunitat.",
     "description": "Link to learn more about the profile indicator feature"
   },
-  "options_forcemarkasread": {
-    "message": "Cada vegada que obris un fil a la Consola de la Comunitat, envia automàticament una petició per marcar-lo com a llegit. Aquesta és una opció temporal usada com a <i>workaround</i> d'<a href=\"https://support.google.com/s/community/forum/51488989/thread/114559215\" target=\"_blank\" rel=\"noreferrer noopener\">aquest bug</a>.",
-    "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/static/_locales/en/messages.json b/src/static/_locales/en/messages.json
index 16c0e0f..09881d9 100644
--- a/src/static/_locales/en/messages.json
+++ b/src/static/_locales/en/messages.json
@@ -111,10 +111,6 @@
     "message": "Force disable the <code class=\"help\" title=\"This experiment, when enabled, introduces a redesign of the profile view which also unifies all forum profiles into a single one.\">SMEI_UNIFIED_PROFILES</code> experiment in the Community Console.",
     "description": "Feature checkbox in the options page"
   },
-  "options_forcemarkasread": {
-    "message": "Each time you open a thread in the Community Console, automatically send a request to mark it as read. This is a temporary option used to work around <a href=\"https://support.google.com/s/community/forum/51488989/thread/114559215\" target=\"_blank\" rel=\"noreferrer noopener\">this bug</a>.",
-    "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/static/_locales/es/messages.json b/src/static/_locales/es/messages.json
index 1f70b4e..4bea06d 100644
--- a/src/static/_locales/es/messages.json
+++ b/src/static/_locales/es/messages.json
@@ -111,10 +111,6 @@
     "message": "Desactiva forzosamente el experimento <code class=\"help\" title=\"Este experimento, cuando está activado, introduce un rediseño de la interfaz de los perfiles que también unifica todos los perfiles en cada foro en uno único.\">SMEI_UNIFIED_PROFILES</code> en la Consola de la Comunidad.",
     "description": "Link to learn more about the profile indicator feature"
   },
-  "options_forcemarkasread": {
-    "message": "Cada vez que abras un hilo en la Consola de la Comunidad, enviar automáticamente una petición para marcarlo como leído. Esta es una opción temporal usada como <i>workaround</i> de <a href=\"https://support.google.com/s/community/forum/51488989/thread/114559215\" target=\"_blank\" rel=\"noreferrer noopener\">este bug</a>.",
-    "description": "Feature checkbox in the options page"
-  },
   "options_profileindicator_moreinfo": {
     "message": "+info sobre las 2 opciones anteriores",
     "description": "Link to learn more about the profile indicator feature"
diff --git a/src/static/options/options.html b/src/static/options/options.html
index 09ce1bb..d6be8d6 100644
--- a/src/static/options/options.html
+++ b/src/static/options/options.html
@@ -45,7 +45,6 @@
         <div class="option"><input type="checkbox" id="enhancedannouncementsdot"> <label for="enhancedannouncementsdot" data-i18n="enhancedannouncementsdot"></label></div>
         <div class="option"><input type="checkbox" id="repositionexpandthread"> <label for="repositionexpandthread" data-i18n="repositionexpandthread"></label> <span class="experimental-label" data-i18n="experimental_label"></span></div>
         <div class="option"><input type="checkbox" id="disableunifiedprofiles"> <label for="disableunifiedprofiles" data-i18n="disableunifiedprofiles"></label> <span class="experimental-label" data-i18n="experimental_label"></span></div>
-        <div class="option"><input type="checkbox" id="forcemarkasread"> <label for="forcemarkasread" data-i18n="forcemarkasread"></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>