Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Monkey-patching любых функций с автоматической очисткой
stop()
const unpatch = api.Patcher.before(object, 'method', (args) => { args[0] = args[0].toUpperCase(); // модифицируем аргументы на месте })
const unpatch = api.Patcher.after(object, 'method', (args, ret) => { return ret + 1; // undefined — оригинальный результат сохраняется })
undefined
const unpatch = api.Patcher.instead(object, 'method', (args, original) => { return original(...args) + '!'; })
const unpatch = api.Patcher.after(obj, 'method', fn); unpatch(); // снимает только этот патч
api.Patcher.unpatchAll() // снять все патчи плагина вручную
api.Patcher.before(obj, 'add', (args) => { args[0] *= 10; }); api.Patcher.after(obj, 'add', (args, ret) => ret + 1000); // obj.add(2, 3): before 2→20, orig 20+3=23, after 23+1000=1023
BYM.register({ id: 'nav-logger' }, (api) => ({ start() { api.Patcher.after(window.history, 'pushState', (args) => { api.Logger.log('Переход:', args[2]); }); }, stop() {}, }));