iFrames
임베디드 프레임 안에 있는 활동 데이터를 처리합니다.
iFrame 프레즌스 스크립트는 선택 기능으로 지원됩니다. metadata.json에서 iframe을 true로 설정하고 iFrameRegExp를 지정하세요.
iFrame 프레즌스 설정
중첩된 프레임 URL 패턴을 metadata.json에 추가하세요.
{
"iframe": true,
"iFrameRegExp": "player\\.example\\.com/embed/"
}presence.ts 옆에 iframe.ts 파일을 만드세요. 일치하는 중첩 프레임 안에서 실행됩니다.
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,
},
})
})presence.ts에서 데이터를 받습니다.
presence.on("iFrameData", (data) => {
iFrameData = data
})iFrameData는 메시지마다 한 번 발생합니다. 여러 프레임이 있으면 메인 프레즌스에서 데이터를 식별하거나 병합하세요. iFrameRegExp는 중첩 프레임 URL과 비교됩니다.
권장 접근 방식
iframe 처리는 메인 페이지가 필요한 상태에 접근할 수 없을 때만 사용하세요.
iframe 로직을 추가하기 전에 안정적인 DOM 선택자, 미디어 요소, 공개된 페이지 상태를 우선하세요.
안전
프레임에서 개인정보나 민감한 데이터를 수집하지 마세요. 프레즌스는 Discord Rich Presence에 유용한 활동 정보만 전송해야 합니다.