Browser Use
yolkbot can be used in the browser!
yolkbot can be used in the browser, which allows you to use the biggest parts of yolkbot!
yolkbot is now bundled in the browser, meaning it only imports one file (under 100kb) for the entire library, making it incredibly efficient.
The only thing that changes between Node.JS and the browser is how modules are imported. Since you can’t directly just import a pacakge name, you have to use a CDN to access it. Our recommended one is esm.sh
. For example:
import Matchmaker from ...
, use let { Matchmaker } = await ...
. This avoids some ugly bugs.Imports in the browser all come from one file, https://esm.sh/yolkbot@latest/browser
, which is the browser bundle of yolkbot.
To import Dispatches, either destructure the dispatches object:
Or import the dispatches object directly and refer to it:
Import List
These are all the things that can be imported.
Somewhat simple.
We Recommend Node
Why?
- The browser is slow. Anything you do will take a long time. This isn’t anything we can control, it’s just how browsers work.
- For example, loading the library takes around 5 seconds before the first code is executed.
- In another example, authorization is around 2x slower.
- The browser is limited.
- For example, you’re unable to use proxies. Browsers just don’t support proxied WebSockets.
- Additionally, whatever scope you run the bots in is ultimately limited in terms of resources. A tab can only use up so much CPU or RAM before most browsers shut it down.
- The browser is insecure.
- If you run the bots on, say, Shell Shockers, you’re allowing Shell Shockers to potentially tamper with the bots or detect your IP botting. (If we ever find the game tampering with bot behavior, we’ll obviously fix it. It’s ultimately just a risk you need to take when running any code on a website.)
- The browser is hard to write in.
- Types and hence the things like intellisense that come with them are not featured in the browser bundle due to the obvious lack of typing support in browsers. This makes writing code harder and more prone to errors.
That being said, the browser still works pretty well. If you’re just testing things out or want to run a bot on a website, the browser is a great way to do it. Just be aware of the limitations and risks.
Removed in the Browser
In the browser edition, the big thing removed is proxy support. The browser can’t use proxies for requests or WebSockets, which removes a (kind of big) feature in yolkbot. If you don’t plan to need proxies, the browser is likely still a good choice.
The other thing that may run into issues is pathfinding. Pathfinding requires sending requests to Shell Shockers to get map information. If you aren’t running this from a Shell Shockers page and instead some external page, the map request will likely be blocked due to CORS. This is a limitation of the browser and not yolkbot. Use an extension like CORS Unblock to get around this.
Happy botting!