This utility plugin will give a function wrapping method and will send some events.
This plugin is a dependency for almost all plugins.
wrap_func()on_ready()observe_mutations()disconnect_observers()Add this lines in your init.js file (await ensures it finishes before dependents):
await Plugins.load('https://0xaf.github.io/openwebrxplus-plugins/receiver/utils/utils.js');
// load the rest of your plugins here
Learn how to load plugins.
Plugins.utils.wrap_func(name, before_cb, after_cb, obj)Wrap a function and intercept calls before and/or after execution.
Plugins.utils.on_ready(callback)Run callback once OpenWebRX+ has completed initialization.
Plugins.utils.observe_mutations(targets, options, callback, run_now)Create one or more MutationObserver instances with a shared callback.
targets: single node, array, NodeList, or HTMLCollectionoptions: standard MutationObserver.observe() optionscallback(mutationsList, observer, target): called on mutation batchesrun_now: if true, callback is called once immediately per valid targetReturns an array of handles: { observer, target, disconnect }.
Example:
var handles = Plugins.utils.observe_mutations(
[tabEl, rootEl],
{ attributes: true, attributeFilter: ['class'] },
function () {
refreshVisibility();
},
true
);
Plugins.utils.disconnect_observers(handles)Disconnect handles returned by observe_mutations().
Plugins.utils.disconnect_observers(handles);
Code is in the Github repo.