In the browser, you import yolkbot using either:
<script type="module"> tags)window.yolkbot) (Tampermonkey)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>
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
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);
Some features are disabled in the browser due to browser-based limitations:
COSMETIC_DATA intent; adding this would add another megabyte to the download size of the libraryIn the browser, you import yolkbot using either:
<script type="module"> tags)window.yolkbot) (Tampermonkey)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>
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
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);
Some features are disabled in the browser due to browser-based limitations:
COSMETIC_DATA intent; adding this would add another megabyte to the download size of the library