Steven Yan před 3 roky
rodič
revize
92898fe751
2 změnil soubory, kde provedl 25 přidání a 1 odebrání
  1. 20 1
      index.js
  2. 5 0
      index.json

+ 20 - 1
index.js

@@ -15,7 +15,26 @@ document.addEventListener("visibilitychange", function () {
   }
 });
 
-var loadICP = function () {};
+var loadICP = function () {
+  var url = new URL(document.location.href);
+  if (/www.stevenapis.xyz/gi.test(url.hostname)) {
+    var a = document.createElement("a");
+    var req = new XMLHttpRequest();
+    req.open("GET", "https://www.stevenapis.xyz/index.json");
+    req.setRequestHeader("Content-type", "application/json");
+    req.send();
+    req.onreadystatechange = function () {
+      if (req.readyState === 4 && req.status === 200) {
+        var j = JSON.parse(req.responseText);
+        a.innerHTML = j.text;
+        a.href = j.href;
+        a.target = "_blank";
+        document.getElementsByClassName("footer")[0].appendChild(a);
+        document.getElementsByTagName("title")[0].innerText = j.title;
+      }
+    };
+  }
+};
 
 var startTimer = function () {
   var today = new Date();

+ 5 - 0
index.json

@@ -0,0 +1,5 @@
+{
+    "title": "我的数码文章",
+    "text": "蜀ICP备2022008836号-1",
+    "href": "https://beian.miit.gov.cn"
+}