Fix incorrect CSS selector

This commit is contained in:
Mimi 2020-04-10 13:25:11 +08:00
parent f0b53f7560
commit 601bc7f195
2 changed files with 28 additions and 20 deletions

View File

@ -165,21 +165,23 @@ function loadWidget(config) {
fetch(waifuPath) fetch(waifuPath)
.then(response => response.json()) .then(response => response.json())
.then(result => { .then(result => {
result.mouseover.forEach(tips => { window.addEventListener("mouseover", event => {
window.addEventListener("mouseover", event => { for (let tips of result.mouseover) {
if (!event.target.matches(tips.selector)) return; if (!event.target.matches(tips.selector)) continue;
let text = randomSelection(tips.text); let 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;
}
}); });
result.click.forEach(tips => { window.addEventListener("click", event => {
window.addEventListener("click", event => { for (let tips of result.click) {
if (!event.target.matches(tips.selector)) return; if (!event.target.matches(tips.selector)) continue;
let text = randomSelection(tips.text); let 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;
}
}); });
result.seasons.forEach(tips => { result.seasons.forEach(tips => {
let now = new Date(), let now = new Date(),

View File

@ -24,26 +24,29 @@
"selector": "#waifu-tool .fa-times", "selector": "#waifu-tool .fa-times",
"text": ["到了要说再见的时候了吗?", "呜呜 QAQ 后会有期……", "不要抛弃我呀……", "我们,还能再见面吗……", "哼,你会后悔的!"] "text": ["到了要说再见的时候了吗?", "呜呜 QAQ 后会有期……", "不要抛弃我呀……", "我们,还能再见面吗……", "哼,你会后悔的!"]
}, { }, {
"selector": ".menu-item-home", "selector": ".menu-item-home a",
"text": ["点击前往首页,想回到上一页可以使用浏览器的后退功能哦。", "点它就可以回到首页啦!", "回首页看看吧。"] "text": ["点击前往首页,想回到上一页可以使用浏览器的后退功能哦。", "点它就可以回到首页啦!", "回首页看看吧。"]
}, { }, {
"selector": ".menu-item-about", "selector": ".menu-item-about a",
"text": ["你想知道我家主人是谁吗?", "这里有一些关于我家主人的秘密哦,要不要看看呢?", "发现主人出没地点!"] "text": ["你想知道我家主人是谁吗?", "这里有一些关于我家主人的秘密哦,要不要看看呢?", "发现主人出没地点!"]
}, { }, {
"selector": ".menu-item-tags", "selector": ".menu-item-tags a",
"text": ["点击就可以看文章的标签啦!", "点击来查看所有标签哦。", "快看看这里都有什么呢!"] "text": ["点击就可以看文章的标签啦!", "点击来查看所有标签哦。"]
}, { }, {
"selector": ".menu-item-categories", "selector": ".menu-item-categories a",
"text": ["文章都分类好啦~", "点击来查看文章分类哦。", "快看看这里都有什么呢!"] "text": ["文章都分类好啦~", "点击来查看文章分类哦。"]
}, { }, {
"selector": ".menu-item-archives", "selector": ".menu-item-archives a",
"text": ["翻页比较麻烦吗,那就来看看文章归档吧。", "文章目录都整理在这里啦!", "快看看这里都有什么呢?"] "text": ["翻页比较麻烦吗,那就来看看文章归档吧。", "文章目录都整理在这里啦!"]
}, { }, {
"selector": ".menu-item-friends", "selector": ".menu-item-friends a",
"text": ["这是我的朋友们哦ヾ(◍°∇°◍)ノ゙", "要去大佬们的家看看吗?", "要去拜访一下我的朋友们吗?"] "text": ["这是我的朋友们哦ヾ(◍°∇°◍)ノ゙", "要去大佬们的家看看吗?", "要去拜访一下我的朋友们吗?"]
}, { }, {
"selector": ".menu-item-search", "selector": ".menu-item-search a",
"text": ["找不到想看的内容?搜索看看吧!", "在找什么东西呢,需要帮忙吗?"] "text": ["找不到想看的内容?搜索看看吧!", "在找什么东西呢,需要帮忙吗?"]
}, {
"selector": ".menu-item a",
"text": ["快看看这里都有什么呢?"]
}, { }, {
"selector": ".site-author", "selector": ".site-author",
"text": ["我家主人好看吗?", "这是我家主人(*´∇`*)"] "text": ["我家主人好看吗?", "这是我家主人(*´∇`*)"]
@ -66,8 +69,11 @@
"selector": ".fancybox img, img.medium-zoom-image", "selector": ".fancybox img, img.medium-zoom-image",
"text": ["点击图片可以放大呢!"] "text": ["点击图片可以放大呢!"]
}, { }, {
"selector": ".highlight, .gist", "selector": ".copy-btn",
"text": ["代码可以直接点击复制哟。", "GitHub我是新手", "PHP 是最好的语言!"] "text": ["代码可以直接点击复制哟。"]
}, {
"selector": ".highlight .table-container, .gist",
"text": ["GitHub我是新手", "PHP 是最好的语言!"]
}, { }, {
"selector": ".container a[href^='http'], .nav-link .nav-text", "selector": ".container a[href^='http'], .nav-link .nav-text",
"text": ["要去看看 <span>{text}</span> 么?", "去 <span>{text}</span> 逛逛吧。", "到 <span>{text}</span> 看看吧。"] "text": ["要去看看 <span>{text}</span> 么?", "去 <span>{text}</span> 逛逛吧。", "到 <span>{text}</span> 看看吧。"]