`); $customShare.append($upperShare.children()); $upperShare.remove(); if ($fullscreen.length) $customShare.insertBefore($fullscreen); else $bottomRight.append($customShare); // Reveal once placed (no flicker) requestAnimationFrame(() => { $customShare.css("display", "flex"); $customShare.find(".playkit-icon-share").css("display", "flex"); }); } function watchForShareClose() { const root = document.querySelector("#un3-video-player"); if (!root) return; if (shareCloseObserver) shareCloseObserver.disconnect(); shareCloseObserver = new MutationObserver(() => { const shareMenu = document.querySelector(".playkit-share-menu"); const topShare = document.querySelector(".playkit-right-upper-bar-wrapper-container_Vm .playkit-icon-share"); // When share menu closes if (!shareMenu) { if (topShare) topShare.style.display = "none"; // hide instantly setTimeout(() => ensureShareReady(true), 300); // reposition after rebuild } }); shareCloseObserver.observe(root, { childList: true, subtree: true }); } /** ---------- SHARE BUTTON FIX END ---------- **/ jQuery(document).on('click', 'i.playkit-icon-embed', () => { const input = jQuery("div.playkit-input-copy-url input.playkit-form-control"); const iframeHTML = input.attr('aria-label'); const newIframeHTML = patchIframe(iframeHTML); input.val(newIframeHTML); input.attr('aria-label', newIframeHTML); }); // Common function for your iframe patching logic function updateIframe(radioId) { const input = jQuery('div.playkit-input-copy-url input.playkit-form-control'); const iframeHTML = input.attr('aria-label'); const newIframeHTML = patchIframe(iframeHTML); input.val(newIframeHTML).attr('aria-label', newIframeHTML); } // Listen for clicks on any PlayKit radio wrapper jQuery(document).on('click', '.playkit-radio-button', function () { const $radioDiv = jQuery(this); const radioId = $radioDiv.find('input[type="radio"]').attr('id'); // Delay a little to allow PlayKit or other logic to update aria-checked setTimeout(function () { const isChecked = $radioDiv.attr('aria-checked') === 'true'; if (isChecked) { // Trigger your update logic based on the selected radio switch (radioId) { case 'full-video': updateIframe('full-video'); break; case 'start-from': updateIframe('start-from'); break; case 'clip': updateIframe('clip'); break; default: console.warn('Unknown radio:', radioId); } } }, 100); }); jQuery(document).on('click', '.playkit-btn-copy-url', function () { // Find the target input const $input = jQuery('div.playkit-input-copy-url input.playkit-form-control'); // Get the value from the aria-label attribute const iframeHTML = $input.attr('aria-label'); if (!iframeHTML) { console.warn('No iframe HTML found in aria-label'); return; } // Try the modern Clipboard API first if (navigator.clipboard && navigator.clipboard.writeText) { navigator.clipboard .writeText(iframeHTML) .catch((err) => { console.error('Clipboard API failed:', err); fallbackCopy(iframeHTML); }); } else { // Fallback for older browsers fallbackCopy(iframeHTML); } }); // Fallback using a temporary textarea element function fallbackCopy(text) { const $temp = jQuery('