Is it the page refresh that’s causing the issue, or do you simply want to save the post before it refreshes? If the later then It’s simple enough with js to check if a condition has changed (ie a button click) in the dom and then:
jQuery("input#save-post").click().prop('disabled', true);
This will of course trigger a full page refresh. You may have to hijack the ‘Insert selected Images’ button’s default behavior altogether to negotiate a possible race condition with the page refresh automatically.