Custom Javascript using CMS Rich Text and embedded HTML

I am trying to get some javascript code into my CMS page using a rich text element set as code. However, when setting the embedded HTML element, I cannot call any rich text field from my CMS variables.

My code will change drastically from page to page, so I would’t want to change only some variable parts of my script. I would like to fully load it all within using my rich text field.

Is there a way of doing this?

Thank you