1const IDs = []; 2const checkBoxElms = []; 3const players = []; 4 5const main = () => { 6 console.info("main"); 7 const tag = document.createElement("script"); 8 tag.src = "//www.youtube.com/iframe_api"; 9 const firstScriptTag = document.getElementsByTagName("script")[0]; 10 firstScriptTag.parentNode?.insertBefore(tag, firstScriptTag); 11}; 12 13if (document.readyState !== "loading") { 14 console.info("readyState"); 15 main(); 16} else { 17 console.info("addEventListener"); 18 document.addEventListener("DOMContentLoaded", main, false); 19} 20 21window.onYouTubeIframeAPIReady = () => { 22 console.group("onYouTubeIframeAPIReady"); 23 console.info("onYouTubeIframeAPIReady"); 24 const playerContainerNodes = document.querySelectorAll(".mwsc__image_movie"); 25 const checkBoxNodes = document.querySelectorAll(".mwsc__movie_cb"); 26 playerContainerNodes.forEach((q) => { 27 const id = q.id; 28 IDs.push(id); 29 }); 30 console.debug({ IDs }); 31 const onPlayerReady = (event) => { 32 event.target.setVolume(0); 33 event.target.playVideo(); 34 }; 35 36 playerContainerNodes.forEach((DOM) => { 37 const ID = DOM.id; 38 const id = DOM.dataset.id; 39 const opt = DOM.dataset.opt ? parseFloat(DOM.dataset.opt) : 0; 40 const videoId = DOM.dataset.movid; 41 const width = "100vw"; 42 const height = "auto"; 43 const Options = { 44 width, 45 height, 46 videoId, 47 playerVars: { 48 autoplay: opt & 1 ? 1 : 0, 49 disablekb: 1, 50 fs: 0, 51 rel: 0, 52 }, 53 events: {}, 54 }; 55 if (opt & 1) { 56 Options.events.onReady = onPlayerReady; 57 } 58 if (opt & 2) { 59 Options.playerVars.playlist = videoId; 60 Options.playerVars.loop = 1; 61 } 62 console.debug(Options); 63 const player = new YT.Player(ID, Options); 64 const ckID = `mwsc__image_cb--${id}`; 65 const ckBox = document.getElementById(ckID); 66 ckBox?.addEventListener("change", (event) => { 67 var isChecked = event.target.checked; 68 console.debug("change", ckID, isChecked); 69 if (!isChecked) player.stopVideo(); 70 }); 71 players.push(player); 72 }); 73 checkBoxNodes.forEach((q) => checkBoxElms.push(q)); 74 console.groupEnd(); 75};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.