EDIT: rlemon helped me get there. Thank you.
console.log(videoScript, 'log of script tag HTML')
var x = videoScript.outerHTML
document.getElementById('injectedScriptElement').innerText = x
I can now render the log of the script tag into the DOM.
I am trying to troubleshoot an issue I am having and the best way for me to show someone else is to print/render the console.log to the DOM so the person can easily copy&paste the html without diving into the console.
When I console.log a created script tag, I see the full html of the script tag in the console.
When I try to inject it into the DOM using innerHTML or innerText, I get the following in the DOM:
[object HTMLScriptElement]
I have also tried toString() and JSON.stringify but that renders out an empty object {}
Is there a way to do what I'm trying to achieve?
At the end of the day I can just add the code statically, but I would rather it come from the Javascript itself to reassure them that the output is actually coming from the Javascript and not just added manually by me.