Fix per-forum activity in TW basic

Fixed: twpowertools:169
Change-Id: I77a25cb5a047cdf84b74de79ecba2ad3591ef33c
diff --git a/src/contentScripts/publicProfile.js b/src/contentScripts/publicProfile.js
index 693aa3f..6c3da8d 100644
--- a/src/contentScripts/publicProfile.js
+++ b/src/contentScripts/publicProfile.js
@@ -4,7 +4,7 @@
 import PerForumStatsSection from './communityConsole/utils/PerForumStatsSection.js';
 import {injectPreviousPostsLinksUnifiedProfile} from './utilsCommon/unifiedProfiles.js';
 
-const profileViewRegex = /var view ?= ?(.+\]);/;
+const profileViewRegex = /var view ?= ?'([^']+)';/;
 
 getOptions(['history', 'perforumstats']).then(options => {
   if (options?.history)
@@ -25,12 +25,22 @@
       for (let i = 0; i < scripts.length; ++i) {
         const matches = scripts[i].textContent.match(profileViewRegex);
         if (matches?.[1]) {
-          profileView = JSON.parse(matches[1]);
+          let rawJsonStringContents =
+              matches[1]
+                  .replace(
+                      /\\x([0-9a-f]{2})/ig,
+                      (_, pair) => {
+                        return String.fromCharCode(parseInt(pair, 16));
+                      })
+                  .replace(/\\'/g, `'`)
+                  .replace(/"/g, `\\"`);
+          let rawJsonString = `"${rawJsonStringContents}"`;
+          let rawJson = JSON.parse(rawJsonString);
+          profileView = JSON.parse(rawJson);
           break;
         }
       }
       const profileViewC = {'1': correctArrayKeys(profileView)};
-      console.log(profileViewC);
       if (!profileView) throw new Error('Could not find user view data.');
       new PerForumStatsSection(
           chart?.parentNode, profileViewC,