Flatten threads: change additional info element detection method

This is done in preparation for the next CL.

Bug: twpowertools:156
Change-Id: I15a77355550463995b57046f8d6fc34da3a275d7
diff --git a/src/contentScripts/communityConsole/flattenThreads/flattenThreads.js b/src/contentScripts/communityConsole/flattenThreads/flattenThreads.js
index 6fc3eac..d99ddc6 100644
--- a/src/contentScripts/communityConsole/flattenThreads/flattenThreads.js
+++ b/src/contentScripts/communityConsole/flattenThreads/flattenThreads.js
@@ -1,45 +1,27 @@
-export const kAdditionalInfoPrefix = '__TWPT_FLATTENTHREADS_ADDITIONALINFO__';
-export const kAdditionalInfoRegex =
-    /^__TWPT_FLATTENTHREADS_ADDITIONALINFO__(.*)/;
+export const kAdditionalInfoClass = 'ck-indent-9996300035194';
 
 export const kReplyPayloadSelector =
     '.scTailwindThreadMessageMessagecardcontent:not(.scTailwindThreadMessageMessagecardpromoted) .scTailwindThreadPostcontentroot html-blob';
 export const kReplyActionButtonsSelector =
-    '.scTailwindThreadMessageMessagecardcontent:not(.scTailwindThreadMessageMessagecardpromoted) sc-tailwind-thread-message-message-actions';
+  '.scTailwindThreadMessageMessagecardcontent:not(.scTailwindThreadMessageMessagecardpromoted) sc-tailwind-thread-message-message-actions';
+export const kAdditionalInfoSelector = '.ck-indent-9996300035194';
 export const kMatchingSelectors = [
   kReplyPayloadSelector,
   kReplyActionButtonsSelector,
+  kAdditionalInfoSelector,
 ];
 
 export function getExtraInfoNodes(node) {
-  const confirmedNodes = [];
-  const possibleExtraInfoNodes =
-      node.querySelectorAll('span[style*=\'display\'][style*=\'none\']');
-  for (const candidate of possibleExtraInfoNodes) {
-    const content = candidate.textContent;
-    const matches = content.match(kAdditionalInfoRegex);
-    if (matches) confirmedNodes.push(candidate);
-  }
-  return confirmedNodes;
+  return node.querySelectorAll(kAdditionalInfoSelector);
 }
 
 export default class FlattenThreads {
   construct() {}
 
   getExtraInfo(node) {
-    let rawExtraInfo = null;
-    const possibleExtraInfoNodes =
-        node.querySelectorAll('span[style*=\'display\'][style*=\'none\']');
-    for (const candidate of possibleExtraInfoNodes) {
-      const content = candidate.textContent;
-      const matches = content.match(kAdditionalInfoRegex);
-      if (matches) {
-        rawExtraInfo = matches?.[1] ?? null;
-        break;
-      }
-    }
-    if (!rawExtraInfo) return null;
-    return JSON.parse(rawExtraInfo);
+    const extraInfoNode = node.querySelector(kAdditionalInfoSelector);
+    if (!extraInfoNode) return null;
+    return JSON.parse(extraInfoNode.textContent);
   }
 
   injectId(node, extraInfo) {
diff --git a/src/xhrInterceptor/responseModifiers/flattenThread.js b/src/xhrInterceptor/responseModifiers/flattenThread.js
index 53828eb..b515191 100644
--- a/src/xhrInterceptor/responseModifiers/flattenThread.js
+++ b/src/xhrInterceptor/responseModifiers/flattenThread.js
@@ -1,4 +1,4 @@
-import {kAdditionalInfoPrefix} from '../../contentScripts/communityConsole/flattenThreads/flattenThreads.js';
+import {kAdditionalInfoClass} from '../../contentScripts/communityConsole/flattenThreads/flattenThreads.js';
 import GapModel from '../../models/Gap.js';
 import MessageModel from '../../models/Message.js';
 
@@ -35,10 +35,11 @@
       prevReplyId = m.getId();
       prevReplyParentId = info.parentId;
 
-      const span = document.createElement('span');
-      span.textContent = kAdditionalInfoPrefix + JSON.stringify(info);
-      span.setAttribute('style', 'display: none');
-      m.newPayload = m.getPayload() + span.outerHTML;
+      const extraInfoEl = document.createElement('code');
+      extraInfoEl.textContent = JSON.stringify(info);
+      extraInfoEl.setAttribute('style', 'display: none');
+      extraInfoEl.classList.add(kAdditionalInfoClass);
+      m.newPayload = m.getPayload() + extraInfoEl.outerHTML;
     });
     mogs.forEach(m => m.setPayload(m.newPayload));