Add autobook feature
This commit is contained in:
parent
bdf4b5a7c4
commit
9f5fa888ef
@ -64,6 +64,14 @@
|
||||
<input type="number" class="form-control" id="deltaNow" placeholder="days">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="form-check form-switch" style="text-align: left;">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="autobook">
|
||||
<label class="form-check-label" for="autobook">Autobook</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p>Status: <span id="status">Inactive</span></p>
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
document.getElementById("status").innerText = items["__status"] || "unknown";
|
||||
document.getElementById("deltaAppt").value = items["__deltaAppt"] || 1;
|
||||
document.getElementById("deltaNow").value = items["__deltaNow"] || 1;
|
||||
document.getElementById("autobook").checked = items["__autobook"] || false;
|
||||
});
|
||||
|
||||
chrome.storage.onChanged.addListener((changes, area) => {
|
||||
@ -22,6 +23,9 @@
|
||||
document.getElementById("activate").addEventListener("change", async e => {
|
||||
await chrome.storage.local.set({ "__activate": e.target.checked });
|
||||
});
|
||||
document.getElementById("autobook").addEventListener("change", async e => {
|
||||
await chrome.storage.local.set({ "__autobook": e.target.checked });
|
||||
});
|
||||
|
||||
// credentials
|
||||
let usernameField = document.getElementById("username");
|
||||
|
||||
@ -20,6 +20,7 @@ let config = {
|
||||
consulates: null,
|
||||
deltaAppt: null,
|
||||
deltaNow: null,
|
||||
autobook: null,
|
||||
};
|
||||
let isRunning = false;
|
||||
|
||||
@ -168,6 +169,7 @@ async function runner() {
|
||||
config.consulates = result['__consulates'] || null;
|
||||
config.deltaAppt = result['__deltaAppt'] || 1;
|
||||
config.deltaNow = result['__deltaNow'] || 1;
|
||||
config.autobook = result['__autobook'] || false;
|
||||
|
||||
if (prev_config.activate === null) {
|
||||
console.log('Reading config: ' + JSON.stringify(config));
|
||||
@ -430,8 +432,16 @@ async function runner() {
|
||||
document.getElementById("appointments_submit").removeAttribute("disabled");
|
||||
document.getElementById("appointments_submit").click();
|
||||
|
||||
await sendNotification(`Found better appointment in ${consulate} at ${chosenDate} ${chosenTime}`);
|
||||
}
|
||||
msg = `Found better appointment in ${consulate} at ${chosenDate} ${chosenTime}`;
|
||||
console.log(msg);
|
||||
await sendNotification(msg);
|
||||
|
||||
if (config.autobook) {
|
||||
await delay(PAGE_WAIT_TIME);
|
||||
console.log('Auto booking');
|
||||
document.querySelector(".reveal-overlay:last-child [data-reveal] .button.alert").click();
|
||||
}
|
||||
} // end consulates loop
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user