-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
executable file
·76 lines (61 loc) · 2.1 KB
/
content.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
function handleStart() {
const resId1 = parseInt(prompt('Enter the starting RES ID'));
const resId2 = parseInt(prompt('Enter the final RES ID'));
let mode = prompt('Select status: ( confirm, temporary, cancel )');
if (resId1 > resId2) {
alert('ID 1 must be smaller than ID 2!');
} else if (resId1 && resId2 && mode) {
mode = mode.toLowerCase();
if (['confirm', 'temporary', 'cancel'].includes(mode)) {
startAutomate(mode);
} else {
alert('Warning: Invalid Mode Entered!');
}
} else {
alert('Invalid Reservation Id Entry!\n\nOperation Aborted!');
}
async function startAutomate(mode) {
const message = {
status: 200,
resId1,
resId2,
mode,
};
chrome.runtime.sendMessage(message);
}
}
function handleEquip() {
const resId1 = parseInt(prompt('Enter the starting RES ID'));
const resId2 = parseInt(prompt('Enter the final RES ID'));
if (resId1 > resId2) {
alert('ID 1 must be smaller than ID 2!');
} else if (resId1 && resId2) {
const message = {
status: 300,
resId1,
resId2,
};
chrome.runtime.sendMessage(message);
} else {
alert('Invalid Reservation Id Entry!\n\nOperation Aborted!');
}
}
function handleClose() {
chrome.runtime.sendMessage({ status: 'close' });
}
const body = document.querySelector('body');
const startButton = document.createElement('button');
startButton.setAttribute('id', 'status');
startButton.append('Change Status');
const equipButton = document.createElement('button');
equipButton.setAttribute('id', 'equip');
equipButton.append('Add Equipments');
const closeButton = document.createElement('button');
closeButton.setAttribute('id', 'close');
closeButton.append('Close Tabs');
body.appendChild(startButton);
startButton.addEventListener('click', handleStart);
body.appendChild(equipButton);
equipButton.addEventListener('click', handleEquip);
body.appendChild(closeButton);
closeButton.addEventListener('click', handleClose);