const Jt=t=>Object.assign({},...t.split("&").map(t=>(kva=t.split("=").map(decodeURIComponent),{[kva[0]]:kva[1]})));var Wt,videoId,zt,proKey;function Gt(t){var e=t.currentTarget;t.returnValue=!1,t.preventDefault&&t.preventDefault();var a=e.getAttribute("loop"),i=e.getAttribute("data-format");return zt=(zt=zt.replace(/[/\\?%*:|"<>]/g,"-")).replace(/[\u200B-\u200D\uFEFF]/g,"-"),a&&chrome.tabs.sendMessage(Wt,{msg:"loadFrame",data:i,vid:videoId,videoTitle:zt,key:proKey,loop:a}),window.close(),!1}function Ht(t){t=JSON.parse(t),zt=t.videoTitle,proKey=t.key,$(".VideoTitle").text(zt);var e=t.VideoData;for(let t=0;t<e.length;t++){let a=document.createElement("a"),i=e[t].url;a.setAttribute("id","ytdl_link_"+e[t].format+"_"+t),a.setAttribute("data-format",e[t].format),a.setAttribute("class","list-group-item list-group-item-action"),a.setAttribute("loop",t+""),a.innerText=e[t].label,e[t].external?(a.setAttribute("href",i),a.setAttribute("target","_blank")):a.addEventListener("click",Gt,!1),$(a).appendTo(".LinkContainer")}$(".Loading").hide(),setTimeout(function(){try{chrome.tabs.sendMessage(Wt,{msg:"getList",data:videoId},function(t){if(t&&t.data)try{var e=JSON.parse(t.data),a=e&&e.VideoData?e.VideoData:[];for(let t=0;t<a.length;t++){var i=document.getElementById("ytdl_link_"+a[t].format+"_"+t);i&&a[t].label&&(i.textContent=a[t].label)}}catch(t){}})}catch(t){}},600)}$(document).ready(function(){$(".Loading").hide(),$(".notYoutube").hide(),chrome.tabs.query({active:!0,currentWindow:!0},function(tabs){if(!tabs[0]||-1===tabs[0].url.indexOf("youtube.com/watch")&&-1===tabs[0].url.indexOf("youtube.com/shorts/")&&-1===tabs[0].url.indexOf("youtube.com/live/"))$(".Loading").hide(),$(".notYoutube").show();else{if($(".Loading").show(),Wt=tabs[0].id,tabs[0].url.indexOf("shorts/")>-1)try{var t=tabs[0].url.split("shorts/")[1]||"";t=(t=t.split("?")[0]).split("/")[0],videoId=t}catch(t){videoId=tabs[0].url.split("shorts/")[1]}else{const query=Jt(tabs[0].url.split("?")[1]);videoId=query["v"]}chrome.tabs.sendMessage(Wt,{msg:"getList",data:videoId},function(t){void 0,t&&Ht(t.data)})}})});