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 1414 async >
1515 </script >
1616<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+ });
2332 });
2433 });
34+ giscusIframeObserver .observe (document .body , { childList: true , subtree: true });
2535 </script >
2636<input type =" hidden" id =" giscus-base-theme" value =" <%- giscus.baseTheme %>" >
2737<input type =" hidden" id =" giscus-alt-theme" value =" <%- giscus.altTheme %>" >
You can’t perform that action at this time.
0 commit comments