Skip to content

Commit a0e213c

Browse files
committed
fix: correct counter display selectors
1 parent 05cb6a4 commit a0e213c

2 files changed

Lines changed: 36 additions & 15 deletions

File tree

dist/kahoot-antibot.user.js

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -629,17 +629,12 @@ const SEND_CHECKS = [
629629
if (data?.data?.id === 5 ||
630630
(data?.data?.id === 10 && data.data.content === "{}")) {
631631
kantibotData.runtimeData.lobbyLoadTime = 0;
632-
const shouldResetData = METHODS.getKahootSetting("requireRejoin");
633-
if (shouldResetData) {
634-
Object.assign(kantibotData.runtimeData, {
635-
controllerData: {},
636-
captchaIds: new Set(),
637-
englishWordDetectionData: new Set(),
638-
controllerNamePatternData: {},
639-
verifiedControllerNames: new Set(),
640-
unverifiedControllerNames: [],
641-
});
642-
}
632+
// Reset some data, which may be stale from previous round.
633+
Object.assign(kantibotData.runtimeData, {
634+
captchaIds: new Set(),
635+
englishWordDetectionData: new Set(),
636+
controllerNamePatternData: {},
637+
});
643638
}
644639
},
645640
function quizStartCheck(socket, data) {
@@ -692,7 +687,7 @@ const RECV_CHECKS = [
692687
<span class="kantibot-count-desc">Until Unlock</span>`;
693688
counters.append(ddosCounterElement);
694689
const ddosCounterInterval = setInterval(() => {
695-
ddosCounterElement.querySelector(".antibot-count-num").innerHTML = `${--timeLeft}`;
690+
ddosCounterElement.querySelector(".kantibot-count-num").innerHTML = `${--timeLeft}`;
696691
if (timeLeft <= 0) {
697692
clearInterval(ddosCounterInterval);
698693
ddosCounterElement.remove();
@@ -1011,7 +1006,7 @@ const RECV_CHECKS = [
10111006
if (time < 0) {
10121007
time = "Please Wait...";
10131008
}
1014-
container.querySelector(".antibot-count-num").innerHTML = `${time}`;
1009+
container.querySelector(".kantibot-count-num").innerHTML = `${time}`;
10151010
}, 1e3);
10161011
counters.append(container);
10171012
kantibotData.runtimeData.startLockElement = container;
@@ -1039,6 +1034,26 @@ const RECV_CHECKS = [
10391034
return !BOT_DETECTED;
10401035
},
10411036
];
1037+
setInterval(function updateStats() {
1038+
const unverifiedControllerNames = kantibotData.runtimeData.unverifiedControllerNames, verifiedControllerNames = kantibotData.runtimeData.verifiedControllerNames;
1039+
for (const i in unverifiedControllerNames) {
1040+
const data = unverifiedControllerNames[i];
1041+
if (data.time <= 0 &&
1042+
!data.banned &&
1043+
!verifiedControllerNames.has(data.name)) {
1044+
verifiedControllerNames.add(data.name);
1045+
continue;
1046+
}
1047+
if (data.time <= -20) {
1048+
unverifiedControllerNames.splice(+i, 1);
1049+
continue;
1050+
}
1051+
data.time--;
1052+
}
1053+
}, 1e3);
1054+
setInterval(function updateOldKillCount() {
1055+
kantibotData.runtimeData.oldKillCount = kantibotData.runtimeData.killCount;
1056+
}, 20e3);
10421057
function websocketMessageSendHandler(socket, message) {
10431058
const data = JSON.parse(message)[0];
10441059
for (const check of SEND_CHECKS) {
@@ -1053,6 +1068,12 @@ function websocketMessageReceiveVerification(socket, message) {
10531068
return BOT_DETECTED;
10541069
}
10551070
}
1071+
if (METHODS.isEventJoinEvent(data)) {
1072+
kantibotData.runtimeData.controllerData[data.data.cid] = {
1073+
loginTime: Date.now(),
1074+
twoFactorAttempts: 0,
1075+
};
1076+
}
10561077
return !BOT_DETECTED;
10571078
}
10581079
const localConfig = JSON.parse(window.localStorage.kantibotConfig ??

src/kahoot-antibot.user.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ const RECV_CHECKS: ((socket: KWebSocket, data: KSocketEvent) => boolean)[] = [
768768
counters.append(ddosCounterElement);
769769
const ddosCounterInterval = setInterval(() => {
770770
ddosCounterElement.querySelector(
771-
".antibot-count-num"
771+
".kantibot-count-num"
772772
)!.innerHTML = `${--timeLeft}`;
773773
if (timeLeft <= 0) {
774774
clearInterval(ddosCounterInterval);
@@ -1176,7 +1176,7 @@ const RECV_CHECKS: ((socket: KWebSocket, data: KSocketEvent) => boolean)[] = [
11761176
time = "Please Wait...";
11771177
}
11781178
container.querySelector(
1179-
".antibot-count-num"
1179+
".kantibot-count-num"
11801180
)!.innerHTML = `${time}`;
11811181
}, 1e3);
11821182
counters.append(container);

0 commit comments

Comments
 (0)