Hay un poco de información sobre esto aquí:
Javascripts targeting the footer doesn't work after page transitions - #4 by Johani
Cuando usas esto:
api.onAppEvent("inserted-custom-html", () => {
// algún código
});
Debes especificar qué HTML personalizado quieres dirigir; se disparan diferentes eventos según eso.
En este caso, quieres dirigirte al pie de página. ¿Podrías probar esto y ver si funciona para ti?
api.onAppEvent("inserted-custom-html:footer", () => {
// algún código
});