-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgongde.js
48 lines (40 loc) · 1.41 KB
/
gongde.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
let canClick = true;
function addGoodDeed() {
if (canClick) {
canClick = false;
const textContainer = document.getElementById("text-container");
const animatedText = document.createElement("div");
animatedText.classList.add("animated-text");
animatedText.textContent = "功德+1";
textContainer.appendChild(animatedText);
const muyuImg = document.getElementById("muyu-img");
muyuImg.style.transform = "scale(0.8)";
const audioClick = document.getElementById("audio-click");
audioClick.play(); // 播放点击声音
setTimeout(() => {
textContainer.removeChild(animatedText);
muyuImg.style.transform = "scale(1)";
canClick = true;
}, 500); // 设置延迟为0.5秒
}
}
let autoKnockInterval = null;
let isAutoKnocking = false;
function toggleAutoKnock() {
const toggleButton = document.getElementById("toggleAutoKnockButton");
if (!isAutoKnocking) {
// 启动自动敲击,每秒敲一次
autoKnockInterval = setInterval(autoKnockMuyu, 1000);
isAutoKnocking = true;
toggleButton.textContent = "停止敲击";
} else {
// 停止自动敲击
clearInterval(autoKnockInterval);
isAutoKnocking = false;
toggleButton.textContent = "自动敲击";
}
}
function autoKnockMuyu() {
// 模拟点击木鱼
addGoodDeed();
}