Skip to content

Commit

Permalink
fix: correct counter display selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
theusaf committed Aug 26, 2023
1 parent 05cb6a4 commit a0e213c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
47 changes: 34 additions & 13 deletions dist/kahoot-antibot.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,17 +629,12 @@ const SEND_CHECKS = [
if (data?.data?.id === 5 ||
(data?.data?.id === 10 && data.data.content === "{}")) {
kantibotData.runtimeData.lobbyLoadTime = 0;
const shouldResetData = METHODS.getKahootSetting("requireRejoin");
if (shouldResetData) {
Object.assign(kantibotData.runtimeData, {
controllerData: {},
captchaIds: new Set(),
englishWordDetectionData: new Set(),
controllerNamePatternData: {},
verifiedControllerNames: new Set(),
unverifiedControllerNames: [],
});
}
// Reset some data, which may be stale from previous round.
Object.assign(kantibotData.runtimeData, {
captchaIds: new Set(),
englishWordDetectionData: new Set(),
controllerNamePatternData: {},
});
}
},
function quizStartCheck(socket, data) {
Expand Down Expand Up @@ -692,7 +687,7 @@ const RECV_CHECKS = [
<span class="kantibot-count-desc">Until Unlock</span>`;
counters.append(ddosCounterElement);
const ddosCounterInterval = setInterval(() => {
ddosCounterElement.querySelector(".antibot-count-num").innerHTML = `${--timeLeft}`;
ddosCounterElement.querySelector(".kantibot-count-num").innerHTML = `${--timeLeft}`;
if (timeLeft <= 0) {
clearInterval(ddosCounterInterval);
ddosCounterElement.remove();
Expand Down Expand Up @@ -1011,7 +1006,7 @@ const RECV_CHECKS = [
if (time < 0) {
time = "Please Wait...";
}
container.querySelector(".antibot-count-num").innerHTML = `${time}`;
container.querySelector(".kantibot-count-num").innerHTML = `${time}`;
}, 1e3);
counters.append(container);
kantibotData.runtimeData.startLockElement = container;
Expand Down Expand Up @@ -1039,6 +1034,26 @@ const RECV_CHECKS = [
return !BOT_DETECTED;
},
];
setInterval(function updateStats() {
const unverifiedControllerNames = kantibotData.runtimeData.unverifiedControllerNames, verifiedControllerNames = kantibotData.runtimeData.verifiedControllerNames;
for (const i in unverifiedControllerNames) {
const data = unverifiedControllerNames[i];
if (data.time <= 0 &&
!data.banned &&
!verifiedControllerNames.has(data.name)) {
verifiedControllerNames.add(data.name);
continue;
}
if (data.time <= -20) {
unverifiedControllerNames.splice(+i, 1);
continue;
}
data.time--;
}
}, 1e3);
setInterval(function updateOldKillCount() {
kantibotData.runtimeData.oldKillCount = kantibotData.runtimeData.killCount;
}, 20e3);
function websocketMessageSendHandler(socket, message) {
const data = JSON.parse(message)[0];
for (const check of SEND_CHECKS) {
Expand All @@ -1053,6 +1068,12 @@ function websocketMessageReceiveVerification(socket, message) {
return BOT_DETECTED;
}
}
if (METHODS.isEventJoinEvent(data)) {
kantibotData.runtimeData.controllerData[data.data.cid] = {
loginTime: Date.now(),
twoFactorAttempts: 0,
};
}
return !BOT_DETECTED;
}
const localConfig = JSON.parse(window.localStorage.kantibotConfig ??
Expand Down
4 changes: 2 additions & 2 deletions src/kahoot-antibot.user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ const RECV_CHECKS: ((socket: KWebSocket, data: KSocketEvent) => boolean)[] = [
counters.append(ddosCounterElement);
const ddosCounterInterval = setInterval(() => {
ddosCounterElement.querySelector(
".antibot-count-num"
".kantibot-count-num"
)!.innerHTML = `${--timeLeft}`;
if (timeLeft <= 0) {
clearInterval(ddosCounterInterval);
Expand Down Expand Up @@ -1176,7 +1176,7 @@ const RECV_CHECKS: ((socket: KWebSocket, data: KSocketEvent) => boolean)[] = [
time = "Please Wait...";
}
container.querySelector(
".antibot-count-num"
".kantibot-count-num"
)!.innerHTML = `${time}`;
}, 1e3);
counters.append(container);
Expand Down

0 comments on commit a0e213c

Please sign in to comment.