Adrià Vilanova MartÃnez | 4f56d56 | 2022-01-26 00:23:27 +0100 | [diff] [blame] | 1 | import PerForumStatsSection from '../contentScripts/communityConsole/utils/PerForumStatsSection.js'; |
| 2 | |
| 3 | window.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 | }); |