function fetchPageAssets(){ var downloader = $("") $(".ui-title-bar").append(downloader) var assets = $("#assets-table .next-input--readonly") assets.each(function(index, input) { $('#download-file').attr('href', input.value); $('#download-file')[0].click(); if (index + 1 == assets.length) { var lastItem = $(input).parents("tr[bind-class]").attr('bind-class').substring(25,36) $.ajax({ url: "/admin/settings/files?direction=next&last_id="+lastItem+"&last_value="+ lastItem+"&limit=100&order=id+desc", }).done(function(data) { var mutationObserver = new MutationObserver(function(mutations, observer) { mutations.forEach(function(mutation) { if (mutation.target.id && mutation.target.id == "assets-table") { fetchPageAssets() observer.disconnect() } }) }); mutationObserver.observe(document, { childList: true, subtree: true }); var newDoc = document.open("text/html", "replace"); newDoc.write(data); newDoc.close(); }) } }) } fetchPageAssets()