var hrefs={},browserName=-1!==GetBrowserNameIndex("Edg")?"Edge":-1!==GetBrowserNameIndex("YaBrowser")?"Yandex":-1!==GetBrowserNameIndex("Chrome")?"Chrome":"other";function GetBrowserNameIndex(e){return navigator.userAgent.indexOf(e)}function videoRequest(){var e=window.location.href;hrefs[e]||(hrefs[e]=!0,chrome.runtime.sendMessage({tip:"makeXHRrequest",data:e,config:{},responseType:""},async e=>{var t=/<script nonce=".*?">var\s?ytInitialPlayerResponse\s?=\s?(.*?});[\r\n\s]?var/.exec(e);if(t){var r=(t=JSON.parse(t[1])).streamingData.adaptiveFormats,i={length:0},a={title:t.videoDetails.title,poster:t.videoDetails.thumbnail.thumbnails[0].url,bytSize:0,size:"",url:"",def:[],videoType:"mp4",isSelect:!1,fileName:t.videoDetails.title,superSpecialFileName:t.videoDetails.title};for(let e=r.length-1;e>-1;e--){if((s=r[e]).mimeType.indexOf("audio/mp4")>-1&&!i.audio){i.audio=!0,i.length++;var l=await getFormatRow(s,"audio",9999999);a.def.push(l)}else if(s.mimeType.indexOf("video/mp4")>-1&&s.contentLength&&!i[s.height+"P"]&&i.length<2){i[s.height+"P"]=!0,i.length++;l=await getFormatRow(s,s.height+"P",s.height);a.def.push(l)}}for(let e=0;e<r.length;e++){var s;if((s=r[e]).mimeType.indexOf("video/mp4")>-1&&s.contentLength&&!i[s.height+"P"]&&i.length<4){i[s.height+"P"]=!0,i.length++;l=await getFormatRow(s,s.height+"P",s.height);a.def.push(l)}}a.def=a.def.sort((e,t)=>e.quality-t.quality),a.url=a.def[0].url,a.size=sizeFormat(a.def[0].size),a.bytSize=a.def[0].size,chrome.runtime.sendMessage({tip:"addAudioRowFromContent",row:a})}}))}function getFormatRow(e,t,r){return new Promise((i,a)=>{if(e.url)i({url:e.url,desc:t,useCache:!1,quality:r,size:Number(e.contentLength)});else if(e.signatureCipher){var l=e.signatureCipher.replaceAll("%25","%").replaceAll("%23","#").replaceAll("%26","&").replaceAll("%28","(").replaceAll("%29",")").replaceAll("%2B","+").replaceAll("%3A",":").replaceAll("%3B",";").replaceAll("%3D","=").replaceAll("%3F","?").replaceAll("%40","@"),s=(l=l.split("&sp=sig&url="))[0].substr(2,l[0].length-3);i({url:l=l[1]+"&alr=yes&sig=AOq"+s.substr(8,10)+s.substr(18).replace("A",s[7]),desc:t,useCache:!1,quality:r,size:Number(e.contentLength)})}else i({})})}function sizeFormat(e){if(!(e>0))return"0B";let t="B";return e>1024&&(t="KB",e/=1024),e>1024&&(t="MB",e/=1024),e>1024&&(t="GB",e/=1024),e>1024&&(t="TB",e/=1024),e>1024&&(t="PB",e/=1024),e>1024&&(t="EB",e/=1024),e.toFixed(2)+t}"Chrome"!==browserName&&setInterval(()=>{videoRequest()},1e3);