How can Integrate custom callback with javascript generated via widget

How can I customise the behaviour of this extension/plugin that uses infinite scroll.

I have found this gist however this is adding javascript manually so you have more control on where to place the custom call back code.

The javascript is generated via the yii extension and I dont want to edit the extension incase it get overwritten when updating.

Have you checked RegisterJs? or better organize your js in file and register it with Register JS File Functionality?

If you have multiple stuffs (css, js et al) then checkout Assets