blob: c9c6e2c4b7b7d4c7947a4d9f7dc09c4e5ca486e2 [file] [log] [blame]
Adrià Vilanova Martínez4f56d562022-01-26 00:23:27 +01001import PerForumStatsSection from '../contentScripts/communityConsole/utils/PerForumStatsSection.js';
2
3window.addEventListener('message', e => {
4 if (e.source === window && e.data?.prefix === 'TWPT-extrainfo') {
5 switch (e.data?.action) {
6 case 'injectPerForumStatsSection':
7 let existingChartSection =
8 document
9 .querySelector(
10 'sc-tailwind-user_profile-user-profile sc-tailwind-shared-activity-chart')
11 ?.parentNode;
12 if (!existingChartSection) {
13 console.error('extraInfo: couldn\'t find existing chart section.');
14 return;
15 }
16 new PerForumStatsSection(
17 existingChartSection, e.data?.profile, e.data?.locale);
18 break;
19
20 default:
21 console.error(
22 'Action \'' + e.data?.action +
23 '\' unknown to TWPT-extrainfo receiver.');
24 }
25 }
26});