steam-miniprofile icon indicating copy to clipboard operation
steam-miniprofile copied to clipboard

Ability to know when profile has loaded in iframe

Open liamsnowdon opened this issue 1 year ago • 2 comments

Hi, thanks for the awesome tool. Works great :)

One thing that would be useful when using the iframe is to know when the html changes from the initial loading state to the profile state. As far as I can see there is no easy way of doing this. I think this could be achieved by posting a message to the parent like this:

window.parent.postMessage({
  state: 'loaded'
})

Then whenever the iframe is used, the post message can be listened to using:

window.addEventListener('message', (event) => {
  if (event.origin !== 'https://gamer2810.github.io') {
    return
  }

  // Do something with message
})

liamsnowdon avatar Jun 02 '24 11:06 liamsnowdon