Skip to content

Commit 78e26d9

Browse files
authored
Use nocookie YouTube embeds with API params (#92)
- Switch video and playlist embeds to `youtube-nocookie.com` - Add `enablejsapi`, `origin`, and branding-related query params - Preserve autoplay while improving embed privacy and consistency
1 parent 8f27708 commit 78e26d9

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

apps/web/src/youtubePlayerStore.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,19 @@ export function parseYouTubeUrl(input: string): { type: "video" | "playlist"; id
186186
}
187187

188188
export function buildYouTubeEmbedUrl(type: "video" | "playlist", id: string): string {
189+
const origin =
190+
typeof window !== "undefined" ? window.location.origin : "";
191+
const params = new URLSearchParams({
192+
autoplay: "1",
193+
enablejsapi: "1",
194+
origin,
195+
rel: "0",
196+
modestbranding: "1",
197+
});
198+
189199
if (type === "playlist") {
190-
return `https://www.youtube.com/embed/videoseries?list=${id}&autoplay=1`;
200+
params.set("list", id);
201+
return `https://www.youtube-nocookie.com/embed/videoseries?${params.toString()}`;
191202
}
192-
return `https://www.youtube.com/embed/${id}?autoplay=1`;
203+
return `https://www.youtube-nocookie.com/embed/${id}?${params.toString()}`;
193204
}

0 commit comments

Comments
 (0)