Skip to content

Commit 215b74a

Browse files
Code style update
1 parent 1471992 commit 215b74a

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Add Live2D widget to web page. Compatible with PJAX.
2424
jQuery and font-awesome is required for this plugin. You can add this to `<head>`:
2525
```xml
2626
<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
27-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome/css/font-awesome.min.css"/>
27+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome/css/font-awesome.min.css">
2828
```
2929
否则无法正常显示。(如果你的网页已经加载了jQuery,就不要重复加载了)
3030

waifu-tips.js

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,24 @@ function loadWidget(waifuPath, apiPath) {
7272
var SiteIndexUrl = location.port ? `${location.protocol}//${location.hostname}:${location.port}/` : `${location.protocol}//${location.hostname}/`, text; //自动获取主页
7373
if (location.href == SiteIndexUrl) { //如果是主页
7474
var now = new Date().getHours();
75-
if (now > 23 || now <= 5) text = "你是夜猫子呀?这么晚还不睡觉,明天起的来嘛?";
76-
else if (now > 5 && now <= 7) text = "早上好!一日之计在于晨,美好的一天就要开始了。";
75+
if (now > 5 && now <= 7) text = "早上好!一日之计在于晨,美好的一天就要开始了。";
7776
else if (now > 7 && now <= 11) text = "上午好!工作顺利嘛,不要久坐,多起来走动走动哦!";
7877
else if (now > 11 && now <= 14) text = "中午了,工作了一个上午,现在是午餐时间!";
7978
else if (now > 14 && now <= 17) text = "午后很容易犯困呢,今天的运动目标完成了吗?";
8079
else if (now > 17 && now <= 19) text = "傍晚了!窗外夕阳的景色很美丽呢,最美不过夕阳红~";
8180
else if (now > 19 && now <= 21) text = "晚上好,今天过得怎么样?";
8281
else if (now > 21 && now <= 23) text = ["已经这么晚了呀,早点休息吧,晚安~", "深夜时要爱护眼睛呀!"];
83-
else text = "好久不见,日子过得好快呢……";
84-
}
85-
else if (document.referrer !== "") {
82+
else text = "你是夜猫子呀?这么晚还不睡觉,明天起的来嘛?";
83+
} else if (document.referrer !== "") {
8684
var referrer = document.createElement("a");
8785
referrer.href = document.referrer;
8886
var domain = referrer.hostname.split(".")[1];
8987
if (location.hostname == referrer.hostname) text = `欢迎阅读<span style="color:#0099cc;">『${document.title.split(" - ")[0]}』</span>`;
90-
else if (domain == "baidu") text = `Hello!来自 百度搜索 的朋友<br/>你是搜索 <span style="color:#0099cc;">${referrer.search.split("&wd=")[1].split("&")[0]}</span> 找到的我吗?`;
91-
else if (domain == "so") text = `Hello!来自 360搜索 的朋友<br/>你是搜索 <span style="color:#0099cc;">${referrer.search.split("&q=")[1].split("&")[0]}</span> 找到的我吗?`;
92-
else if (domain == "google") text = `Hello!来自 谷歌搜索 的朋友<br/>欢迎阅读<span style="color:#0099cc;">『${document.title.split(" - ")[0]}』</span>`;
88+
else if (domain == "baidu") text = `Hello!来自 百度搜索 的朋友<br>你是搜索 <span style="color:#0099cc;">${referrer.search.split("&wd=")[1].split("&")[0]}</span> 找到的我吗?`;
89+
else if (domain == "so") text = `Hello!来自 360搜索 的朋友<br>你是搜索 <span style="color:#0099cc;">${referrer.search.split("&q=")[1].split("&")[0]}</span> 找到的我吗?`;
90+
else if (domain == "google") text = `Hello!来自 谷歌搜索 的朋友<br>欢迎阅读<span style="color:#0099cc;">『${document.title.split(" - ")[0]}』</span>`;
9391
else text = `Hello!来自 <span style="color:#0099cc;">${referrer.hostname}</span> 的朋友`;
94-
}
95-
else {
92+
} else {
9693
text = `欢迎阅读<span style="color:#0099cc;">『${document.title.split(" - ")[0]}』</span>`;
9794
}
9895
showMessage(text, 7000, 8);
@@ -102,7 +99,7 @@ function loadWidget(waifuPath, apiPath) {
10299
var userAction = false,
103100
hitokotoTimer = null,
104101
messageTimer = null,
105-
messageArray = ["已经过了这么久了呀……", "大坏蛋!你都多久没碰人家了呀,嘤嘤嘤~", "嗨~快来逗我玩吧!", "拿小拳拳锤你胸口!"];
102+
messageArray = ["好久不见,日子过得好快呢……", "大坏蛋!你都多久没碰人家了呀,嘤嘤嘤~", "嗨~快来逗我玩吧!", "拿小拳拳锤你胸口!"];
106103
if ($(".fa-share-alt").is(":hidden")) messageArray.push("记得把小家加入Adblock白名单哦!");
107104
$(document).mousemove(() => {
108105
userAction = true;
@@ -112,8 +109,7 @@ function loadWidget(waifuPath, apiPath) {
112109
setInterval(() => {
113110
if (!userAction) {
114111
if (!hitokotoTimer) hitokotoTimer = setInterval(showHitokoto, 25000);
115-
}
116-
else {
112+
} else {
117113
userAction = false;
118114
clearInterval(hitokotoTimer);
119115
hitokotoTimer = null;
@@ -241,16 +237,14 @@ function initWidget(waifuPath = "/waifu-tips.json", apiPath = "") {
241237
if ($("#waifu-toggle").attr("first-time")) {
242238
loadWidget(waifuPath, apiPath);
243239
$("#waifu-toggle").attr("first-time", false);
244-
}
245-
else {
240+
} else {
246241
localStorage.removeItem("waifu-display");
247242
$("#waifu").show().animate({ bottom: 0 }, 3000);
248243
}
249244
});
250245
if (localStorage.getItem("waifu-display") && new Date().getTime() - localStorage.getItem("waifu-display") <= 86400000) {
251246
$("#waifu-toggle").attr("first-time", true).css({ "margin-left": -50 });
252-
}
253-
else {
247+
} else {
254248
loadWidget(waifuPath, apiPath);
255249
}
256250
}

0 commit comments

Comments
 (0)