diff --git a/README.md b/README.md index 578f909..fd13792 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Add Live2D widget to web page. Compatible with PJAX. jQuery and font-awesome is required for this plugin. You can add this to ``: ```xml - + ``` 否则无法正常显示。(如果你的网页已经加载了jQuery,就不要重复加载了) diff --git a/waifu-tips.js b/waifu-tips.js index 9cd13e9..760ac15 100755 --- a/waifu-tips.js +++ b/waifu-tips.js @@ -72,27 +72,24 @@ function loadWidget(waifuPath, apiPath) { var SiteIndexUrl = location.port ? `${location.protocol}//${location.hostname}:${location.port}/` : `${location.protocol}//${location.hostname}/`, text; //自动获取主页 if (location.href == SiteIndexUrl) { //如果是主页 var now = new Date().getHours(); - if (now > 23 || now <= 5) text = "你是夜猫子呀?这么晚还不睡觉,明天起的来嘛?"; - else if (now > 5 && now <= 7) text = "早上好!一日之计在于晨,美好的一天就要开始了。"; + if (now > 5 && now <= 7) text = "早上好!一日之计在于晨,美好的一天就要开始了。"; else if (now > 7 && now <= 11) text = "上午好!工作顺利嘛,不要久坐,多起来走动走动哦!"; else if (now > 11 && now <= 14) text = "中午了,工作了一个上午,现在是午餐时间!"; else if (now > 14 && now <= 17) text = "午后很容易犯困呢,今天的运动目标完成了吗?"; else if (now > 17 && now <= 19) text = "傍晚了!窗外夕阳的景色很美丽呢,最美不过夕阳红~"; else if (now > 19 && now <= 21) text = "晚上好,今天过得怎么样?"; else if (now > 21 && now <= 23) text = ["已经这么晚了呀,早点休息吧,晚安~", "深夜时要爱护眼睛呀!"]; - else text = "好久不见,日子过得好快呢……"; - } - else if (document.referrer !== "") { + else text = "你是夜猫子呀?这么晚还不睡觉,明天起的来嘛?"; + } else if (document.referrer !== "") { var referrer = document.createElement("a"); referrer.href = document.referrer; var 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]}』`; + 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 { + } else { text = `欢迎阅读『${document.title.split(" - ")[0]}』`; } showMessage(text, 7000, 8); @@ -102,7 +99,7 @@ function loadWidget(waifuPath, apiPath) { var userAction = false, hitokotoTimer = null, messageTimer = null, - messageArray = ["已经过了这么久了呀……", "大坏蛋!你都多久没碰人家了呀,嘤嘤嘤~", "嗨~快来逗我玩吧!", "拿小拳拳锤你胸口!"]; + messageArray = ["好久不见,日子过得好快呢……", "大坏蛋!你都多久没碰人家了呀,嘤嘤嘤~", "嗨~快来逗我玩吧!", "拿小拳拳锤你胸口!"]; if ($(".fa-share-alt").is(":hidden")) messageArray.push("记得把小家加入Adblock白名单哦!"); $(document).mousemove(() => { userAction = true; @@ -112,8 +109,7 @@ function loadWidget(waifuPath, apiPath) { setInterval(() => { if (!userAction) { if (!hitokotoTimer) hitokotoTimer = setInterval(showHitokoto, 25000); - } - else { + } else { userAction = false; clearInterval(hitokotoTimer); hitokotoTimer = null; @@ -241,16 +237,14 @@ function initWidget(waifuPath = "/waifu-tips.json", apiPath = "") { if ($("#waifu-toggle").attr("first-time")) { loadWidget(waifuPath, apiPath); $("#waifu-toggle").attr("first-time", false); - } - else { + } else { localStorage.removeItem("waifu-display"); $("#waifu").show().animate({ bottom: 0 }, 3000); } }); if (localStorage.getItem("waifu-display") && new Date().getTime() - localStorage.getItem("waifu-display") <= 86400000) { $("#waifu-toggle").attr("first-time", true).css({ "margin-left": -50 }); - } - else { + } else { loadWidget(waifuPath, apiPath); } }