It looks like the close button is created and added to the video by the JS, could it perhaps instead be added to the video markup on the page? (I haven't seen what that markup is, if this is intended to transform a normal video block by adding the extra stuff I can understand why the answer to that would be no)

If not, perhaps you could instead put the string on a data-element somewhere, maybe on the body tag or maybe on the video being modified. Using an inline script to mess with a global seems like a very awkward way to get data from the backend to the frontend.