Add per-forum stats to TW profiles

Fixed: twpowertools:102

Change-Id: Ie947c05346a5e430f08b3f3c4fbd13c2c8d744da
diff --git a/src/contentScripts/utilsCommon/protojs.js b/src/contentScripts/utilsCommon/protojs.js
new file mode 100644
index 0000000..026559b
--- /dev/null
+++ b/src/contentScripts/utilsCommon/protojs.js
@@ -0,0 +1,13 @@
+// Function which converts a protobuf array into an array which can be accessed
+// as if it was a protobuf object (with the same keys). If the input is not an
+// array it returns itself (since it is called recursively).
+export function correctArrayKeys(input) {
+  if (!Array.isArray(input)) return input;
+
+  let object = [];
+  for (let i = 0; i < input.length; ++i) {
+    if (input[i] === null) continue;
+    object[i + 1] = correctArrayKeys(input[i]);
+  }
+  return object;
+}