Skip to main content

Documentation Index

Fetch the complete documentation index at: https://bym.lonestill.uk/llms.txt

Use this file to discover all available pages before exploring further.

Перехватывает window.fetch. Хуки снимаются при stop() автоматически.
Для запросов во внешние API из плагинов используй api.HTTP. api.Net — для перехвата запросов, которые YM делает сам.

onRequest

const stop = api.Net.onRequest(filter, ({ url, opts }) => { ... })
Вызывается перед отправкой. filter — подстрока URL, null или '' — все запросы.

onResponse

const stop = api.Net.onResponse(filter, async ({ url, status, response }) => { ... })
Вызывается после ответа. response — клон Response, читай через .json() или .text(). YM получает оригинал без изменений.

Пример

BYM.register({ id: 'api-spy' }, (api) => ({
  start() {
    api.Net.onResponse('/api/v2.1/handlers/track', async ({ status, response }) => {
      if (status !== 200) return;
      const data = await response.json();
      api.Logger.log('Track data:', data);
    });
  },
  stop() {},
}));