var FORMAT_LABEL={17:"3GP 144p",18:"MP4 360p",22:"MP4 720p",44:"WebM 480p",45:"WebM 720p",46:"WebM 1080p",91:"MP4 144p",92:"MP4 240p",93:"MP4 360p",94:"MP4 480p",95:"MP4 720p",96:"MP4 1080p",300:"MP4 720p 60fps",301:"MP4 1080p 60fps",133:"MP4 240p (Video)",134:"MP4 360p (Video)",135:"MP4 480p (Video)",136:"MP4 720p (Video)",137:"MP4 1080p (Video)",160:"MP4 144p (Video)",mp3128:"mp3128",mp3256:"mp3256","720P":"720P","1080p3":"1080p3",Settings:"Settings",About:"About",Donate:"Donate"};const W=t=>Object.assign({},...t.split("&").map(t=>(kva=t.split("=").map(decodeURIComponent),{[kva[0]]:kva[1]})));function notifyExtension(t){var e=t.currentTarget,a=e.getAttribute("download");return a=(a=a.replace(/[/\\?%*:|"<>]/g,"-")).replace(/[\u200B-\u200D\uFEFF]/g,"-"),t.returnValue=!1,t.preventDefault&&t.preventDefault(),e.getAttribute("loop")&&chrome.runtime.sendMessage({action:"download",url:e.getAttribute("href"),filename:a}),!1}var ut,videoId,dt,proKey;function pt(t){var e=t.currentTarget;t.returnValue=!1,t.preventDefault&&t.preventDefault();var a=e.getAttribute("loop"),o=e.getAttribute("data-format");return dt=(dt=dt.replace(/[/\\?%*:|"<>]/g,"-")).replace(/[\u200B-\u200D\uFEFF]/g,"-"),a&&chrome.tabs.sendMessage(ut,{msg:"loadFrame",data:o,vid:videoId,videoTitle:dt,key:proKey,loop:a}),window.close(),!1}function ct(t){t=JSON.parse(t),dt=t.videoTitle,proKey=t.key,$(".VideoTitle").text(dt);var e=t.VideoData;for(let t=0;t<e.length;t++){var a=e[t].format;if(FORMAT_LABEL[a]){let a=document.createElement("a"),o=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",o),a.setAttribute("target","_blank")):a.addEventListener("click",pt,!1),$(a).appendTo(".LinkContainer")}}$(".Loading").hide(),setTimeout(function(){try{chrome.tabs.sendMessage(ut,{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 o=document.getElementById("ytdl_link_"+a[t].format+"_"+t);o&&a[t].label&&(o.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(),ut=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=W(tabs[0].url.split("?")[1]);videoId=query["v"]}chrome.tabs.sendMessage(ut,{msg:"getList",data:videoId},function(t){void 0,t&&ct(t.data)})}})});