Command Palette

Search for a command to run...

iFrames

Handle activity data that lives inside embedded frames.

iFrame presence scripts are supported as an opt-in feature. Set iframe to true and provide iFrameRegExp in metadata.json.

Configure an iFrame presence

Add the nested-frame URL pattern to metadata.json:

{
  "iframe": true,
  "iFrameRegExp": "player\\.example\\.com/embed/"
}

Create an iframe.ts file next to presence.ts. It runs inside matching nested frames:

const iframe = new iFrame()

iframe.on("UpdateData", () => {
  const video = document.querySelector("video")
  if (!video) return

  iframe.send({
    video: {
      paused: video.paused,
      currentTime: video.currentTime,
      duration: video.duration,
      title: document.querySelector(".video-title")?.textContent,
    },
  })
})

Receive the data in presence.ts:

presence.on("iFrameData", (data) => {
  // Merge or replace data from the matching frame.
  iFrameData = data
})

iFrameData is emitted once per message. When multiple frames are present, identify or merge their payloads in the main presence. iFrameRegExp is matched against the nested frame URL.

Only use iframe handling when the main page cannot access the required state.

Prefer stable DOM selectors, media elements, and public page state before adding iframe logic.

Safety

Avoid collecting personal or sensitive data from frames. A presence should only send activity information that is useful for Discord Rich Presence.