-
Notifications
You must be signed in to change notification settings - Fork 2
/
popup.js
34 lines (32 loc) · 1.28 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
const buttons = {
'allConsultation': 'allConsultation',
'tpebis': 'tpebis',
// Ajoutez d'autres boutons ici
'sendNotif': 'sendNotif',
'sendCustomAmount': 'sendCustomAmount',
};
for (let id in buttons) {
document.getElementById(id).addEventListener('click', function() {
console.log(id + " clicked");
if (id === 'sendCustomAmount') {
let customAmount = document.getElementById('customAmount').value;
if (customAmount) {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {action: buttons[id], amount: customAmount});
});
console.log(buttons[id] + " message sent with amount: " + customAmount);
} else if (id === 'sendNotif') {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {action: buttons[id]});
});
} else {
console.log("No amount entered");
}
} else {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {action: buttons[id]});
});
console.log(buttons[id] + " message sent");
}
});
}