diff --git a/demo/demo2.html b/demo/demo2.html index c3358d3..9768fa4 100755 --- a/demo/demo2.html +++ b/demo/demo2.html @@ -161,7 +161,7 @@ window.addEventListener("load", () => { var apiPath = "https://live2d.fghrsh.net/api", state = 0, modelId = localStorage.getItem("modelId"), modelTexturesId = localStorage.getItem("modelTexturesId"); - if (modelId == null) { + if (modelId === null) { modelId = 1; modelTexturesId = 53; } @@ -223,24 +223,24 @@ window.addEventListener("load", () => { } document.getElementById("handle").addEventListener("click", () => { - if (state == 1) { + if (state === 1) { state = 2; coverPosition("80%"); } - else if (state == 2) { + else if (state === 2) { state = 1; coverPosition("20%"); } }); document.querySelector("input[type=password]").addEventListener("focus", () => { - if (state == 2) { + if (state === 2) { state = 1; coverPosition("20%"); } }); document.querySelector("input[type=password]").addEventListener("blur", () => { - if (state == 1) { + if (state === 1) { state = 2; coverPosition("80%"); } diff --git a/waifu-tips.js b/waifu-tips.js index 50825da..d2c3165 100755 --- a/waifu-tips.js +++ b/waifu-tips.js @@ -90,10 +90,10 @@ function loadWidget(config) { } else if (document.referrer !== "") { var referrer = new URL(document.referrer), domain = referrer.hostname.split(".")[1]; - if (location.hostname == referrer.hostname) text = `欢迎阅读「${document.title.split(" - ")[0]}」`; - else if (domain == "baidu") text = `Hello!来自 百度搜索 的朋友
你是搜索 ${referrer.search.split("&wd=")[1].split("&")[0]} 找到的我吗?`; - else if (domain == "so") text = `Hello!来自 360搜索 的朋友
你是搜索 ${referrer.search.split("&q=")[1].split("&")[0]} 找到的我吗?`; - else if (domain == "google") text = `Hello!来自 谷歌搜索 的朋友
欢迎阅读「${document.title.split(" - ")[0]}」`; + if (location.hostname === referrer.hostname) text = `欢迎阅读「${document.title.split(" - ")[0]}」`; + else if (domain === "baidu") text = `Hello!来自 百度搜索 的朋友
你是搜索 ${referrer.search.split("&wd=")[1].split("&")[0]} 找到的我吗?`; + else if (domain === "so") text = `Hello!来自 360搜索 的朋友
你是搜索 ${referrer.search.split("&q=")[1].split("&")[0]} 找到的我吗?`; + else if (domain === "google") text = `Hello!来自 谷歌搜索 的朋友
欢迎阅读「${document.title.split(" - ")[0]}」`; else text = `Hello!来自 ${referrer.hostname} 的朋友`; } else { text = `欢迎阅读「${document.title.split(" - ")[0]}」`; @@ -157,7 +157,7 @@ function loadWidget(config) { (function initModel() { var modelId = localStorage.getItem("modelId"), modelTexturesId = localStorage.getItem("modelTexturesId"); - if (modelId == null) { + if (modelId === null) { // 首次访问加载 指定模型 的 指定材质 var modelId = 1, // 模型 ID modelTexturesId = 53; // 材质 ID @@ -229,7 +229,7 @@ function loadWidget(config) { fetch(`${apiPath}rand_textures/?id=${modelId}-${modelTexturesId}`) .then(response => response.json()) .then(result => { - if (result.textures.id == 1 && (modelTexturesId == 1 || modelTexturesId == 0)) showMessage("我还没有其他衣服呢!", 4000, 10); + if (result.textures.id === 1 && (modelTexturesId === 1 || modelTexturesId === 0)) showMessage("我还没有其他衣服呢!", 4000, 10); else loadModel(modelId, result.textures.id, "我的新衣服好看嘛?"); }); }