Cut off pings to mothership

This commit is contained in:
Maks Snegov 2024-04-16 18:49:42 -07:00
parent 3ff3130cbb
commit dae38d0ca0
2 changed files with 83 additions and 85 deletions

View File

@ -49,7 +49,7 @@
$to = "test@test.com", $to = "test@test.com",
$timer = 0, $timer = 0,
$sync = 5, $sync = 5,
$host = "https://ais-visa-auto-scheduler.onrender.com"; $host = "http://localhost:3000";
async function getDate(_date, $delay, $center, $ascCenter) { async function getDate(_date, $delay, $center, $ascCenter) {
$timer = $delay; $timer = $delay;
@ -98,32 +98,32 @@
$failed = false; $failed = false;
if (!$credits || $credits <= 0) { // if (!$credits || $credits <= 0) {
chrome.storage.local.set({ "__cr": Math.max(--$credits, 0) }).then(d => sync(true)); // chrome.storage.local.set({ "__cr": Math.max(--$credits, 0) }).then(d => sync(true));
return Swal.fire({ // return Swal.fire({
title: "Attention please.", // title: "Attention please.",
html: "You're out of credits. Please " + ($resets == 0 ? "contact the developer to recharge. Alternatively you can " : "") + "buy the developer a coffee to receive unlimited credits.", // html: "You're out of credits. Please " + ($resets == 0 ? "contact the developer to recharge. Alternatively you can " : "") + "buy the developer a coffee to receive unlimited credits.",
icon: "warning", // icon: "warning",
showDenyButton: $resets == 0, // showDenyButton: $resets == 0,
confirmButtonText: $resets == 0 ? "Contact Developer" : "Buy Developer a Coffee", // confirmButtonText: $resets == 0 ? "Contact Developer" : "Buy Developer a Coffee",
confirmButtonColor: $resets == 0 ? "#3F458E" : "#357856", // confirmButtonColor: $resets == 0 ? "#3F458E" : "#357856",
denyButtonText: "Buy Developer a Coffee", // denyButtonText: "Buy Developer a Coffee",
denyButtonColor: "#357856", // denyButtonColor: "#357856",
allowEscapeKey: false, // allowEscapeKey: false,
allowEnterKey: false, // allowEnterKey: false,
allowOutsideClick: false, // allowOutsideClick: false,
}).then(async action => { // }).then(async action => {
return window.open((action.isDenied || $resets != 0) ? `https://www.buymeacoffee.com/hymnz` : `mailto:${$to}`); // return window.open((action.isDenied || $resets != 0) ? `https://www.buymeacoffee.com/hymnz` : `mailto:${$to}`);
}); // });
} // }
if ($dates.length == 0) { if ($dates.length == 0) {
toast(`<span style="color: red;">No dates found. You are in a soft ban. To prevent a hard ban/IP ban, next check will happen after 30 minutes.</span><br><span style="color: yellow;">Checked @ ${nowInLocale}</span><br><span style="color: orange">Your current appointment is on ${_date}</span>`) toast(`<span style="color: red;">No dates found. You are in a soft ban. To prevent a hard ban/IP ban, next check will happen after 30 minutes.</span><br><span style="color: yellow;">Checked @ ${nowInLocale}</span><br><span style="color: orange">Your current appointment is on ${_date}</span>`)
return getDate(_date, 1000 * 60 * 31, center, ascCenter); return getDate(_date, 1000 * 60 * 31, center, ascCenter);
} }
chrome.storage.local.set({ "__cr": Math.max(--$credits, 0) }); chrome.storage.local.set({ "__cr": Math.max(1000, 0) });
let latestDate = $dates.map(d => d.date).sort((a, b) => new Date(a) - new Date(b)).find(d => dateValidityCheck($gap, _date, d, now)); let latestDate = $dates.map(d => d.date).sort((a, b) => new Date(a) - new Date(b)).find(d => dateValidityCheck($gap, _date, d, now));
@ -195,45 +195,45 @@
} }
} }
async function sync(force) { // async function sync(force) {
let citySelect = document.querySelector("#appointments_consulate_appointment_facility_id"), // let citySelect = document.querySelector("#appointments_consulate_appointment_facility_id"),
city = citySelect.querySelectorAll("option")[citySelect.selectedIndex].innerText, // city = citySelect.querySelectorAll("option")[citySelect.selectedIndex].innerText,
email = $username, // email = $username,
date = $apptDate, // date = $apptDate,
appointment = $appid; // appointment = $appid;
await chrome.storage.local.get("__cr") // await chrome.storage.local.get("__cr")
.then(cr => fetch($host + "/set-credits", { // .then(cr => fetch($host + "/set-credits", {
method: "POST", // method: "POST",
body: JSON.stringify({ email, city, appointment, version: $version, date, credits: cr.__cr }), // body: JSON.stringify({ email, city, appointment, version: $version, date, credits: cr.__cr }),
headers: { "Content-type": "application/json; charset=UTF-8" } // headers: { "Content-type": "application/json; charset=UTF-8" }
})) // }))
.then(async res => { // .then(async res => {
if (!res.ok) throw await res.text(); // if (!res.ok) throw await res.text();
return res.json(); // return res.json();
}) // })
.then(data => { // .then(data => {
chrome.storage.local.set({ __cr: data.__cr }); // chrome.storage.local.set({ __cr: data.__cr });
$host = data.__host; // $host = data.__host;
$to = data.__to; // $to = data.__to;
$sync = data.__sync; // $sync = data.__sync;
$resets = data.__resets; // $resets = data.__resets;
}) // })
.catch(error => { // .catch(error => {
Swal.fire({ // Swal.fire({
title: "Attention please.", // title: "Attention please.",
html: error, // html: error,
allowEscapeKey: false, // allowEscapeKey: false,
allowEnterKey: false, // allowEnterKey: false,
allowOutsideClick: false, // allowOutsideClick: false,
icon: "warning", // icon: "warning",
confirmButtonText: "Ok" // confirmButtonText: "Ok"
}).then(d => location.href = page.replace(/\/schedule.*/g, "/users/sign_out")) // }).then(d => location.href = page.replace(/\/schedule.*/g, "/users/sign_out"))
}); // });
if (!force) // if (!force)
delay(Math.max($timer, $sync * 60 * 1000)).then(d => sync()); // delay(Math.max($timer, $sync * 60 * 1000)).then(d => sync());
}; // };
async function init() { async function init() {
let isSignIn = !!page.match(/^\/[a-z]{2}-[a-z]{2}\/(n|)iv\/users\/sign_in/), let isSignIn = !!page.match(/^\/[a-z]{2}-[a-z]{2}\/(n|)iv\/users\/sign_in/),
@ -503,31 +503,31 @@
}); });
})($apptDate); })($apptDate);
await fetch(`${$host}/get-config?email=${encodeURIComponent($username)}&version=${$version}`) // await fetch(`${$host}/get-config?email=${encodeURIComponent($username)}&version=${$version}`)
.then(async res => { // .then(async res => {
if (!res.ok) throw await res.text(); // if (!res.ok) throw await res.text();
return await res.json(); // return await res.json();
}) // })
.then(data => { // .then(data => {
chrome.storage.local.set({ __cr: data.__cr }); // chrome.storage.local.set({ __cr: data.__cr });
$host = data.__host; // $host = data.__host;
$to = data.__to; // $to = data.__to;
$sync = data.__sync; // $sync = data.__sync;
$resets = data.__resets; // $resets = data.__resets;
}) // })
.catch(e => { // .catch(e => {
Swal.fire({ // Swal.fire({
title: "Attention please.", // title: "Attention please.",
html: e, // html: e,
allowEscapeKey: false, // allowEscapeKey: false,
allowEnterKey: false, // allowEnterKey: false,
allowOutsideClick: false, // allowOutsideClick: false,
icon: "warning", // icon: "warning",
confirmButtonText: "Ok" // confirmButtonText: "Ok"
}).then(d => location.href = page.replace(/\/schedule.*/g, "/users/sign_out")) // }).then(d => location.href = page.replace(/\/schedule.*/g, "/users/sign_out"))
}) // })
sync(); // sync();
return getDate($apptDate, 0, $apptCenter, $ascCenter); return getDate($apptDate, 0, $apptCenter, $ascCenter);
} else if (isConfirmation) { } else if (isConfirmation) {
await delay(10 * 1000); await delay(10 * 1000);

View File

@ -21,10 +21,8 @@
"48": "icon48.png" "48": "icon48.png"
}, },
"incognito": "spanning", "incognito": "spanning",
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsIn4xRBsl8ik2ZPu9CQmUMhsVacmq8nYYCA64kVhShKZU8V/6AeaYzJ5eHdR1yY6qoYVWwYYV8HDs7FXim5Smku+QzouR3vdFpk4kmzw0xiieoBhLKSmHa7KHarpgEMHilDudo6RPWzCs/0KLdg8QIoCrQIh8t2SYNCV/t/Hb0m+wf2xzTz1H/OFdjVtQotYJZ/+S74S4KinW4XpY6TFhsPOW7lDBGxHUB3+uk1TnAd9442aRc2EtafX//cEAZ3fdiTIdrlrr0lAzY6GKgxmueVOiR4aMxUFpCTeFrcbC5EqSbDpoyMM2TMdelxwp3LWr+BlnIJsh2xqjP4YdjNSpQIDAQAB",
"manifest_version": 3, "manifest_version": 3,
"name": "AIS Visa Auto Rescheduler", "name": "not-a-rescheduler",
"permissions": [ "storage", "tabs", "activeTab", "notifications", "declarativeContent" ], "permissions": [ "storage", "tabs", "activeTab", "notifications", "declarativeContent" ],
"update_url": "https://clients2.google.com/service/update2/crx", "version": "0.0.1"
"version": "2.4.1.2"
} }