mirror of
https://github.com/stevenjoezhang/live2d-widget.git
synced 2024-11-22 04:34:20 +08:00
Use URL API
This commit is contained in:
parent
928588368c
commit
eb58e5f49e
@ -6,7 +6,7 @@
|
||||
function loadWidget(waifuPath, apiPath) {
|
||||
localStorage.removeItem("waifu-display");
|
||||
sessionStorage.removeItem("waifu-text");
|
||||
document.body.insertAdjacentHTML('beforeend', `<div id="waifu">
|
||||
document.body.insertAdjacentHTML("beforeend", `<div id="waifu">
|
||||
<div id="waifu-tips"></div>
|
||||
<canvas id="live2d" width="300" height="300"></canvas>
|
||||
<div id="waifu-tool">
|
||||
@ -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 = `欢迎阅读<span>「${document.title.split(" - ")[0]}」</span>`;
|
||||
else if (domain == "baidu") text = `Hello!来自 百度搜索 的朋友<br>你是搜索 <span>${referrer.search.split("&wd=")[1].split("&")[0]}</span> 找到的我吗?`;
|
||||
else if (domain == "so") text = `Hello!来自 360搜索 的朋友<br>你是搜索 <span>${referrer.search.split("&q=")[1].split("&")[0]}</span> 找到的我吗?`;
|
||||
@ -221,7 +220,7 @@ function loadWidget(waifuPath, apiPath) {
|
||||
|
||||
function initWidget(waifuPath = "/waifu-tips.json", apiPath = "") {
|
||||
if (screen.width <= 768) return;
|
||||
document.body.insertAdjacentHTML('beforeend', `<div id="waifu-toggle" style="margin-left: -100px;">
|
||||
document.body.insertAdjacentHTML("beforeend", `<div id="waifu-toggle" style="margin-left: -100px;">
|
||||
<span>看板娘</span>
|
||||
</div>`);
|
||||
$("#waifu-toggle").hover(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user