Using window objects to define javascript variables for Chrome extension

I am trying to create a dynamic overlay for a browser game that will update team information as it updates within the game. The function that is used in the game to do so is:

updateGameInfo()

I have the HTML/CSS/JS defined, so for team member name, it would be

const memberName = document.getElementById("name")

And I would like to change it after updateGameInfo() is complete to be

memberName.textContent = window.gameInfo.party[0].name

How can I create this function to automatically run after updateGameInfo() and get the relevant information to change the variables?