Blooket Random Game

this may or may not be bannable lol!

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Blooket Random Game
// @namespace    http://fb.blooket.com/c/firebase/id
// @version      0.6
// @description  this may or may not be bannable lol!
// @author       not-made-by-konz-but-give-konz-credit
// @match        fb.blooket.com/c/firebase/id*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=blooket.com
// @grant        none
// ==/UserScript==

function load() {
    if (document.body.innerHTML.includes('"success":')) {
        init();
    } else {
        setTimeout(load, 1); // Check again in 100ms
    }
}

load();

function init(){
if (document.body.innerHTML.includes('"success":')) {
const urlParams = new URLSearchParams(window.location.search);
const id = urlParams.get('id');
if (window.location.href.startsWith('https://fb.blooket.com/c/firebase/id') && document.body.innerHTML.includes('"success":true')) {
    window.location.href = `https://play.blooket.com/play?id=${id}`;
}
   else {
       document.body.innerHTML = "";
    const randomCode = Math.floor(1000000 + Math.random() * 9000000);
    console.log('Random code:', randomCode);
    window.location.href = `id?id=${randomCode}&&timestamp=${Date.now()}`;
    location.refresh();
   }
}
};