Skip to content

Commit

Permalink
refactor: simplify find iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyhalight committed Jan 14, 2025
1 parent 9167eec commit ac339c5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
4 changes: 2 additions & 2 deletions dist/vot-min.user.js

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions dist/vot.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -12607,12 +12607,8 @@ function initIframeInteractor() {
const reqId = e.data.replace("getVideoId:", "");
const iframeLink = atob(reqId);
const videoId = /\/(\w{3,5})\/[^/]+$/.exec(window.location.pathname)?.[1];
const iframes = Array.from(
document.querySelectorAll("electra-player > iframe"),
);

const iframeWin = iframes.find(
(iframe) => iframe.src === iframeLink,
const iframeWin = document.querySelector(
`electra-player > iframe[src="${iframeLink}"]`,
)?.contentWindow;

iframeWin.postMessage(
Expand Down
8 changes: 2 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2958,12 +2958,8 @@ function initIframeInteractor() {
const reqId = e.data.replace("getVideoId:", "");
const iframeLink = atob(reqId);
const videoId = /\/(\w{3,5})\/[^/]+$/.exec(window.location.pathname)?.[1];
const iframes = Array.from(
document.querySelectorAll("electra-player > iframe"),
);

const iframeWin = iframes.find(
(iframe) => iframe.src === iframeLink,
const iframeWin = document.querySelector(
`electra-player > iframe[src="${iframeLink}"]`,
)?.contentWindow;

iframeWin.postMessage(
Expand Down

0 comments on commit ac339c5

Please sign in to comment.