YouTube-Music-BOOM-Radio

default icon of this template

BetterYTM Plugin Template

– compatible with BYTM v2.2.0


Table of Contents:


Introduction:

BetterYTM is a UserScript that enhances the YouTube and YouTube Music experience by adding features and fixing bugs. It has a plugin system that allows you to create your own plugins to further customize the experience and make use of its API.
This template is perfect for anyone who wants to create a plugin for BetterYTM but doesn’t want to deal with the hassle of setting up a working development environment.

BetterYTM (BYTM for short) is included as a Git submodule to ensure that both projects’ versions stay compatible until you decide to update your plugin.
This also conveniently allows you to inspect BetterYTM’s code for finding specific details about the API and even more conveniently, allows you to navigate through to the BYTM API by ctrl+clicking on imported members.
Just make sure to read the plugin sublicense to find out which parts you are allowed to include in your plugin’s bundle in dist/.
If you only import with the type keyword (or without, when importing enums), you should be fine.

The plugin will be built with Vite and pnpm and written in TypeScript to provide a modern and lightning fast development experience.
You may also import plain JavaScript files (with the extension .mjs) if you prefer that instead.

It is also set up to be easily hosted on a local server for testing and to be built for production with a single command.
If you use a UserScript manager extension such as Violentmonkey, you can easily test the plugin by opening the local server URL in your browser.
The extension will keep updating the userscript automatically when any changes are made, as long as you clicked the “track external edits” button.
Configure this behavior in the nodemonConfig object in package.json and src/tools/serve.ts.

The library UserUtils is also included to provide a plethora of useful functions and classes for UserScripts.
I highly recommend checking it out! It is included on the BYTM API via unsafeWindow.BYTM.UserUtils.

[!NOTE]
If your plugin is published, send me a quick E-Mail or message on Discord so I can add it to the BetterYTM Plugin List.
You can also contact me for questions and help or to request features to be exposed on the API.

Have fun creating your plugin!


Prerequisites


Setup

  1. Install Node.js (current version or LTS) and pnpm (can be done with npm i -g pnpm)
  2. Create a repository based on this template.
  3. Clone the repository to your local machine.
  4. Use git submodule update --init --recursive to clone the BetterYTM submodule.
  5. Copy .env.template to .env and modify it to your needs.
  6. Install BetterYTM from the releases page.
    If you wanna prepare your code for the latest version that’s still in development, check out the latest pull request for the download and changelog.
  7. Open a terminal in the project root and run pnpm i to install dependencies.
  8. Run pnpm run dev to build the plugin and host it on a local server for testing.
    Open this URL with your UserScript manager extension to easily test the plugin.
    I recommend using Violentmonkey, which will automatically update the userscript when any changes are made.

Refer to the commands section for more information on the available commands.


Inner Workings:

File structure:


Tips and Notes:


Commands


License

This project (minus Git submodules) is licensed under the WTFPL - do whatever you want with it.
It is based on BetterYTM, which itself is licensed under the AGPL-3.0 license.

Make sure to include this in your plugin’s readme to comply with BetterYTM’s plugin sublicense.