Skip to content

Commit 62661bf

Browse files
committed
style: lint code
1 parent 4013266 commit 62661bf

File tree

5 files changed

+711
-693
lines changed

5 files changed

+711
-693
lines changed

.eslintrc.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
"es2020": true,
55
"node": true
66
},
7-
"extends": "eslint:recommended",
7+
"parser": "@typescript-eslint/parser",
8+
"plugins": ["@typescript-eslint"],
9+
"extends": [
10+
"eslint:recommended",
11+
"plugin:@typescript-eslint/eslint-recommended",
12+
"plugin:@typescript-eslint/recommended"
13+
],
814
"parserOptions": {
915
"ecmaVersion": 11,
1016
"sourceType": "module"
@@ -14,7 +20,7 @@
1420
"no-global-assign": ["off"],
1521
"no-control-regex": ["off"],
1622
"no-empty": ["warn"],
17-
"no-unused-vars": ["warn"],
23+
"no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
1824
"no-var": ["error"],
1925
"no-unneeded-ternary": ["error"],
2026
"one-var": [

README.md

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
---
66

77
# INSTALLATION
8+
89
1. Make sure you have a script manager such as https://www.tampermonkey.net/
910
2. Come back to this page and press the green install button.
1011

@@ -23,21 +24,23 @@
2324
---
2425

2526
## Features
26-
* Remove all bots with a similarity rating of 60%
27-
* You can set the similarity in the config. Lower numbers = more strict
28-
* Extend Kahoot! questions by a few seconds to help with stream delay.
29-
* Prevent answers that happen before 0.5 seconds after the question starts
30-
* Ensure names are generated by Kahoot! when using the friendly nickname option
31-
* Block many naming formats that bots use.
32-
* Block common bots in team mode
33-
* Prevent brute forcing the two-step code
34-
* Auto-lock your game when you get spammed with bots. Automatically unlocks after one minute.
35-
* Auto-start your game when auto-progress is enabled. This will start the quiz if a player joins the lobby after the specified amount of time to prevent a never ending lobby.
36-
* Counter cheating!
37-
* Add a CAPTCHA to stop even more bots!
38-
* Change the two-factor authentification time!
27+
28+
- Remove all bots with a similarity rating of 60%
29+
- You can set the similarity in the config. Lower numbers = more strict
30+
- Extend Kahoot! questions by a few seconds to help with stream delay.
31+
- Prevent answers that happen before 0.5 seconds after the question starts
32+
- Ensure names are generated by Kahoot! when using the friendly nickname option
33+
- Block many naming formats that bots use.
34+
- Block common bots in team mode
35+
- Prevent brute forcing the two-step code
36+
- Auto-lock your game when you get spammed with bots. Automatically unlocks after one minute.
37+
- Auto-start your game when auto-progress is enabled. This will start the quiz if a player joins the lobby after the specified amount of time to prevent a never ending lobby.
38+
- Counter cheating!
39+
- Add a CAPTCHA to stop even more bots!
40+
- Change the two-factor authentification time!
3941

4042
###                Join us!
43+
4144
<table style="border: solid 0.1rem black">
4245
<tbody>
4346
<tr>
@@ -57,58 +60,60 @@
5760

5861
Sometimes, just an antibot is not enough... Here are ways to prevent bots from joining your games to the best of your ability
5962

60-
* **Enable Friendly Names** - This limits what names can be used, making the antibot more powerful
61-
* **Enable 2FA** - Some bots try to brute force this. The Antibot detects this and can block them.
62-
* **Enable Team Mode** - While team mode no longer prevents most bots from joining, it can help filter out some bots that use the same patters for teams. Some bots may still not support team mode, so this will help.
63+
- **Enable Friendly Names** - This limits what names can be used, making the antibot more powerful
64+
- **Enable 2FA** - Some bots try to brute force this. The Antibot detects this and can block them.
65+
- **Enable Team Mode** - While team mode no longer prevents most bots from joining, it can help filter out some bots that use the same patters for teams. Some bots may still not support team mode, so this will help.
6366

6467
---
6568

6669
## Features planned:
67-
* More Blocking Options (When new botting patterns are found).
68-
* Prevent answers during team talk
70+
71+
- More Blocking Options (When new botting patterns are found).
72+
- Prevent answers during team talk
6973

7074
## Support for other play.kahoot.it scripts
7175

7276
KAntibot v4 works alongside other kahoot scripts normally, meaning you do not have to add your code to an array.
7377

74-
* You can check if the antibot version is 4+ using `window.kantibotVersion` variable.
75-
* Scripts using `window.antibotAdditionalScripts` will be executed by the antibot, but it is deprecated.
76-
* The `window.antibotAdditionalReplacements` feature is no longer supported, as KAntibot does not directly patch the JS code.
78+
- You can check if the antibot version is 4+ using `window.kantibotVersion` variable.
79+
- Scripts using `window.antibotAdditionalScripts` will be executed by the antibot, but it is deprecated.
80+
- The `window.antibotAdditionalReplacements` feature is no longer supported, as KAntibot does not directly patch the JS code.
7781

7882
To detect if the antibot is active, you can check for the `window.kantibotEnabled` variable (v3.0.0+)
7983

8084
### Retrieving Kahoot Internals
8185

8286
If you would like to make scripts that access various internals without interfering with KAntibot, you can use methods such as `window.kantibotAddHook`.
8387

84-
* Hooks are made of 3 parts:
85-
* A property name
86-
* A filter
87-
* A callback
88-
* The hook listens for when certain properties of any object is set to something
89-
* The filter is a function that takes the value of the property and returns true if the callback should be called
90-
* The callback is called when the filter returns true, and is passed the value of the property, which can be used however the developer requires.
91-
* If it returns true, the hook will be removed after completion, otherwise it will remain active.
88+
- Hooks are made of 3 parts:
89+
- A property name
90+
- A filter
91+
- A callback
92+
- The hook listens for when certain properties of any object is set to something
93+
- The filter is a function that takes the value of the property and returns true if the callback should be called
94+
- The callback is called when the filter returns true, and is passed the value of the property, which can be used however the developer requires.
95+
- If it returns true, the hook will be removed after completion, otherwise it will remain active.
9296

9397
**Example:**
9498

9599
```js
96100
window.kantibotAddHook({
97101
prop: "example",
98-
condition: function(target, value) {
102+
condition: function (target, value) {
99103
return value === "test";
100104
},
101-
callback: function(target, value) {
105+
callback: function (target, value) {
102106
console.log("The object the property is put on is", target);
103107
console.log("The example property is set to", value);
104108
return true;
105-
}
109+
},
106110
});
107111
```
108112

109113
---
110114

111115
### Contributors and Sources
112-
* [Compare Strings Javascript Return %of Likely - Stackoverflow](https://stackoverflow.com/questions/10473745/compare-strings-javascript-return-of-likely)
113-
* [epicmines33](https://www.youtube.com/channel/UCLlz8OJpHO_9XxKWOcWksew)
114-
* [stevehainesfib](https://www.youtube.com/channel/UCRYSmku_9-SYRnxcDEa5AIA)
116+
117+
- [Compare Strings Javascript Return %of Likely - Stackoverflow](https://stackoverflow.com/questions/10473745/compare-strings-javascript-return-of-likely)
118+
- [epicmines33](https://www.youtube.com/channel/UCLlz8OJpHO_9XxKWOcWksew)
119+
- [stevehainesfib](https://www.youtube.com/channel/UCRYSmku_9-SYRnxcDEa5AIA)

dist/kahoot-antibot.user.js

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ const METHODS = {
421421
editDistance(s1, s2) {
422422
s1 = s1.toLowerCase();
423423
s2 = s2.toLowerCase();
424-
const costs = new Array();
424+
const costs = [];
425425
for (let i = 0; i <= s1.length; i++) {
426426
let lastValue = i;
427427
for (let j = 0; j <= s2.length; j++) {
@@ -713,8 +713,7 @@ const SEND_CHECKS = [
713713
});
714714
}
715715
},
716-
];
717-
const RECV_CHECKS = [
716+
], RECV_CHECKS = [
718717
function ddosCheck() {
719718
if (!METHODS.isLocked() &&
720719
!kantibotData.runtimeData.lockingGame &&
@@ -1047,7 +1046,8 @@ const RECV_CHECKS = [
10471046
function lobbyAutoStartCheck(socket, data) {
10481047
if (!METHODS.isEventJoinEvent(data))
10491048
return !BOT_DETECTED;
1050-
if (kantibotData.kahootInternals.services.game.navigation.page === "lobby" &&
1049+
if (kantibotData.kahootInternals.services.game.navigation.page ===
1050+
"lobby" &&
10511051
METHODS.getKahootSetting("automaticallyProgressGame") &&
10521052
METHODS.getSetting("start_lock") !== 0) {
10531053
if (kantibotData.runtimeData.lobbyLoadTime === 0) {
@@ -1146,9 +1146,7 @@ for (const setting in localConfig) {
11461146
}
11471147
}
11481148
function injectAntibotSettings(target) {
1149-
const lastIndex = target.children.length - 1;
1150-
const antibotIndex = lastIndex - 2;
1151-
const lastItem = target.children[lastIndex];
1149+
const lastIndex = target.children.length - 1, antibotIndex = lastIndex - 2, lastItem = target.children[lastIndex];
11521150
if (typeof lastItem.type === "function" &&
11531151
lastItem.props?.text?.id ===
11541152
"player.components.game-options-menu.unableToResetToDefaultsInGame") {
@@ -1158,8 +1156,7 @@ function injectAntibotSettings(target) {
11581156
antibotItem.props?.id === "kantibot-settings") {
11591157
return;
11601158
}
1161-
const { createElement } = window.React;
1162-
const settings = [
1159+
const { createElement } = window.React, settings = [
11631160
KAntibotSettingComponent({
11641161
title: "Block Fast Answers",
11651162
inputType: "checkbox",
@@ -1265,27 +1262,20 @@ function injectAntibotSettings(target) {
12651262
inputType: "checkbox",
12661263
id: "counterCheats",
12671264
description: "Adds an additional 5 second question at the end to counter cheats.",
1268-
onChange() {
1269-
// alert("This feature may only be applied upon reload.");
1270-
},
12711265
}),
12721266
KAntibotSettingComponent({
12731267
title: "Enable CAPTCHA",
12741268
inputType: "checkbox",
12751269
id: "enableCAPTCHA",
12761270
description: "Adds a 30 second poll at the start of the quiz. If players don't answer it correctly, they get banned.",
1277-
onChange() {
1278-
// alert("This feature may only be applied upon reload.");
1279-
},
12801271
}),
12811272
KAntibotSettingComponent({
12821273
title: "Reduce False Positives",
12831274
inputType: "checkbox",
12841275
id: "reduceFalsePositives",
12851276
description: "Reduces false positives by making the antibot less strict.",
12861277
}),
1287-
];
1288-
const antibotSettingsContainer = createElement("div", { id: "kantibot-settings" }, createElement("div", { className: "kantibot-settings-header" }, `KAntibot v${KANTIBOT_VERSION} by theusaf`), ...settings);
1278+
], antibotSettingsContainer = createElement("div", { id: "kantibot-settings" }, createElement("div", { className: "kantibot-settings-header" }, `KAntibot v${KANTIBOT_VERSION} by theusaf`), ...settings);
12891279
// Inject the antibot settings
12901280
target.children.splice(antibotIndex + 1, 0, antibotSettingsContainer);
12911281
}
@@ -1492,7 +1482,7 @@ const KANTIBOT_HOOKS = {
14921482
};
14931483
}
14941484
if (websocketMessageReceiveVerification(socket, message) === !BOT_DETECTED) {
1495-
return value.call(this, ...arguments);
1485+
return value.call(this, socket, message);
14961486
}
14971487
};
14981488
return true;
@@ -1523,12 +1513,7 @@ const KANTIBOT_HOOKS = {
15231513
target.core = function (input, payload) {
15241514
if (payload.type === "player/answers/RECORD_CONTROLLER_ANSWERS") {
15251515
for (let i = 0; i < payload.payload.answers.length; i++) {
1526-
const answerData = payload.payload.answers[i];
1527-
const receivedTime = answerData.answerStats.receivedTime;
1528-
const additionalTime = METHODS.getSetting("teamtimeout") * 1000;
1529-
const actualQuestiontime = kantibotData.runtimeData.currentQuestionActualTime;
1530-
const actualTimeRemaining = receivedTime + additionalTime;
1531-
const timeMultiplier = actualQuestiontime / (actualQuestiontime + additionalTime);
1516+
const answerData = payload.payload.answers[i], receivedTime = answerData.answerStats.receivedTime, additionalTime = METHODS.getSetting("teamtimeout") * 1000, actualQuestiontime = kantibotData.runtimeData.currentQuestionActualTime, actualTimeRemaining = receivedTime + additionalTime, timeMultiplier = actualQuestiontime / (actualQuestiontime + additionalTime);
15321517
answerData.answerStats.receivedTime =
15331518
actualTimeRemaining * timeMultiplier;
15341519
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kantibot",
3-
"version": "4.0.0",
3+
"version": "4.2.0",
44
"description": "Remove all bots from a kahoot game.",
55
"main": "index.js",
66
"scripts": {
@@ -12,6 +12,8 @@
1212
"devDependencies": {
1313
"@types/react": "^18.2.21",
1414
"@types/tampermonkey": "^4.20.1",
15+
"@typescript-eslint/eslint-plugin": "^6.5.0",
16+
"@typescript-eslint/parser": "^6.5.0",
1517
"typescript": "^5.2.2"
1618
}
1719
}

0 commit comments

Comments
 (0)