Skip to content

Commit fd29499

Browse files
Merge pull request 0xPolygon#2038 from 0xPolygon/platform/spamming-attack
Platform: Add logging to Giscus
2 parents 3bbd8aa + cae99ca commit fd29499

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

overrides/partials/comments.html

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ <h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
99
data-mapping="pathname"
1010
data-strict="1"
1111
data-reactions-enabled="1"
12-
data-emit-metadata="0"
12+
data-emit-metadata="1"
1313
data-input-position="bottom"
1414
data-theme="preferred_color_scheme"
1515
data-lang="en"
1616
crossorigin="anonymous"
1717
async>
18-
</script>
18+
</script>
1919

2020
<!-- Synchronize Giscus theme with palette -->
2121
<script>
@@ -51,5 +51,22 @@ <h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
5151
}
5252
})
5353
})
54+
</script>
55+
56+
<script>
57+
import { MessageEvent, IMetadataMessage } from "https://giscus.app/lib/types/giscus.js";
58+
59+
// handle message events
60+
function handleMessage(event: MessageEvent) {
61+
if (event.origin !== 'https://giscus.app') return;
62+
if (!(typeof event.data === 'object' && event.data.giscus)) return;
63+
64+
if ('discussion' in giscusData) {
65+
const metadataMessage: IMetadataMessage = giscusData;
66+
console.log(metadataMessage.discussion);
67+
console.log(metadataMessage.viewer);
68+
}
69+
}
5470
</script>
55-
{% endif %}
71+
72+
{% endif %}

0 commit comments

Comments
 (0)