forked from huycoihdinfo/Binance_Moonbix_bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contentScript.js
104 lines (96 loc) · 3.25 KB
/
contentScript.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
'use strict';
function simulateClick(element) {
const event = new MouseEvent('click', {
bubbles: true,
cancelable: true,
view: window
});
element.dispatchEvent(event);
}
function startGame() {
const startButton = document.querySelector('.Game_game__container__1I7MG .bn-svg');
if (startButton) {
console.log('Start button found, clicking to start the game...');
simulateClick(startButton);
} else {
console.log('Start button not found.');
}
}
function playGame() {
const canvas = document.querySelector('.canvas-wrapper canvas');
if (canvas) {
console.log('Canvas found, simulating game play...');
const interval = setInterval(() => {
const rect = canvas.getBoundingClientRect();
const x = rect.left + (rect.width / 2);
const y = rect.top + (rect.height / 2);
simulateClick(canvas);
console.log('Clicking on canvas at position:', x, y);
}, 1000);
} else {
console.log('Canvas not found.');
}
}
function clickTaskTab() {
const taskTab = Array.from(document.querySelectorAll('.components_container__tab__1mbN9')).find(tab => {
return tab.innerText.includes('Nhiệm vụ');
});
if (taskTab) {
console.log('Task tab found, clicking...');
taskTab.click();
return true;
} else {
console.log('Tasks tab not found.');
return false;
}
}
function clickIncompleteTask() {
const tasks = document.querySelectorAll('.Tasks_taskItem__16PwK');
let foundIncompleteTask = false;
for (const task of tasks) {
const checkIcon = task.querySelector('img[src*="check.png"]');
if (!checkIcon) {
console.log('Unfinished task found, clicking...');
task.click(); // Thực hiện click vào nhiệm vụ chưa hoàn thành
foundIncompleteTask = true;
break;
}
}
return foundIncompleteTask;
}
function clickContinueButton() {
const continueButton = document.querySelector('.DailyLogin_login__button__15aOK');
if (continueButton) {
console.log('The "Continue" button is found, clicking...');
continueButton.click(); // Thực hiện click vào nút "Tiếp tục"
return true;
} else {
console.log('"Continue" button not found.');
return false;
}
}
window.addEventListener('load', function() {
if (document.readyState === 'complete') {
// Thực hiện hàm click
let clicked = false;
const interval = setInterval(() => {
clicked = clickTaskTab();
if (clicked) {
clearInterval(interval);
const taskInterval = setInterval(() => {
const found = clickIncompleteTask();
if (!found) {
clearInterval(taskInterval);
console.log('No more unfinished quests found.');
}
}, 1000);
}
}, 1000);
const continueInterval = setInterval(() => {
const clickedContinue = clickContinueButton();
if (clickedContinue) {
clearInterval(continueInterval);
}
}, 1000);
}
});