iframe.ts 680 B

12345678910111213141516171819202122232425262728
  1. const iframe = new iFrame();
  2. if (document.location.href.includes("player.blubrry.com")) {
  3. iframe.on("UpdateData", async () => {
  4. iframe.send({
  5. elapsed: document.querySelector(".time-elapsed")?.textContent,
  6. total: document.querySelector(".sm2-inline-duration.time-total")
  7. ?.textContent,
  8. isPlaying: Boolean(document.querySelector("i.is-playing")),
  9. });
  10. });
  11. }
  12. if (document.location.href.includes("www.youtube.com")) {
  13. iframe.on("UpdateData", async () => {
  14. const { currentTime, duration, paused } =
  15. document.querySelector<HTMLVideoElement>(
  16. "video.video-stream.html5-main-video"
  17. );
  18. iframe.send({
  19. currentTime,
  20. duration,
  21. paused,
  22. });
  23. });
  24. }