mirror of
https://github.com/caojiezi2003/live2d-widget.git
synced 2024-11-10 04:49:47 +00:00
Code style update
This commit is contained in:
parent
27005921cf
commit
54021a7265
108
waifu-tips.js
108
waifu-tips.js
@ -1,10 +1,32 @@
|
|||||||
|
console.log(`
|
||||||
|
く__,.ヘヽ. / ,ー、 〉
|
||||||
|
\ ', !-─‐-i / /´
|
||||||
|
/`ー' L//`ヽ、
|
||||||
|
/ /, /| , , ',
|
||||||
|
イ / /-‐/ i L_ ハ ヽ! i
|
||||||
|
レ ヘ 7イ`ト レ'ァ-ト、!ハ| |
|
||||||
|
!,/7 '0' ´0iソ| |
|
||||||
|
|.从" _ ,,,, / |./ |
|
||||||
|
レ'| i>.、,,__ _,.イ / .i |
|
||||||
|
レ'| | / k_7_/レ'ヽ, ハ. |
|
||||||
|
| |/i 〈|/ i ,.ヘ | i |
|
||||||
|
.|/ / i: ヘ! \ |
|
||||||
|
kヽ>、ハ _,.ヘ、 /、!
|
||||||
|
!'〈//`T´', \ `'7'ーr'
|
||||||
|
レ'ヽL__|___i,___,ンレ|ノ
|
||||||
|
ト-,/ |___./
|
||||||
|
'ー' !_,.:
|
||||||
|
`);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* https://imjad.cn/archives/lab/add-dynamic-poster-girl-with-live2d-to-your-blog-02
|
* https://imjad.cn/archives/lab/add-dynamic-poster-girl-with-live2d-to-your-blog-02
|
||||||
* https://www.fghrsh.net/post/123.html
|
* https://www.fghrsh.net/post/123.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function initWidget(waifuPath, apiPath) {
|
function initWidget(waifuPath, apiPath) {
|
||||||
if (screen.width <= 768 || (localStorage.getItem("waifu-display") && new Date().getTime() - localStorage.getItem("waifu-display") <= 86400000)) return;
|
if (screen.width <= 768 || (localStorage.getItem("waifu-display") && new Date().getTime() - localStorage.getItem("waifu-display") <= 86400000)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
localStorage.removeItem("waifu-display");
|
localStorage.removeItem("waifu-display");
|
||||||
sessionStorage.removeItem("waifu-text");
|
sessionStorage.removeItem("waifu-text");
|
||||||
$("body").append(`<div id="waifu">
|
$("body").append(`<div id="waifu">
|
||||||
@ -20,42 +42,47 @@ function initWidget(waifuPath, apiPath) {
|
|||||||
<span class="fa fa-lg fa-times"></span>
|
<span class="fa fa-lg fa-times"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>`);
|
</div>`);
|
||||||
$("#waifu-tool .fa-comment").click(showHitokoto);
|
|
||||||
$("#waifu-tool .fa-paper-plane").click(function() {
|
function registerEventListener() {
|
||||||
var s = document.createElement("script");
|
$("#waifu-tool .fa-comment").click(showHitokoto);
|
||||||
document.body.appendChild(s);
|
$("#waifu-tool .fa-paper-plane").click(function() {
|
||||||
s.src = "https://galaxymimi.com/js/asteroids.js";
|
var s = document.createElement("script");
|
||||||
});
|
document.body.appendChild(s);
|
||||||
$("#waifu-tool .fa-user-circle").click(loadOtherModel);
|
s.src = "https://galaxymimi.com/js/asteroids.js";
|
||||||
$("#waifu-tool .fa-street-view").click(loadRandModel);
|
|
||||||
$("#waifu-tool .fa-camera-retro").click(function() {
|
|
||||||
showMessage("照好了嘛,是不是很可爱呢?", 6000, 9);
|
|
||||||
window.Live2D.captureName = "photo.png";
|
|
||||||
window.Live2D.captureFrame = true;
|
|
||||||
});
|
|
||||||
$("#waifu-tool .fa-info-circle").click(function() {
|
|
||||||
window.open("https://github.com/stevenjoezhang/live2d-widget");
|
|
||||||
});
|
|
||||||
$("#waifu-tool .fa-times").click(function() {
|
|
||||||
localStorage.setItem("waifu-display", new Date().getTime());
|
|
||||||
showMessage("愿你有一天能与重要的人重逢。", 2000, 11);
|
|
||||||
$("#waifu").animate({ bottom: -500 }, 3000, function() {
|
|
||||||
$("#waifu").hide();
|
|
||||||
});
|
});
|
||||||
});
|
$("#waifu-tool .fa-user-circle").click(loadOtherModel);
|
||||||
var re = /x/;
|
$("#waifu-tool .fa-street-view").click(loadRandModel);
|
||||||
console.log(re);
|
$("#waifu-tool .fa-camera-retro").click(function() {
|
||||||
re.toString = function() {
|
showMessage("照好了嘛,是不是很可爱呢?", 6000, 9);
|
||||||
showMessage("哈哈,你打开了控制台,是想要看看我的秘密吗?", 6000, 9);
|
window.Live2D.captureName = "photo.png";
|
||||||
return "";
|
window.Live2D.captureFrame = true;
|
||||||
};
|
});
|
||||||
$(document).on("copy", function() {
|
$("#waifu-tool .fa-info-circle").click(function() {
|
||||||
showMessage("你都复制了些什么呀,转载要记得加上出处哦!", 6000, 9);
|
window.open("https://github.com/stevenjoezhang/live2d-widget");
|
||||||
});
|
});
|
||||||
$(document).on("visibilitychange", function() {
|
$("#waifu-tool .fa-times").click(function() {
|
||||||
if (!document.hidden) showMessage("哇,你终于回来了~", 6000, 9);
|
localStorage.setItem("waifu-display", new Date().getTime());
|
||||||
});
|
showMessage("愿你有一天能与重要的人重逢。", 2000, 11);
|
||||||
(function() {
|
$("#waifu").animate({ bottom: -500 }, 3000, function() {
|
||||||
|
$("#waifu").hide();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
var re = /x/;
|
||||||
|
console.log(re);
|
||||||
|
re.toString = function() {
|
||||||
|
showMessage("哈哈,你打开了控制台,是想要看看我的秘密吗?", 6000, 9);
|
||||||
|
return "";
|
||||||
|
};
|
||||||
|
$(document).on("copy", function() {
|
||||||
|
showMessage("你都复制了些什么呀,转载要记得加上出处哦!", 6000, 9);
|
||||||
|
});
|
||||||
|
$(document).on("visibilitychange", function() {
|
||||||
|
if (!document.hidden) showMessage("哇,你终于回来了~", 6000, 9);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
registerEventListener();
|
||||||
|
|
||||||
|
function welcomeMessage() {
|
||||||
var SiteIndexUrl = location.port ? `${location.protocol}//${location.hostname}:${location.port}/` : `${location.protocol}//${location.hostname}/`, text; //自动获取主页
|
var SiteIndexUrl = location.port ? `${location.protocol}//${location.hostname}:${location.port}/` : `${location.protocol}//${location.hostname}/`, text; //自动获取主页
|
||||||
if (location.href == SiteIndexUrl) { //如果是主页
|
if (location.href == SiteIndexUrl) { //如果是主页
|
||||||
var now = new Date().getHours();
|
var now = new Date().getHours();
|
||||||
@ -79,9 +106,12 @@ function initWidget(waifuPath, apiPath) {
|
|||||||
else if (domain == 'google') text = 'Hello!来自 谷歌搜索 的朋友<br/>欢迎阅读<span style="color:#0099cc;">『' + document.title.split(' - ')[0] + '』</span>';
|
else if (domain == 'google') text = 'Hello!来自 谷歌搜索 的朋友<br/>欢迎阅读<span style="color:#0099cc;">『' + document.title.split(' - ')[0] + '』</span>';
|
||||||
else text = 'Hello!来自 <span style="color:#0099cc;">' + referrer.hostname + '</span> 的朋友';
|
else text = 'Hello!来自 <span style="color:#0099cc;">' + referrer.hostname + '</span> 的朋友';
|
||||||
}
|
}
|
||||||
else text = '欢迎阅读<span style="color:#0099cc;">『' + document.title.split(' - ')[0] + '』</span>';
|
else {
|
||||||
|
text = `欢迎阅读<span style="color:#0099cc;">『${document.title.split(' - ')[0]}』</span>`;
|
||||||
|
}
|
||||||
showMessage(text, 7000, 8);
|
showMessage(text, 7000, 8);
|
||||||
})();
|
}
|
||||||
|
welcomeMessage();
|
||||||
//检测用户活动状态,并在空闲时定时显示一言
|
//检测用户活动状态,并在空闲时定时显示一言
|
||||||
var userAction = false,
|
var userAction = false,
|
||||||
hitokotoTimer = null,
|
hitokotoTimer = null,
|
||||||
@ -118,7 +148,6 @@ function initWidget(waifuPath, apiPath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function showMessage(text, timeout, priority) {
|
function showMessage(text, timeout, priority) {
|
||||||
//console.log(text, timeout, priority);
|
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
if (!sessionStorage.getItem("waifu-text") || sessionStorage.getItem("waifu-text") <= priority) {
|
if (!sessionStorage.getItem("waifu-text") || sessionStorage.getItem("waifu-text") <= priority) {
|
||||||
if (messageTimer) {
|
if (messageTimer) {
|
||||||
@ -126,7 +155,6 @@ function initWidget(waifuPath, apiPath) {
|
|||||||
messageTimer = null;
|
messageTimer = null;
|
||||||
}
|
}
|
||||||
if (Array.isArray(text)) text = text[Math.floor(Math.random() * text.length)];
|
if (Array.isArray(text)) text = text[Math.floor(Math.random() * text.length)];
|
||||||
//console.log(text);
|
|
||||||
sessionStorage.setItem("waifu-text", priority);
|
sessionStorage.setItem("waifu-text", priority);
|
||||||
$("#waifu-tips").stop().html(text).fadeTo(200, 1);
|
$("#waifu-tips").stop().html(text).fadeTo(200, 1);
|
||||||
messageTimer = setTimeout(function() {
|
messageTimer = setTimeout(function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user