Custom message

This commit is contained in:
Mimi 2022-10-20 23:00:36 +08:00
parent e0be7adf1d
commit 45807e0238
3 changed files with 25 additions and 23 deletions

View File

@ -35,34 +35,21 @@ function loadWidget(config) {
document.getElementById(`waifu-tool-${tool}`).addEventListener("click", callback);
}
}
const devtools = () => {};
console.log("%c", devtools);
devtools.toString = () => {
showMessage("哈哈,你打开了控制台,是想要看看我的小秘密吗?", 6000, 9);
};
window.addEventListener("copy", () => {
showMessage("你都复制了些什么呀,转载要记得加上出处哦!", 6000, 9);
});
window.addEventListener("visibilitychange", () => {
if (!document.hidden) showMessage("哇,你终于回来了~", 6000, 9);
});
})();
function welcomeMessage(time) {
const message = `欢迎阅读<span>「${document.title.split(" - ")[0]}」</span>`;
let text;
if (location.pathname === "/") { // 如果是主页
for (let { hour, text } of time) {
const now = new Date(),
after = hour.split("-")[0],
before = hour.split("-")[1] || after;
if (after <= now.getHours() && now.getHours() <= before) {
text = randomSelection(text);
return text;
}
}
}
const text = `欢迎阅读<span>「${document.title.split(" - ")[0]}」</span>`;
let from;
if (document.referrer !== "") {
const referrer = new URL(document.referrer),
domain = referrer.hostname.split(".")[1];
@ -71,13 +58,13 @@ function loadWidget(config) {
"so": "360搜索",
"google": "谷歌搜索"
};
if (location.hostname === referrer.hostname) return message;
if (location.hostname === referrer.hostname) return text;
if (domain in domains) text = domains[domain];
else text = referrer.hostname;
return `Hello来自 <span>${text}</span> 的朋友<br>${message}`;
if (domain in domains) from = domains[domain];
else from = referrer.hostname;
return `Hello来自 <span>${from}</span> 的朋友<br>${text}`;
}
return message;
return text;
}
function registerEventListener(result) {
@ -94,7 +81,7 @@ function loadWidget(config) {
userActionTimer = null;
} else if (!userActionTimer) {
userActionTimer = setInterval(() => {
showMessage(randomSelection(messageArray), 6000, 9);
showMessage(messageArray, 6000, 9);
}, 20000);
}
}, 1000);
@ -127,6 +114,18 @@ function loadWidget(config) {
messageArray.push(text);
}
});
const devtools = () => { };
console.log("%c", devtools);
devtools.toString = () => {
showMessage(result.message.console, 6000, 9);
};
window.addEventListener("copy", () => {
showMessage(result.message.copy, 6000, 9);
});
window.addEventListener("visibilitychange", () => {
if (!document.hidden) showMessage(result.message.visibilitychange, 6000, 9);
});
}
(function initModel() {

File diff suppressed because one or more lines are too long

View File

@ -247,6 +247,9 @@
"text": "你是夜猫子呀?这么晚还不睡觉,明天起的来嘛?"
}],
"message": {
"default": ["好久不见,日子过得好快呢……", "大坏蛋!你都多久没理人家了呀,嘤嘤嘤~", "嗨~快来逗我玩吧!", "拿小拳拳锤你胸口!", "记得把小家加入收藏夹哦!"]
"default": ["好久不见,日子过得好快呢……", "大坏蛋!你都多久没理人家了呀,嘤嘤嘤~", "嗨~快来逗我玩吧!", "拿小拳拳锤你胸口!", "记得把小家加入收藏夹哦!"],
"console": "哈哈,你打开了控制台,是想要看看我的小秘密吗?",
"copy": "你都复制了些什么呀,转载要记得加上出处哦!",
"visibilitychange": "哇,你终于回来了~"
}
}