From 149c7dae4bc558c0bd758e6cf7b26b263e442573 Mon Sep 17 00:00:00 2001 From: PJ568 Date: Wed, 10 Apr 2024 09:52:28 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BC=98=E5=8C=96]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/giscus.js | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/js/giscus.js b/js/giscus.js index e3096205..f5a1ce00 100644 --- a/js/giscus.js +++ b/js/giscus.js @@ -29,27 +29,30 @@ switch (lang) { } var giscus = function () { - const script = document.createElement("script"); - script.type = "text/javascript"; - script.src = "https://giscus.app/client.js"; + if (document.getElementById("giscus-container") != null) { + const script = document.createElement("script"); + script.type = "text/javascript"; + script.src = "https://giscus.app/client.js"; - script.setAttribute("data-repo", "PJ-568/568tools"); - script.setAttribute("data-repo-id", "R_kgDOJer3gw"); - script.setAttribute("data-category", "Announcements"); - script.setAttribute("data-category-id", "DIC_kwDOJer3g84CXG0D"); + script.setAttribute("data-repo", "PJ-568/568tools"); + script.setAttribute("data-repo-id", "R_kgDOJer3gw"); + script.setAttribute("data-category", "Announcements"); + script.setAttribute("data-category-id", "DIC_kwDOJer3g84CXG0D"); - script.setAttribute("data-mapping", "title"); - script.setAttribute("data-strict", "1"); - script.setAttribute("data-reactions-enabled", "1"); - script.setAttribute("data-emit-metadata", "0"); - script.setAttribute("data-input-position", "top"); - script.setAttribute("data-theme", "https://tools.pj568.eu.org/css/568_comment.css"); - script.setAttribute("data-lang", giscus_lang); + script.setAttribute("data-mapping", "title"); + script.setAttribute("data-strict", "1"); + script.setAttribute("data-reactions-enabled", "1"); + script.setAttribute("data-emit-metadata", "0"); + script.setAttribute("data-input-position", "top"); + script.setAttribute("data-theme", "https://tools.pj568.eu.org/css/568_comment.css"); + script.setAttribute("data-lang", giscus_lang); - script.crossOrigin = "anonymous"; - script.async = true; - document.getElementById("giscus-container").appendChild(script); + script.crossOrigin = "anonymous"; + script.async = true; + + document.getElementById("giscus-container").appendChild(script); + } }; window.addEventListener('load', giscus); \ No newline at end of file