Update waifu-tips.js

This commit is contained in:
PFiS 2021-02-14 22:44:52 +08:00 committed by GitHub
parent 4d89c96e0e
commit 04f3a44224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -196,7 +196,7 @@ function loadWidget(config) {
window.addEventListener("mouseover", event => { window.addEventListener("mouseover", event => {
for (let { selector, text } of result.mouseover) { for (let { selector, text } of result.mouseover) {
if (!event.target.matches(selector)) continue; if (!event.target.matches(selector)) continue;
text = randomSelection(tips.text); text = randomSelection(text);
text = text.replace("{text}", event.target.innerText); text = text.replace("{text}", event.target.innerText);
showMessage(text, 4000, 8); showMessage(text, 4000, 8);
return; return;
@ -205,18 +205,18 @@ function loadWidget(config) {
window.addEventListener("click", event => { window.addEventListener("click", event => {
for (let { selector, text } of result.click) { for (let { selector, text } of result.click) {
if (!event.target.matches(selector)) continue; if (!event.target.matches(selector)) continue;
text = randomSelection(tips.text); text = randomSelection(text);
text = text.replace("{text}", event.target.innerText); text = text.replace("{text}", event.target.innerText);
showMessage(text, 4000, 8); showMessage(text, 4000, 8);
return; return;
} }
}); });
result.seasons.forEach(tips => { result.seasons.forEach(({ date, text }) => {
const now = new Date(), const now = new Date(),
after = tips.date.split("-")[0], after = date.split("-")[0],
before = tips.date.split("-")[1] || after; before = date.split("-")[1] || after;
if ((after.split("/")[0] <= now.getMonth() + 1 && now.getMonth() + 1 <= before.split("/")[0]) && (after.split("/")[1] <= now.getDate() && now.getDate() <= before.split("/")[1])) { if ((after.split("/")[0] <= now.getMonth() + 1 && now.getMonth() + 1 <= before.split("/")[0]) && (after.split("/")[1] <= now.getDate() && now.getDate() <= before.split("/")[1])) {
let text = randomSelection(tips.text); text = randomSelection(text);
text = text.replace("{year}", now.getFullYear()); text = text.replace("{year}", now.getFullYear());
//showMessage(text, 7000, true); //showMessage(text, 7000, true);
messageArray.push(text); messageArray.push(text);