Injecting a javascript banner code right before & after wordpress navigation menu

The Core menu system, which was not mentioned in the initial version of the question, does not have any “before” and “after” hooks that I can find. You could create a custom Walker that could include those hooks but it is going to be a theme problem, either way.

If that is not satisfactory, you will need to alter the DOM with Javascript. I don’t know if that is even possible/viable for the code you want to include but if that is an option you need to hook code to wp_enqueue_scripts something like this: https://wordpress.stackexchange.com/a/128250/21376.

You can use wp_localize_script() to write data to the page that your script can use. For example: https://wordpress.stackexchange.com/a/92184/21376.