Add an attribute to inline script tag

Add additional attributes to an inline script tag.
// NAV: Add attributes to inline script nf-front-end-js-extra 
function wpcoder_add_attribute_to_inline_script ($attributes, $javascript) {
    
    if(isset($attributes['id']) && $attributes['id'] === 'nf-front-end-js-extra') {
        $attributes = array_merge(array( 'data-cookieconsent' => 'ignore' ), $attributes);
    } 
    
    return $attributes;
    
}

add_filter('wp_inline_script_attributes', 'wpcoder_add_attribute_to_inline_script', 10, 2);