diff --git a/waifu-tips.js b/waifu-tips.js index 5f2a9a7..30704f9 100755 --- a/waifu-tips.js +++ b/waifu-tips.js @@ -6,7 +6,7 @@ function loadWidget(waifuPath, apiPath) { localStorage.removeItem("waifu-display"); sessionStorage.removeItem("waifu-text"); - document.body.insertAdjacentHTML('beforeend', `
+ document.body.insertAdjacentHTML("beforeend", `
@@ -28,7 +28,7 @@ function loadWidget(waifuPath, apiPath) { if (!window.ASTEROIDSPLAYERS) window.ASTEROIDSPLAYERS = []; window.ASTEROIDSPLAYERS.push(new Asteroids()); } else { - var script = document.createElement('script'); + var script = document.createElement("script"); script.src = "https://cdn.jsdelivr.net/gh/GalaxyMimi/CDN/asteroids.js"; document.head.appendChild(script); } @@ -72,16 +72,15 @@ function loadWidget(waifuPath, apiPath) { var now = new Date().getHours(); 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 > 11 && now <= 13) text = "中午了,工作了一个上午,现在是午餐时间!"; + else if (now > 13 && 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 !== "") { - var referrer = document.createElement("a"); - referrer.href = document.referrer; - var domain = referrer.hostname.split(".")[1]; + 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]} 找到的我吗?`; @@ -221,7 +220,7 @@ function loadWidget(waifuPath, apiPath) { function initWidget(waifuPath = "/waifu-tips.json", apiPath = "") { if (screen.width <= 768) return; - document.body.insertAdjacentHTML('beforeend', `
+ document.body.insertAdjacentHTML("beforeend", `
看板娘
`); $("#waifu-toggle").hover(() => {