Update waifu-tips.js

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

View File

@ -194,18 +194,18 @@ function loadWidget(config) {
.then(response => response.json()) .then(response => response.json())
.then(result => { .then(result => {
window.addEventListener("mouseover", event => { window.addEventListener("mouseover", event => {
for (let tips of result.mouseover) { for (let { selector, text } of result.mouseover) {
if (!event.target.matches(tips.selector)) continue; if (!event.target.matches(selector)) continue;
let text = randomSelection(tips.text); text = randomSelection(tips.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;
} }
}); });
window.addEventListener("click", event => { window.addEventListener("click", event => {
for (let tips of result.click) { for (let { selector, text } of result.click) {
if (!event.target.matches(tips.selector)) continue; if (!event.target.matches(selector)) continue;
let text = randomSelection(tips.text); text = randomSelection(tips.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;