logo bannerlogo banner
Page Navigator

In the browser, you import yolkbot using either:

  1. Dynamic import (<script type="module"> tags)
  2. Global import (window.yolkbot) (Tampermonkey)

Dynamic Import

Dynamic import is the preferred method of importing yolkbot in the browser. It allows you to import only the parts you need, and it works with modern browsers.

let { Bot, Enums: { Intents } } = await import('https://yolkbot.xyz/browser/module');

This must be placed in a script with the type="module" specifier in your HTML file like so:

<script type="module">
    let { Bot, Enums: { Intents } } = await import('https://yolkbot.xyz/browser/module');
    let bot = new Bot();
    bot.on('gameReady', () => {
        bot.emit('saveLoadout', { gunId: 1 }); // switch to scrambler
        bot.emit('spawn');
    });
    bot.join('my bot name', 'game-code-here');
</script>

Global Import

If you want to use yolkbot in a global context, you can import it using a <script> tag. This will make yolkbot available globally as window.yolkbot.

<script src="https://yolkbot.xyz/browser/global.js"></script>

<script>
    let bot = new window.yolkbot.Bot();
    bot.on('gameReady', () => {
        bot.emit('saveLoadout', { gunId: 1 }); // switch to scrambler
        bot.emit('spawn');
    });
    bot.join('my bot name', 'game-code-here');
</script>

To use the Global Import in Tampermonkey, you can use the @require directive in your Tampermonkey script:

// ==UserScript==
// @name         My Yolkbot Script
// @description  A script that uses yolkbot
// @author       You
// @require      https://yolkbot.xyz/browser/global.js

Import List

In the global import, you can check window.yolkbot for all available imports:

console.log(window.yolkbot);

In the module import, you can import it as the toplevel identifier "yolkbot" for all imports:

let yolkbot = await import('https://yolkbot.xyz/browser/module');
console.log(yolkbot);

Disabled Browser Features

Some features are disabled in the browser due to browser-based limitations:

  • Proxies; these are unfortunately not supported inside of the browser
  • The COSMETIC_DATA intent; adding this would add another megabyte to the download size of the library
  • Map caching; this isn't viable in the long-term for storage reasons