q78kgblog 1.0.4 → 2.0.0-1711191136897
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/404.html +10 -10
- package/BingSiteAuth.xml +3 -3
- package/about/index.html +14 -14
- package/archives/2022/06/index.html +11 -11
- package/archives/2022/index.html +11 -11
- package/archives/2023/02/index.html +11 -11
- package/archives/2023/04/index.html +11 -11
- package/archives/2023/05/index.html +11 -11
- package/archives/2023/08/index.html +11 -11
- package/archives/2023/09/index.html +11 -11
- package/archives/2023/index.html +11 -11
- package/archives/2024/01/index.html +11 -11
- package/archives/2024/02/index.html +11 -11
- package/archives/2024/index.html +11 -11
- package/archives/index.html +11 -11
- package/atom.xml +41 -41
- package/baidusitemap.xml +18 -18
- package/bangumis/index.html +16 -16
- package/bigpie/index.html +12 -12
- package/categories/Hello-World/index.html +11 -11
- package/categories/Hexo/index.html +11 -11
- package/categories/index.html +12 -12
- package/categories//345/271/264/347/273/210/346/200/273/347/273/223/index.html +11 -11
- package/categories//346/201/260/351/245/255/index.html +11 -11
- package/categories//347/264/240/346/235/220/index.html +11 -11
- package/categories//351/227/262/350/201/212/346/235/202/350/260/210/index.html +11 -11
- package/content.json +1 -1
- package/css/ariasakablog.css +1 -1
- package/css/iconfont.css +4 -4
- package/essay/index.html +10 -10
- package/fcircle/index.html +12 -12
- package/fontawesome/index.html +12 -12
- package/index.html +21 -21
- package/links/index.html +47 -20
- package/live2d-widget/LICENSE +674 -674
- package/live2d-widget/README.md +188 -188
- package/live2d-widget/autoload.js +63 -63
- package/live2d-widget/demo/demo.html +34 -34
- package/live2d-widget/demo/login.html +271 -271
- package/live2d-widget/live2d.min.js +1 -1
- package/live2d-widget/package.json +31 -31
- package/live2d-widget/rollup.config.js +38 -38
- package/live2d-widget/src/index.js +178 -178
- package/live2d-widget/src/message.js +22 -22
- package/live2d-widget/src/model.js +75 -75
- package/live2d-widget/src/tools.js +78 -78
- package/live2d-widget/src/utils.js +5 -5
- package/live2d-widget/src/waifu-tips.js +3 -3
- package/live2d-widget/waifu-tips.js +5 -5
- package/live2d-widget/waifu-tips.json +255 -255
- package/live2d-widget/waifu.css +310 -310
- package/noie.html +68 -68
- package/othersite/index.html +11 -11
- package/package.json +1 -1
- package/people.html +23 -23
- package/posts/164ef646/index.html +14 -14
- package/posts/228c2ef8/index.html +15 -15
- package/posts/4a17b156/index.html +14 -14
- package/posts/6f3c565b/index.html +14 -14
- package/posts/7da7c3f6/index.html +14 -14
- package/posts/a9a6c1fb/index.html +14 -14
- package/posts/c262e439/index.html +14 -14
- package/posts/c81531cf/index.html +14 -14
- package/posts/da2093a1/index.html +14 -14
- package/posts/e54f7476/index.html +14 -14
- package/projects.html +423 -423
- package/random.html +15 -17
- package/robots.txt +17 -17
- package/search.xml +10 -10
- package/sitemap.txt +15 -17
- package/sitemap.xml +79 -97
- package/sw.js +1 -1
- package/tags/AI/index.html +12 -12
- package/tags/Butterfly/index.html +12 -12
- package/tags/Cloudflare/index.html +12 -12
- package/tags/DiffSinger/index.html +12 -12
- package/tags/Hexo/index.html +12 -12
- package/tags/Next/index.html +12 -12
- package/tags/RAID/index.html +12 -12
- package/tags/VPS/index.html +12 -12
- package/tags/Vercel/index.html +12 -12
- package/tags/Workers/index.html +12 -12
- package/tags/hello-world/index.html +12 -12
- package/tags/index.html +12 -12
- package/tags//344/270/273/351/242/230/index.html +12 -12
- package/tags//344/272/221/346/234/215/345/212/241/345/231/250/index.html +12 -12
- package/tags//344/276/277/345/256/234/index.html +12 -12
- package/tags//345/206/231/344/275/234/index.html +12 -12
- package/tags//345/245/263/346/200/247/346/204/217/350/257/206/index.html +12 -12
- package/tags//345/255/246/344/271/240/index.html +12 -12
- package/tags//345/256/266/351/207/214/344/272/221/index.html +12 -12
- package/tags//345/271/264/347/273/210/346/200/273/347/273/223/index.html +12 -12
- package/tags//346/200/247/344/273/267/346/257/224/index.html +12 -12
- package/tags//346/212/230/350/205/276/index.html +12 -12
- package/tags//346/217/220/344/276/233/345/225/206/index.html +12 -12
- package/tags//346/227/245/345/270/270/index.html +12 -12
- package/tags//346/234/215/345/212/241/345/231/250/index.html +12 -12
- package/tags//346/265/252/346/275/256/index.html +12 -12
- package/tags//347/256/200/347/210/261/index.html +12 -12
- package/tags//350/207/252/345/212/250/346/240/207/346/263/250/index.html +12 -12
- package/tags//350/256/272/346/226/207/index.html +12 -12
- package/tags//350/260/267/346/255/214/347/277/273/350/257/221/index.html +12 -12
- package/tags//350/264/237/350/275/275/345/235/207/350/241/241/index.html +12 -12
- package/tags//351/207/221/345/217/245/index.html +12 -12
- package/tags//351/255/224/346/224/271/index.html +12 -12
- package/img-col/index.html +0 -802
@@ -1,31 +1,31 @@
|
|
1
|
-
{
|
2
|
-
"name": "live2d-widget",
|
3
|
-
"version": "0.9.0",
|
4
|
-
"description": "Live2D widget for web pages",
|
5
|
-
"main": "autoload.js",
|
6
|
-
"type": "module",
|
7
|
-
"scripts": {
|
8
|
-
"build": "rollup -c rollup.config.js -f iife | terser -c -m > waifu-tips.js",
|
9
|
-
"build-dev": "rollup -c rollup.config.js -f iife -o waifu-tips.js -w"
|
10
|
-
},
|
11
|
-
"repository": {
|
12
|
-
"type": "git",
|
13
|
-
"url": "git+https://github.com/stevenjoezhang/live2d-widget.git"
|
14
|
-
},
|
15
|
-
"keywords": [
|
16
|
-
"Live2d"
|
17
|
-
],
|
18
|
-
"author": "stevenjoezhang <stevenjoezhang@gmail.com>",
|
19
|
-
"license": "GPL-3.0-or-later",
|
20
|
-
"bugs": {
|
21
|
-
"url": "https://github.com/stevenjoezhang/live2d-widget/issues"
|
22
|
-
},
|
23
|
-
"homepage": "https://github.com/stevenjoezhang/live2d-widget#readme",
|
24
|
-
"devDependencies": {
|
25
|
-
"@fortawesome/fontawesome-free": "^6.2.0",
|
26
|
-
"@rollup/plugin-node-resolve": "^15.0.0",
|
27
|
-
"@rollup/pluginutils": "^5.0.1",
|
28
|
-
"rollup": "^3.2.3",
|
29
|
-
"terser": "^5.15.1"
|
30
|
-
}
|
31
|
-
}
|
1
|
+
{
|
2
|
+
"name": "live2d-widget",
|
3
|
+
"version": "0.9.0",
|
4
|
+
"description": "Live2D widget for web pages",
|
5
|
+
"main": "autoload.js",
|
6
|
+
"type": "module",
|
7
|
+
"scripts": {
|
8
|
+
"build": "rollup -c rollup.config.js -f iife | terser -c -m > waifu-tips.js",
|
9
|
+
"build-dev": "rollup -c rollup.config.js -f iife -o waifu-tips.js -w"
|
10
|
+
},
|
11
|
+
"repository": {
|
12
|
+
"type": "git",
|
13
|
+
"url": "git+https://github.com/stevenjoezhang/live2d-widget.git"
|
14
|
+
},
|
15
|
+
"keywords": [
|
16
|
+
"Live2d"
|
17
|
+
],
|
18
|
+
"author": "stevenjoezhang <stevenjoezhang@gmail.com>",
|
19
|
+
"license": "GPL-3.0-or-later",
|
20
|
+
"bugs": {
|
21
|
+
"url": "https://github.com/stevenjoezhang/live2d-widget/issues"
|
22
|
+
},
|
23
|
+
"homepage": "https://github.com/stevenjoezhang/live2d-widget#readme",
|
24
|
+
"devDependencies": {
|
25
|
+
"@fortawesome/fontawesome-free": "^6.2.0",
|
26
|
+
"@rollup/plugin-node-resolve": "^15.0.0",
|
27
|
+
"@rollup/pluginutils": "^5.0.1",
|
28
|
+
"rollup": "^3.2.3",
|
29
|
+
"terser": "^5.15.1"
|
30
|
+
}
|
31
|
+
}
|
@@ -1,38 +1,38 @@
|
|
1
|
-
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
2
|
-
import { createFilter } from "@rollup/pluginutils";
|
3
|
-
|
4
|
-
function string(opts = {}) {
|
5
|
-
if (!opts.include) {
|
6
|
-
throw Error("include option should be specified");
|
7
|
-
}
|
8
|
-
|
9
|
-
const filter = createFilter(opts.include, opts.exclude);
|
10
|
-
|
11
|
-
return {
|
12
|
-
name: "string",
|
13
|
-
|
14
|
-
transform(code, id) {
|
15
|
-
if (filter(id)) {
|
16
|
-
return {
|
17
|
-
code: `export default ${JSON.stringify(code)};`,
|
18
|
-
map: { mappings: "" }
|
19
|
-
};
|
20
|
-
}
|
21
|
-
},
|
22
|
-
|
23
|
-
renderChunk(code, chunk, outputOptions = {}) {
|
24
|
-
return `/*!
|
25
|
-
* Live2D Widget
|
26
|
-
* https://github.com/stevenjoezhang/live2d-widget
|
27
|
-
*/
|
28
|
-
` + code;
|
29
|
-
}
|
30
|
-
};
|
31
|
-
}
|
32
|
-
|
33
|
-
export default {
|
34
|
-
input: "src/waifu-tips.js",
|
35
|
-
plugins: [nodeResolve(), string({
|
36
|
-
include: "**/*.svg",
|
37
|
-
})]
|
38
|
-
};
|
1
|
+
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
2
|
+
import { createFilter } from "@rollup/pluginutils";
|
3
|
+
|
4
|
+
function string(opts = {}) {
|
5
|
+
if (!opts.include) {
|
6
|
+
throw Error("include option should be specified");
|
7
|
+
}
|
8
|
+
|
9
|
+
const filter = createFilter(opts.include, opts.exclude);
|
10
|
+
|
11
|
+
return {
|
12
|
+
name: "string",
|
13
|
+
|
14
|
+
transform(code, id) {
|
15
|
+
if (filter(id)) {
|
16
|
+
return {
|
17
|
+
code: `export default ${JSON.stringify(code)};`,
|
18
|
+
map: { mappings: "" }
|
19
|
+
};
|
20
|
+
}
|
21
|
+
},
|
22
|
+
|
23
|
+
renderChunk(code, chunk, outputOptions = {}) {
|
24
|
+
return `/*!
|
25
|
+
* Live2D Widget
|
26
|
+
* https://github.com/stevenjoezhang/live2d-widget
|
27
|
+
*/
|
28
|
+
` + code;
|
29
|
+
}
|
30
|
+
};
|
31
|
+
}
|
32
|
+
|
33
|
+
export default {
|
34
|
+
input: "src/waifu-tips.js",
|
35
|
+
plugins: [nodeResolve(), string({
|
36
|
+
include: "**/*.svg",
|
37
|
+
})]
|
38
|
+
};
|
@@ -1,178 +1,178 @@
|
|
1
|
-
import Model from "./model.js";
|
2
|
-
import showMessage from "./message.js";
|
3
|
-
import randomSelection from "./utils.js";
|
4
|
-
import tools from "./tools.js";
|
5
|
-
|
6
|
-
function loadWidget(config) {
|
7
|
-
const model = new Model(config);
|
8
|
-
localStorage.removeItem("waifu-display");
|
9
|
-
sessionStorage.removeItem("waifu-text");
|
10
|
-
document.body.insertAdjacentHTML("beforeend", `<div id="waifu">
|
11
|
-
<div id="waifu-tips"></div>
|
12
|
-
<canvas id="live2d" width="800" height="800"></canvas>
|
13
|
-
<div id="waifu-tool"></div>
|
14
|
-
</div>`);
|
15
|
-
// https://stackoverflow.com/questions/24148403/trigger-css-transition-on-appended-element
|
16
|
-
setTimeout(() => {
|
17
|
-
document.getElementById("waifu").style.bottom = 0;
|
18
|
-
}, 0);
|
19
|
-
|
20
|
-
(function registerTools() {
|
21
|
-
tools["switch-model"].callback = () => model.loadOtherModel();
|
22
|
-
tools["switch-texture"].callback = () => model.loadRandModel();
|
23
|
-
if (!Array.isArray(config.tools)) {
|
24
|
-
config.tools = Object.keys(tools);
|
25
|
-
}
|
26
|
-
for (let tool of config.tools) {
|
27
|
-
if (tools[tool]) {
|
28
|
-
const { icon, callback } = tools[tool];
|
29
|
-
document.getElementById("waifu-tool").insertAdjacentHTML("beforeend", `<span id="waifu-tool-${tool}">${icon}</span>`);
|
30
|
-
document.getElementById(`waifu-tool-${tool}`).addEventListener("click", callback);
|
31
|
-
}
|
32
|
-
}
|
33
|
-
})();
|
34
|
-
|
35
|
-
function welcomeMessage(time) {
|
36
|
-
if (location.pathname === "/") { // 如果是主页
|
37
|
-
for (let { hour, text } of time) {
|
38
|
-
const now = new Date(),
|
39
|
-
after = hour.split("-")[0],
|
40
|
-
before = hour.split("-")[1] || after;
|
41
|
-
if (after <= now.getHours() && now.getHours() <= before) {
|
42
|
-
return text;
|
43
|
-
}
|
44
|
-
}
|
45
|
-
}
|
46
|
-
const text = `欢迎阅读<span>「${document.title.split(" - ")[0]}」</span>`;
|
47
|
-
let from;
|
48
|
-
if (document.referrer !== "") {
|
49
|
-
const referrer = new URL(document.referrer),
|
50
|
-
domain = referrer.hostname.split(".")[1];
|
51
|
-
const domains = {
|
52
|
-
"baidu": "百度",
|
53
|
-
"so": "360搜索",
|
54
|
-
"google": "谷歌搜索"
|
55
|
-
};
|
56
|
-
if (location.hostname === referrer.hostname) return text;
|
57
|
-
|
58
|
-
if (domain in domains) from = domains[domain];
|
59
|
-
else from = referrer.hostname;
|
60
|
-
return `Hello!来自 <span>${from}</span> 的朋友<br>${text}`;
|
61
|
-
}
|
62
|
-
return text;
|
63
|
-
}
|
64
|
-
|
65
|
-
function registerEventListener(result) {
|
66
|
-
// 检测用户活动状态,并在空闲时显示消息
|
67
|
-
let userAction = false,
|
68
|
-
userActionTimer,
|
69
|
-
messageArray = result.message.default,
|
70
|
-
lastHoverElement;
|
71
|
-
window.addEventListener("mousemove", () => userAction = true);
|
72
|
-
window.addEventListener("keydown", () => userAction = true);
|
73
|
-
setInterval(() => {
|
74
|
-
if (userAction) {
|
75
|
-
userAction = false;
|
76
|
-
clearInterval(userActionTimer);
|
77
|
-
userActionTimer = null;
|
78
|
-
} else if (!userActionTimer) {
|
79
|
-
userActionTimer = setInterval(() => {
|
80
|
-
showMessage(messageArray, 6000, 9);
|
81
|
-
}, 20000);
|
82
|
-
}
|
83
|
-
}, 1000);
|
84
|
-
showMessage(welcomeMessage(result.time), 7000, 11);
|
85
|
-
window.addEventListener("mouseover", event => {
|
86
|
-
for (let { selector, text } of result.mouseover) {
|
87
|
-
if (!event.target.closest(selector)) continue;
|
88
|
-
if (lastHoverElement === selector) return;
|
89
|
-
lastHoverElement = selector;
|
90
|
-
text = randomSelection(text);
|
91
|
-
text = text.replace("{text}", event.target.innerText);
|
92
|
-
showMessage(text, 4000, 8);
|
93
|
-
return;
|
94
|
-
}
|
95
|
-
});
|
96
|
-
window.addEventListener("click", event => {
|
97
|
-
for (let { selector, text } of result.click) {
|
98
|
-
if (!event.target.closest(selector)) continue;
|
99
|
-
text = randomSelection(text);
|
100
|
-
text = text.replace("{text}", event.target.innerText);
|
101
|
-
showMessage(text, 4000, 8);
|
102
|
-
return;
|
103
|
-
}
|
104
|
-
});
|
105
|
-
result.seasons.forEach(({ date, text }) => {
|
106
|
-
const now = new Date(),
|
107
|
-
after = date.split("-")[0],
|
108
|
-
before = date.split("-")[1] || after;
|
109
|
-
if ((after.split("/")[0] <= now.getMonth() + 1 && now.getMonth() + 1 <= before.split("/")[0]) && (after.split("/")[1] <= now.getDate() && now.getDate() <= before.split("/")[1])) {
|
110
|
-
text = randomSelection(text);
|
111
|
-
text = text.replace("{year}", now.getFullYear());
|
112
|
-
messageArray.push(text);
|
113
|
-
}
|
114
|
-
});
|
115
|
-
|
116
|
-
const devtools = () => { };
|
117
|
-
console.log("%c", devtools);
|
118
|
-
devtools.toString = () => {
|
119
|
-
showMessage(result.message.console, 6000, 9);
|
120
|
-
};
|
121
|
-
window.addEventListener("copy", () => {
|
122
|
-
showMessage(result.message.copy, 6000, 9);
|
123
|
-
});
|
124
|
-
window.addEventListener("visibilitychange", () => {
|
125
|
-
if (!document.hidden) showMessage(result.message.visibilitychange, 6000, 9);
|
126
|
-
});
|
127
|
-
}
|
128
|
-
|
129
|
-
(function initModel() {
|
130
|
-
let modelId = localStorage.getItem("modelId"),
|
131
|
-
modelTexturesId = localStorage.getItem("modelTexturesId");
|
132
|
-
if (modelId === null) {
|
133
|
-
// 首次访问加载 指定模型 的 指定材质
|
134
|
-
modelId = 1; // 模型 ID
|
135
|
-
modelTexturesId = 53; // 材质 ID
|
136
|
-
}
|
137
|
-
model.loadModel(modelId, modelTexturesId);
|
138
|
-
fetch(config.waifuPath)
|
139
|
-
.then(response => response.json())
|
140
|
-
.then(registerEventListener);
|
141
|
-
})();
|
142
|
-
}
|
143
|
-
|
144
|
-
function initWidget(config, apiPath) {
|
145
|
-
if (typeof config === "string") {
|
146
|
-
config = {
|
147
|
-
waifuPath: config,
|
148
|
-
apiPath
|
149
|
-
};
|
150
|
-
}
|
151
|
-
document.body.insertAdjacentHTML("beforeend", `<div id="waifu-toggle">
|
152
|
-
<span>看板娘</span>
|
153
|
-
</div>`);
|
154
|
-
const toggle = document.getElementById("waifu-toggle");
|
155
|
-
toggle.addEventListener("click", () => {
|
156
|
-
toggle.classList.remove("waifu-toggle-active");
|
157
|
-
if (toggle.getAttribute("first-time")) {
|
158
|
-
loadWidget(config);
|
159
|
-
toggle.removeAttribute("first-time");
|
160
|
-
} else {
|
161
|
-
localStorage.removeItem("waifu-display");
|
162
|
-
document.getElementById("waifu").style.display = "";
|
163
|
-
setTimeout(() => {
|
164
|
-
document.getElementById("waifu").style.bottom = 0;
|
165
|
-
}, 0);
|
166
|
-
}
|
167
|
-
});
|
168
|
-
if (localStorage.getItem("waifu-display") && Date.now() - localStorage.getItem("waifu-display") <= 86400000) {
|
169
|
-
toggle.setAttribute("first-time", true);
|
170
|
-
setTimeout(() => {
|
171
|
-
toggle.classList.add("waifu-toggle-active");
|
172
|
-
}, 0);
|
173
|
-
} else {
|
174
|
-
loadWidget(config);
|
175
|
-
}
|
176
|
-
}
|
177
|
-
|
178
|
-
export default initWidget;
|
1
|
+
import Model from "./model.js";
|
2
|
+
import showMessage from "./message.js";
|
3
|
+
import randomSelection from "./utils.js";
|
4
|
+
import tools from "./tools.js";
|
5
|
+
|
6
|
+
function loadWidget(config) {
|
7
|
+
const model = new Model(config);
|
8
|
+
localStorage.removeItem("waifu-display");
|
9
|
+
sessionStorage.removeItem("waifu-text");
|
10
|
+
document.body.insertAdjacentHTML("beforeend", `<div id="waifu">
|
11
|
+
<div id="waifu-tips"></div>
|
12
|
+
<canvas id="live2d" width="800" height="800"></canvas>
|
13
|
+
<div id="waifu-tool"></div>
|
14
|
+
</div>`);
|
15
|
+
// https://stackoverflow.com/questions/24148403/trigger-css-transition-on-appended-element
|
16
|
+
setTimeout(() => {
|
17
|
+
document.getElementById("waifu").style.bottom = 0;
|
18
|
+
}, 0);
|
19
|
+
|
20
|
+
(function registerTools() {
|
21
|
+
tools["switch-model"].callback = () => model.loadOtherModel();
|
22
|
+
tools["switch-texture"].callback = () => model.loadRandModel();
|
23
|
+
if (!Array.isArray(config.tools)) {
|
24
|
+
config.tools = Object.keys(tools);
|
25
|
+
}
|
26
|
+
for (let tool of config.tools) {
|
27
|
+
if (tools[tool]) {
|
28
|
+
const { icon, callback } = tools[tool];
|
29
|
+
document.getElementById("waifu-tool").insertAdjacentHTML("beforeend", `<span id="waifu-tool-${tool}">${icon}</span>`);
|
30
|
+
document.getElementById(`waifu-tool-${tool}`).addEventListener("click", callback);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
})();
|
34
|
+
|
35
|
+
function welcomeMessage(time) {
|
36
|
+
if (location.pathname === "/") { // 如果是主页
|
37
|
+
for (let { hour, text } of time) {
|
38
|
+
const now = new Date(),
|
39
|
+
after = hour.split("-")[0],
|
40
|
+
before = hour.split("-")[1] || after;
|
41
|
+
if (after <= now.getHours() && now.getHours() <= before) {
|
42
|
+
return text;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
const text = `欢迎阅读<span>「${document.title.split(" - ")[0]}」</span>`;
|
47
|
+
let from;
|
48
|
+
if (document.referrer !== "") {
|
49
|
+
const referrer = new URL(document.referrer),
|
50
|
+
domain = referrer.hostname.split(".")[1];
|
51
|
+
const domains = {
|
52
|
+
"baidu": "百度",
|
53
|
+
"so": "360搜索",
|
54
|
+
"google": "谷歌搜索"
|
55
|
+
};
|
56
|
+
if (location.hostname === referrer.hostname) return text;
|
57
|
+
|
58
|
+
if (domain in domains) from = domains[domain];
|
59
|
+
else from = referrer.hostname;
|
60
|
+
return `Hello!来自 <span>${from}</span> 的朋友<br>${text}`;
|
61
|
+
}
|
62
|
+
return text;
|
63
|
+
}
|
64
|
+
|
65
|
+
function registerEventListener(result) {
|
66
|
+
// 检测用户活动状态,并在空闲时显示消息
|
67
|
+
let userAction = false,
|
68
|
+
userActionTimer,
|
69
|
+
messageArray = result.message.default,
|
70
|
+
lastHoverElement;
|
71
|
+
window.addEventListener("mousemove", () => userAction = true);
|
72
|
+
window.addEventListener("keydown", () => userAction = true);
|
73
|
+
setInterval(() => {
|
74
|
+
if (userAction) {
|
75
|
+
userAction = false;
|
76
|
+
clearInterval(userActionTimer);
|
77
|
+
userActionTimer = null;
|
78
|
+
} else if (!userActionTimer) {
|
79
|
+
userActionTimer = setInterval(() => {
|
80
|
+
showMessage(messageArray, 6000, 9);
|
81
|
+
}, 20000);
|
82
|
+
}
|
83
|
+
}, 1000);
|
84
|
+
showMessage(welcomeMessage(result.time), 7000, 11);
|
85
|
+
window.addEventListener("mouseover", event => {
|
86
|
+
for (let { selector, text } of result.mouseover) {
|
87
|
+
if (!event.target.closest(selector)) continue;
|
88
|
+
if (lastHoverElement === selector) return;
|
89
|
+
lastHoverElement = selector;
|
90
|
+
text = randomSelection(text);
|
91
|
+
text = text.replace("{text}", event.target.innerText);
|
92
|
+
showMessage(text, 4000, 8);
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
});
|
96
|
+
window.addEventListener("click", event => {
|
97
|
+
for (let { selector, text } of result.click) {
|
98
|
+
if (!event.target.closest(selector)) continue;
|
99
|
+
text = randomSelection(text);
|
100
|
+
text = text.replace("{text}", event.target.innerText);
|
101
|
+
showMessage(text, 4000, 8);
|
102
|
+
return;
|
103
|
+
}
|
104
|
+
});
|
105
|
+
result.seasons.forEach(({ date, text }) => {
|
106
|
+
const now = new Date(),
|
107
|
+
after = date.split("-")[0],
|
108
|
+
before = date.split("-")[1] || after;
|
109
|
+
if ((after.split("/")[0] <= now.getMonth() + 1 && now.getMonth() + 1 <= before.split("/")[0]) && (after.split("/")[1] <= now.getDate() && now.getDate() <= before.split("/")[1])) {
|
110
|
+
text = randomSelection(text);
|
111
|
+
text = text.replace("{year}", now.getFullYear());
|
112
|
+
messageArray.push(text);
|
113
|
+
}
|
114
|
+
});
|
115
|
+
|
116
|
+
const devtools = () => { };
|
117
|
+
console.log("%c", devtools);
|
118
|
+
devtools.toString = () => {
|
119
|
+
showMessage(result.message.console, 6000, 9);
|
120
|
+
};
|
121
|
+
window.addEventListener("copy", () => {
|
122
|
+
showMessage(result.message.copy, 6000, 9);
|
123
|
+
});
|
124
|
+
window.addEventListener("visibilitychange", () => {
|
125
|
+
if (!document.hidden) showMessage(result.message.visibilitychange, 6000, 9);
|
126
|
+
});
|
127
|
+
}
|
128
|
+
|
129
|
+
(function initModel() {
|
130
|
+
let modelId = localStorage.getItem("modelId"),
|
131
|
+
modelTexturesId = localStorage.getItem("modelTexturesId");
|
132
|
+
if (modelId === null) {
|
133
|
+
// 首次访问加载 指定模型 的 指定材质
|
134
|
+
modelId = 1; // 模型 ID
|
135
|
+
modelTexturesId = 53; // 材质 ID
|
136
|
+
}
|
137
|
+
model.loadModel(modelId, modelTexturesId);
|
138
|
+
fetch(config.waifuPath)
|
139
|
+
.then(response => response.json())
|
140
|
+
.then(registerEventListener);
|
141
|
+
})();
|
142
|
+
}
|
143
|
+
|
144
|
+
function initWidget(config, apiPath) {
|
145
|
+
if (typeof config === "string") {
|
146
|
+
config = {
|
147
|
+
waifuPath: config,
|
148
|
+
apiPath
|
149
|
+
};
|
150
|
+
}
|
151
|
+
document.body.insertAdjacentHTML("beforeend", `<div id="waifu-toggle">
|
152
|
+
<span>看板娘</span>
|
153
|
+
</div>`);
|
154
|
+
const toggle = document.getElementById("waifu-toggle");
|
155
|
+
toggle.addEventListener("click", () => {
|
156
|
+
toggle.classList.remove("waifu-toggle-active");
|
157
|
+
if (toggle.getAttribute("first-time")) {
|
158
|
+
loadWidget(config);
|
159
|
+
toggle.removeAttribute("first-time");
|
160
|
+
} else {
|
161
|
+
localStorage.removeItem("waifu-display");
|
162
|
+
document.getElementById("waifu").style.display = "";
|
163
|
+
setTimeout(() => {
|
164
|
+
document.getElementById("waifu").style.bottom = 0;
|
165
|
+
}, 0);
|
166
|
+
}
|
167
|
+
});
|
168
|
+
if (localStorage.getItem("waifu-display") && Date.now() - localStorage.getItem("waifu-display") <= 86400000) {
|
169
|
+
toggle.setAttribute("first-time", true);
|
170
|
+
setTimeout(() => {
|
171
|
+
toggle.classList.add("waifu-toggle-active");
|
172
|
+
}, 0);
|
173
|
+
} else {
|
174
|
+
loadWidget(config);
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
export default initWidget;
|
@@ -1,22 +1,22 @@
|
|
1
|
-
import randomSelection from "./utils.js";
|
2
|
-
|
3
|
-
let messageTimer;
|
4
|
-
|
5
|
-
function showMessage(text, timeout, priority) {
|
6
|
-
if (!text || (sessionStorage.getItem("waifu-text") && sessionStorage.getItem("waifu-text") > priority)) return;
|
7
|
-
if (messageTimer) {
|
8
|
-
clearTimeout(messageTimer);
|
9
|
-
messageTimer = null;
|
10
|
-
}
|
11
|
-
text = randomSelection(text);
|
12
|
-
sessionStorage.setItem("waifu-text", priority);
|
13
|
-
const tips = document.getElementById("waifu-tips");
|
14
|
-
tips.innerHTML = text;
|
15
|
-
tips.classList.add("waifu-tips-active");
|
16
|
-
messageTimer = setTimeout(() => {
|
17
|
-
sessionStorage.removeItem("waifu-text");
|
18
|
-
tips.classList.remove("waifu-tips-active");
|
19
|
-
}, timeout);
|
20
|
-
}
|
21
|
-
|
22
|
-
export default showMessage;
|
1
|
+
import randomSelection from "./utils.js";
|
2
|
+
|
3
|
+
let messageTimer;
|
4
|
+
|
5
|
+
function showMessage(text, timeout, priority) {
|
6
|
+
if (!text || (sessionStorage.getItem("waifu-text") && sessionStorage.getItem("waifu-text") > priority)) return;
|
7
|
+
if (messageTimer) {
|
8
|
+
clearTimeout(messageTimer);
|
9
|
+
messageTimer = null;
|
10
|
+
}
|
11
|
+
text = randomSelection(text);
|
12
|
+
sessionStorage.setItem("waifu-text", priority);
|
13
|
+
const tips = document.getElementById("waifu-tips");
|
14
|
+
tips.innerHTML = text;
|
15
|
+
tips.classList.add("waifu-tips-active");
|
16
|
+
messageTimer = setTimeout(() => {
|
17
|
+
sessionStorage.removeItem("waifu-text");
|
18
|
+
tips.classList.remove("waifu-tips-active");
|
19
|
+
}, timeout);
|
20
|
+
}
|
21
|
+
|
22
|
+
export default showMessage;
|