You could use .ajaxComplete
, as mentioned by @onetrickpony in https://wordpress.stackexchange.com/a/36597/57034, except do it globally on document, as mentioned in http://api.jquery.com/ajaxcomplete/, then filter based on action:
add_action( 'admin_print_footer_scripts', function () {
?>
<script type="text/javascript">
jQuery(function ($) {
$(document).ajaxComplete(function (event, xhr, settings) {
var match;
if (typeof settings.data === 'string'
&& /action=set-post-thumbnail/.test(settings.data)
&& xhr.responseJSON && typeof xhr.responseJSON.data === 'string') {
match = /<img[^>]+src="https://wordpress.stackexchange.com/questions/192124/([^"]+)"/.exec(xhr.responseJSON.data);
if (match !== null) {
var image = new Image();
$(image).load(function () {
var colorThief = new ColorThief();
var dominantColor = colorThief.getColor(image);
console.log(dominantColor);
});
image.src = match[1];
}
}
});
});
</script>
<?php
} );