Wordpress - How can I get a list of all enqueued scripts and styles?

do_action doesn't quite work like that. When you call do_action('crunchify_print_scripts_styles') WP looks at its list of registered actions and filters for any that are attached to a hook called crunchify_print_scripts_styles and then runs those functions.

And you probably want to remove this:

add_action( 'wp_enqueue_scripts', 'crunchify_print_scripts_styles');

... because you aren't able to get the return result of your function.

Also when you use this particular hook you can't guarantee that other functions don't enqueue more scripts or styles after you've generated your list. Use a hook that fires after all scripts and styles have been enqueued, such as wp_head, for convenience, or better still just call your function within your theme when you want to display the result.

Reworking your code like this should work...

function crunchify_print_scripts_styles() {

    $result = [];
    $result['scripts'] = [];
    $result['styles'] = [];

    // Print all loaded Scripts
    global $wp_scripts;
    foreach( $wp_scripts->queue as $script ) :
       $result['scripts'][] =  $wp_scripts->registered[$script]->src . ";";
    endforeach;

    // Print all loaded Styles (CSS)
    global $wp_styles;
    foreach( $wp_styles->queue as $style ) :
       $result['styles'][] =  $wp_styles->registered[$style]->src . ";";
    endforeach;

    return $result;
}

Then within your theme:

print_r( crunchify_print_scripts_styles() );

... will show you the results for debugging, or of course...

$all_the_scripts_and_styles = crunchify_print_scripts_styles();

... will give you the list to manipulate.

Calling it in the theme makes sure you call it after all scripts and styles are enqueued.

To call it from your plugin, attach it to any hook that runs later than wp_enqueue_scripts, like wp_head as I mentioned above:

add_action( 'wp_head', 'wpse_233142_process_list');

function wpse_233142_process_list() {

    $all_the_scripts_and_styles = crunchify_print_scripts_styles();
    // process your array here

}

You could use wp_print_scripts and wp_print_styles actions to timely and properly access to enqueued scripts and styles, as these actions are the last events before scripts and styles are included in the document and, because of that, the last event where modifications on $wp_styles or $wp_scripts could have effect on styles and scripts included in the document.

So, they are the events where you can be more confident that $wp_styles and $wp_scripts contain the scripts and styles effectively included in the document.

add_action( 'wp_print_scripts', 'cyb_list_scripts' );
function cyb_list_scripts() {
    global $wp_scripts;
    $enqueued_scripts = array();
    foreach( $wp_scripts->queue as $handle ) {
        $enqueued_scripts[] = $wp_scripts->registered[$handle]->src;
    }
}
add_action( 'wp_print_styles', 'cyb_list_styles' );
function cyb_list_styles() {
    global $wp_styles;
    $enqueued_styles = array();
    foreach( $wp_styles->queue as $handle ) {
        $enqueued_styles[] = $wp_styles->registered[$handle]->src;
    }
}

If you declare $enqueued_scripts adn $enqueued_styles as global variables (or any other valid scope, for example you could store it in a method's property), you could access to the list of script and styles in a later action.

For example (just a quick example):

global $enqueued_scripts;
global $enqueued_styles;

add_action( 'wp_print_scripts', 'cyb_list_scripts' );
function cyb_list_scripts() {
    global $wp_scripts;
    global $enqueued_scripts;
    $enqueued_scripts = array();
    foreach( $wp_scripts->queue as $handle ) {
        $enqueued_scripts[] = $wp_scripts->registered[$handle]->src;
    }
}
add_action( 'wp_print_styles', 'cyb_list_styles' );
function cyb_list_styles() {
    global $wp_styles;
    global $enqueued_styles;
    $enqueued_styles = array();
    foreach( $wp_styles->queue as $handle ) {
        $enqueued_styles[] = $wp_styles->registered[$handle]->src;
    }
}

add_action( 'wp_head', function() {
    global $enqueued_scripts;
    var_dump( $enqueued_scripts );
    global $enqueued_styles;
    var_dump( $enqueued_styles );
} );