File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
src/resources/formats/html/giscus Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change 14
14
async >
15
15
</script >
16
16
<script type =" application/javascript" >
17
- window .document .addEventListener (" DOMContentLoaded" , function (event ) {
18
- var giscusIframe = window .document .querySelector (' iframe.giscus-frame' );
19
- giscusIframe .addEventListener (" load" , function () {
20
- window .setTimeout (() => {
21
- window .toggleGiscusIfUsed (window .hasAlternateSentinel (), authorPrefersDark);
22
- }, 100 );
17
+ const giscusIframeObserver = new MutationObserver (function (mutations ) {
18
+ mutations .forEach (function (mutation ) {
19
+ mutation .addedNodes .forEach (function (addedNode ) {
20
+ if (addedNode .matches && addedNode .matches (' div.giscus' )) {
21
+ const giscusIframe = addedNode .querySelector (' iframe.giscus-frame' );
22
+ if (giscusIframe) {
23
+ giscusIframe .addEventListener (" load" , function () {
24
+ window .setTimeout (() => {
25
+ window .toggleGiscusIfUsed (window .hasAlternateSentinel (), authorPrefersDark);
26
+ }, 100 );
27
+ });
28
+ giscusIframeObserver .disconnect ();
29
+ }
30
+ }
31
+ });
23
32
});
24
33
});
34
+ giscusIframeObserver .observe (document .body , { childList: true , subtree: true });
25
35
</script >
26
36
<input type =" hidden" id =" giscus-base-theme" value =" <%- giscus.baseTheme %>" >
27
37
<input type =" hidden" id =" giscus-alt-theme" value =" <%- giscus.altTheme %>" >
You can’t perform that action at this time.
0 commit comments