-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
60 lines (53 loc) · 1.75 KB
/
popup.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
document.addEventListener('DOMContentLoaded', () => {
const toggleButton = document.getElementById('toggle');
const statusDisplay = document.getElementById('status');
let isClicking = false;
chrome.runtime.sendMessage({ action: 'getState' }, (response) => {
isClicking = response.isClicking;
updateUI();
});
toggleButton.addEventListener('click', () => {
isClicking = !isClicking;
chrome.runtime.sendMessage({ action: 'setState', isClicking: isClicking });
updateUI();
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
if (tabs[0]) {
chrome.scripting.executeScript({
target: { tabId: tabs[0].id },
function: toggleClicking,
args: [isClicking]
}, () => {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError);
}
});
} else {
console.error('No active tab found');
}
});
});
function updateUI() {
statusDisplay.textContent = `STATUS: ${isClicking ? 'KLIKAEM' : 'STOPAEM'}`;
toggleButton.textContent = isClicking ? 'STOPAY' : 'STARTUY';
}
});
function toggleClicking(isClicking) {
function clickPassButton() {
const buttons = document.querySelectorAll('button');
for (const button of buttons) {
if (button.textContent.trim() === 'Pass') {
button.click();
console.log('Pass button clicked!');
return;
}
}
console.log('Pass button not found!');
}
if (isClicking) {
window.clickerInterval = setInterval(() => {
clickPassButton();
}, 1000);
} else {
clearInterval(window.clickerInterval);
}
}