-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderer.js
More file actions
152 lines (116 loc) · 7.46 KB
/
renderer.js
File metadata and controls
152 lines (116 loc) · 7.46 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
const startStopBtn = document.getElementById('startStopBtn');
const keybindInput = document.getElementById('keybind');
const themeToggle = document.getElementById('theme-toggle');
const resetKeybindBtn = document.getElementById('resetKeybindBtn');
const Interval = document.getElementById('interval')
const imageButtons = document.querySelectorAll('.image-button img');
let isRunning = false;
//-----------------------------------------------------//
//██╗░░██╗███████╗██╗░░░██╗██████╗░██╗███╗░░██╗██████╗░
//██║░██╔╝██╔════╝╚██╗░██╔╝██╔══██╗██║████╗░██║██╔══██╗
//█████═╝░█████╗░░░╚████╔╝░██████╦╝██║██╔██╗██║██║░░██║
//██╔═██╗░██╔══╝░░░░╚██╔╝░░██╔══██╗██║██║╚████║██║░░██║
//██║░╚██╗███████╗░░░██║░░░██████╦╝██║██║░╚███║██████╔╝
//╚═╝░░╚═╝╚══════╝░░░╚═╝░░░╚═════╝░╚═╝╚═╝░░╚══╝╚═════╝░
//-----------------------------------------------------//
let savedKeybind = localStorage.getItem('keybind');
if (savedKeybind) {
keybindInput.value = savedKeybind;
} else {
keybindInput.value = 'Press a key';
}
keybindInput.addEventListener('click', () => {
keybindInput.value = '';
keybindInput.placeholder = 'Press a key...';
});
document.addEventListener('keydown', (event) => {
if (keybindInput === document.activeElement && keybindInput.value === '') {
const key = event.key;
keybindInput.value = key;
localStorage.setItem('keybind', key);
savedKeybind = key;
keybindInput.placeholder = 'Keybind set';
window.electron.setKeybind(key);
}
});
resetKeybindBtn.addEventListener('click', () => {
localStorage.removeItem('keybind');
keybindInput.value = 'Press a key';
keybindInput.placeholder = 'Keybind reset';
window.electron.setKeybind(null);
});
//-------------------------------------------//
//░█████╗░████████╗██╗░░██╗███████╗██████╗░
//██╔══██╗╚══██╔══╝██║░░██║██╔════╝██╔══██╗
//██║░░██║░░░██║░░░███████║█████╗░░██████╔╝
//██║░░██║░░░██║░░░██╔══██║██╔══╝░░██╔══██╗
//╚█████╔╝░░░██║░░░██║░░██║███████╗██║░░██║
//░╚════╝░░░░╚═╝░░░╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝
//-------------------------------------------//
window.electron.onAutoclickerStatus((status) => {
isRunning = status;
startStopBtn.textContent = isRunning ? 'Stop Clicking' : 'Start Clicking';
});
function updateCPSDisplay(interval) {
const cpsDisplay = document.getElementById('cps');
if (interval && interval >= 1) {
const cps = (1000 / interval).toFixed(2);
cpsDisplay.textContent = `Predicted CPS per second: ${cps}`;
} else if (interval && interval < 1 ) {
cpsDisplay.textContent = 'Predicted CPS per second: 1000';
} else {
cpsDisplay.textContent = 'Predicted CPS per second: Invalid interval';
}
}
Interval.addEventListener('input', () => {
const interval = parseFloat(Interval.value);
updateCPSDisplay(interval);
});
const interval = parseFloat(Interval.value);
updateCPSDisplay(interval);
//-------------------------------------------//
//████████╗██╗░░██╗███████╗███╗░░░███╗███████╗
//╚══██╔══╝██║░░██║██╔════╝████╗░████║██╔════╝
//░░░██║░░░███████║█████╗░░██╔████╔██║█████╗░░
//░░░██║░░░██╔══██║██╔══╝░░██║╚██╔╝██║██╔══╝░░
//░░░██║░░░██║░░██║███████╗██║░╚═╝░██║███████╗
//░░░╚═╝░░░╚═╝░░╚═╝╚══════╝╚═╝░░░░░╚═╝╚══════╝
//-------------------------------------------//
let savedTheme = localStorage.getItem('theme') || 'dark';
document.body.setAttribute('data-theme', savedTheme);
themeToggle.checked = savedTheme === 'light';
themeToggle.addEventListener('change', () => {
const newTheme = themeToggle.checked ? 'light' : 'dark';
document.body.setAttribute('data-theme', newTheme);
localStorage.setItem('theme', newTheme);
updateThemeImages(newTheme);
});
function updateThemeImages(theme) {
imageButtons.forEach(img => {
img.src = img.getAttribute(`data-${theme}`);
});
}
updateThemeImages(savedTheme);
//-------------------------------------------------------------------------------------//
//░█████╗░██╗░░░██╗████████╗░█████╗░░█████╗░██╗░░░░░██╗░█████╗░██╗░░██╗███████╗██████╗░
//██╔══██╗██║░░░██║╚══██╔══╝██╔══██╗██╔══██╗██║░░░░░██║██╔══██╗██║░██╔╝██╔════╝██╔══██╗
//███████║██║░░░██║░░░██║░░░██║░░██║██║░░╚═╝██║░░░░░██║██║░░╚═╝█████═╝░█████╗░░██████╔╝
//██╔══██║██║░░░██║░░░██║░░░██║░░██║██║░░██╗██║░░░░░██║██║░░██╗██╔═██╗░██╔══╝░░██╔══██╗
//██║░░██║╚██████╔╝░░░██║░░░╚█████╔╝╚█████╔╝███████╗██║╚█████╔╝██║░╚██╗███████╗██║░░██║
//╚═╝░░╚═╝░╚═════╝░░░░╚═╝░░░░╚════╝░░╚════╝░╚══════╝╚═╝░╚════╝░╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝
//-------------------------------------------------------------------------------------//
startStopBtn.addEventListener('click', () => {
console.log("Start/Stop button clicked");
toggleAutoclicker();
});
function toggleAutoclicker() {
if (isRunning) {
startStopBtn.textContent = 'Start Clicking';
} else {
startStopBtn.textContent = 'Stop Clicking';
}
const intervalV = parseInt(document.getElementById('interval').value, 10) || 1;
console.log(intervalV)
window.electron.toggleAutoclicker(intervalV);
isRunning = !isRunning;
}