-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
87 lines (74 loc) · 2.62 KB
/
script.js
File metadata and controls
87 lines (74 loc) · 2.62 KB
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
if (typeof Game === "undefined") {
const Game = {
Earn: function(amount) {
console.log(`Earned ${amount} in the game!`);
}
};
}
const inputContainer = document.createElement('div');
inputContainer.style.position = 'fixed';
inputContainer.style.top = '20px';
inputContainer.style.left = '50%';
inputContainer.style.transform = 'translateX(-50%)';
inputContainer.style.zIndex = '9999';
inputContainer.style.background = 'pink';
inputContainer.style.padding = '10px';
inputContainer.style.borderRadius = '5px';
inputContainer.style.color = 'white';
const customTextContainer = document.createElement('div');
customTextContainer.style.fontSize = '18px';
customTextContainer.style.fontWeight = 'bold';
customTextContainer.style.marginBottom = '10px';
customTextContainer.textContent = 'CookieHack Client';
inputContainer.appendChild(customTextContainer);
const inputField = document.createElement('input');
inputField.id = 'amountInput';
inputField.placeholder = 'Enter amount of cookies';
inputField.style.padding = '5px';
inputField.style.fontSize = '16px';
inputField.style.marginRight = '10px';
const earnButton = document.createElement('button');
earnButton.textContent = 'Earn';
earnButton.style.padding = '5px 10px';
earnButton.style.fontSize = '16px';
earnButton.style.cursor = 'pointer';
inputContainer.appendChild(inputField);
inputContainer.appendChild(earnButton);
document.body.appendChild(inputContainer);
const hideButton = document.createElement('button');
hideButton.textContent = 'Hide';
hideButton.style.position = 'fixed';
hideButton.style.top = '20px';
hideButton.style.left = '35%';
hideButton.style.zIndex = '9999';
hideButton.style.padding = '5px 10px';
hideButton.style.fontSize = '16px';
hideButton.style.cursor = 'pointer';
document.body.appendChild(hideButton);
function updateGameEarn() {
const inputValue = document.getElementById('amountInput').value;
const amount = parseInt(inputValue);
if (!isNaN(amount) && amount > 0) {
Game.Earn(amount);
document.getElementById('amountInput').value = '';
} else {
alert("Unvalid number, sorry.");
}
}
earnButton.addEventListener('click', updateGameEarn);
inputField.addEventListener('keydown', function(event) {
if (event.key === 'Enter') {
updateGameEarn();
}
});
let isHidden = false;
hideButton.addEventListener('click', function() {
if (isHidden) {
inputContainer.style.display = 'block';
hideButton.textContent = 'Hide';
} else {
inputContainer.style.display = 'none';
hideButton.textContent = 'Show';
}
isHidden = !isHidden;
});