Remove all bots from the player join screen. Simply start a kahoot game and watch as all bots get killed. Does not work on leaderboards currently.
当前为
// ==UserScript==
// @name Kahoot AntiBot
// @namespace http://tampermonkey.net/
// @version 1.1
// @description Remove all bots from the player join screen. Simply start a kahoot game and watch as all bots get killed. Does not work on leaderboards currently.
// @author theusaf
// @match *://play.kahoot.it/*
// @grant none
// ==/UserScript==
window.similarity = function (s1, s2) {
if(!isNaN(s2) && !isNaN(s1)){
return 1;
}
var longer = s1;
var shorter = s2;
if (s1.length < s2.length) {
longer = s2;
shorter = s1;
}
var longerLength = longer.length;
if (longerLength == 0) {
return 1.0;
}
return (longerLength - editDistance(longer, shorter)) / parseFloat(longerLength);
}
window.editDistance = function (s1, s2) {
s1 = s1.toLowerCase();
s2 = s2.toLowerCase();
var costs = new Array();
for (var i = 0; i <= s1.length; i++) {
var lastValue = i;
for (var j = 0; j <= s2.length; j++) {
if (i == 0){
costs[j] = j;
}
else {
if (j > 0) {
var newValue = costs[j - 1];
if (s1.charAt(i - 1) != s2.charAt(j - 1)){
newValue = Math.min(Math.min(newValue, lastValue),costs[j]) + 1;
}
costs[j - 1] = lastValue;
lastValue = newValue;
}
}
}
if (i > 0){
costs[s2.length] = lastValue;
}
}
return costs[s2.length];
}
window.setup1 = function (){
var launch_button = document.querySelectorAll("[data-functional-selector=\"launch-button\"]")[0];
if(launch_button){
console.warn("launch button found!");
launch_button.addEventListener("click",setup2);
}else{
setTimeout(setup1,1000);
}
}
window.setup2 = function (){
var start_button = document.querySelectorAll("[data-functional-selector=\"start-button\"]")[0];
if(start_button){
console.warn("start button found!");
setup3();
}else{
setTimeout(setup2,1000);
}
}
window.setup3 = function (){
let playerList = document.getElementsByClassName("player-list")[0];
let conf = {
childList: true,
subtree: true
};
let observer = new MutationObserver(kill_bots);
observer.observe(playerList,conf);
}
window.onload = setup1;
window.cachedUsernames = [];
window.kill_bots = function (e,observer){
console.warn("determining evil now. be warned.");
if(document.getElementsByClassName("player-list").length == 0){
observer.disconnect();
return;
}
let players = document.querySelectorAll("[data-functional-selector=\"player\"]");
for(let i in players){
if(cachedUsernames.length == 0){
cachedUsernames.push({element:players[i],text:players[i].innerText,clicked:false});
continue;
}
for(let k in cachedUsernames){
if(cachedUsernames[k].element == players[i]){
continue;
}
if(similarity(cachedUsernames[k].text,players[i].innerText) >= 0.60){
players[i].click();
if(!cachedUsernames[k].clicked){
cachedUsernames[k].element.click();
cachedUsernames[k].clicked = true;
}
break;
}
}
cachedUsernames.push({element:players[i],text:players[i].innerText,clicked:false});
}
};