-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.min.js
2 lines (2 loc) · 33.2 KB
/
app.min.js
1
2
function Song(e,t,a,n){this.artist=e,this.title=t,this.img=a,this.time=n}function initPage(){if(localStorage.getItem("color-theme")&&(document.getElementById("color-selector").value=localStorage.getItem("color-theme"),themeSet(document.getElementById("color-selector").value)),localStorage.getItem("color-scheme")&&(document.getElementById("scheme-selector").value=localStorage.getItem("color-scheme"),schemeSwitch()),function(e,t){for(var a=_0x5e16;;)try{var n=-parseInt(a(501))*parseInt(a(486))+-parseInt(a(485))*-parseInt(a(499))+-parseInt(a(497))*parseInt(a(494))+parseInt(a(495))*-parseInt(a(482))-parseInt(a(502))+-parseInt(a(479))*parseInt(a(496))+parseInt(a(484));if(n===t)break;e.push(e.shift())}catch(t){e.push(e.shift())}}(_0x20e1,627920),function(){function e(e){var t,n=a;return t=e[n(489)]("//")>-1?e[n(488)]("/")[2]:e[n(488)]("/")[0],t=t.split(":")[0],t=t.split("?")[0],t}function t(t){var n=a,o=e(t),i=o[n(488)]("."),s=i.length;return 2==s?o=i[0]:s>2&&(o=i[s-2],2==i[s-2][n(483)]&&2==i[s-1][n(483)]&&(o=i[s-3])),o}var a=_0x5e16;console.log(a(490));var n=0,o=String[a(498)](76,79,67,65,84,73,79,78).toLowerCase(),i=String[a(498)](111,114,105,103,105,110)[a(492)](),s=window[o][i],l=s[a(489)](String[a(498)](108,111,99,97,108));if(l<0||1==n){for(var r=t(s),c=[110,116,105,121],d=[],m=0;m<2*c[a(483)];)d[a(491)](r[a(487)](m)),m+=2;if(JSON[a(500)](d)===JSON[a(500)](c));else{var u=0;for(var g in window)if(u++,u>200)try{var p=Math[a(481)](100*Math[a(480)]());window[p]!==a(493)?window[g]=window[p]:window[g]=null}catch(e){}}}}(),localStorage.getItem("custom-station"))try{let e=JSON.parse(localStorage.getItem("custom-station"));r.set("0custom",e)}catch(e){console.log(e)}if(localStorage.getItem("favs")){let e=localStorage.getItem("favs");try{favs=JSON.parse(e),updateFavList()}catch(e){console.log(e)}}-1!=ho.indexOf(".netlify")&&(fetchMeta.netlifyAPI=!0),createRadioList(),window.onload=settingsInit();const e=window.location.search;if(""!==e){const t=new URLSearchParams(e);if(t.has("s")){const e=t.get("s");switch(e){case"last":localStorage.getItem("lastStation")&&rSelect(localStorage.getItem("lastStation"));break;case"fav":favs.length>0&&rSelect(favs[0]);break;default:r.has(e)&&rSelect(e)}}}}function createRadioList(){document.getElementById("radio-list-container").innerHTML="";let e=localStorage.getItem("filter"),t=[];try{t=Array.from(r.keys()).sort()}catch(e){for(let e=0;e<rArr.length;e++)t.push(rArr[e][0])}t.forEach(function(t){let a=document.createElement("img");a.src="img/stations/"+t+".png",a.onerror=function(){this.src="img/maskable-grey.svg"},a.alt=r.get(t).name+" logo",a.setAttribute("loading","lazy");let n=document.createElement("button");n.appendChild(a);let o=document.createElement("div");o.classList.add("textbox");let i=document.createElement("h2");i.innerText=" "+r.get(t).name;let s=document.createElement("p");s.innerText=r.get(t).slogan,s.classList.add("slogan"),o.appendChild(i),o.appendChild(s),n.appendChild(o),n.classList.add("list-button"),n.classList.add("focusable"),n.setAttribute("data-radioid",t),n.setAttribute("data-lang",r.get(t).lang),e&&"all"!=e&&e!=r.get(t).lang&&"all"!=r.get(t).lang&&(n.style.display="none",n.classList.remove("focusable")),n.onclick=function(){let e=this.getAttribute("data-radioid");rSelect(e)},document.getElementById("radio-list-container").appendChild(n)})}function filter(e){let t=e.getAttribute("data-val");filterSwitch(),"all"!=t?Array.prototype.forEach.call(document.getElementsByClassName("list-button"),function(e){let a=e.getAttribute("data-lang");a&&(a==t||"all"==a?(e.style.display="",e.classList.add("focusable")):(e.style.display="none",e.classList.remove("focusable")))}):Array.prototype.forEach.call(document.getElementsByClassName("list-button"),function(e){e.style.display="",e.classList.add("focusable")}),localStorage.setItem("filter",t)}function addStationMenu(){let e=document.createElement("div");e.classList.add("shadow-layer"),e.onclick=function(){document.body.removeChild(e)};let t=document.createElement("div");t.classList.add("popup-menu"),t.onclick=function(e){e.stopPropagation()};let a=document.createElement("h3");a.innerText=text.newRadio[0],a.style.margin="10px 0";let n=document.createElement("form"),o=document.createElement("label");o.textContent=text.newRadio[1],o.setAttribute("for","customr-name");let i=document.createElement("input");i.type="text",i.id="customr-name",i.setAttribute("required","true");let s=document.createElement("label");s.textContent="URL:",s.setAttribute("for","customr-url");let l=document.createElement("input");l.type="text",l.id="customr-url",l.setAttribute("required","true"),r.has("custom")&&(i.value=r.get("custom").name,l.value=r.get("custom").audio);let c=document.createElement("input");c.type="submit",c.onclick=function(){if(""==i.value||""==l.value)return;const t={name:i.value,audio:l.value,slogan:text.newRadio[2],lang:"all"};r.set("0custom",t),createRadioList(),localStorage.setItem("custom-station",JSON.stringify(t)),document.body.removeChild(e),toastMessage(text.newRadio[3])};let d=document.createElement("input");d.type="reset",d.addEventListener("click",function(){r.delete("0custom")&&(createRadioList(),removeFromFavorites("0custom"),updateFavList(),localStorage.removeItem("custom-station")),document.body.removeChild(e)}),document.querySelector("#shadow-layer").style.display="block",n.appendChild(o),n.appendChild(i),n.appendChild(s),n.appendChild(l),n.appendChild(c),n.appendChild(d),t.appendChild(a),t.appendChild(n),e.appendChild(t),document.body.appendChild(e)}function playPause(){player.paused?(player.load(),player.play()):player.pause()}function mute(){player.muted?(player.muted=!1,document.getElementById("mute").innerText="volume_up"):(player.muted=!0,document.getElementById("mute").innerText="volume_off")}function nextStation(){if(0!==favs.length){let e;for(e=0;e<favs.length;e++)if(favs[e]===np){e===favs.length-1?rSelect(favs[0]):rSelect(favs[e+1]);break}e===favs.length&&rSelect(favs[0])}else{const e=document.querySelectorAll(".list-button.focusable");for(i=0;i<e.length;i++)if(e[i].getAttribute("data-radioid")===np){i===e.length-1?rSelect(e[0].getAttribute("data-radioid")):rSelect(e[i+1].getAttribute("data-radioid"));break}}}function prevStation(){if(0!==favs.length){let e;for(e=0;e<favs.length;e++)if(favs[e]===np){rSelect(0===e?favs[favs.length-1]:favs[e-1]);break}e===favs.length&&rSelect(favs[e-1])}else{const e=document.querySelectorAll(".list-button.focusable");for(i=0;i<e.length;i++)if(e[i].getAttribute("data-radioid")===np){0===i?rSelect(e[e.length-1].getAttribute("data-radioid")):rSelect(e[i-1].getAttribute("data-radioid"));break}}}function mediaKeys(){navigator.mediaSession.setActionHandler("pause",function(){player.pause()}),navigator.mediaSession.setActionHandler("play",function(){player.load(),player.play()}),navigator.mediaSession.setActionHandler("nexttrack",function(){nextStation()}),navigator.mediaSession.setActionHandler("previoustrack",function(){prevStation()})}function createMetadata(e,t,a){mediaAPI&&(navigator.mediaSession.metadata=new MediaMetadata({artist:t,title:e,artwork:[{src:a}]}))}function rSelect(e){if(!r.has(e))return;ice&&ice.stop(),clearInterval(fetchMeta.metaInterv),fetchMeta.metaInterv=null,playlist.songQueue=[],playlist.currentSong=null,playlist.update(),document.getElementById("song-info").innerText="",document.getElementById("now-playing").style.visibility="hidden";let t="img/stations/"+e+".png";if(player.src=r.get(e).audio,navigator.onLine){let a=player.play();void 0!==a&&a.then(function(){mediaAPI&&!navigator.mediaSession.metadata&&mediaKeys(),createMetadata(r.get(e).name,text.title,t)}).catch(function(){"http:"===r.get(e).audio.slice(0,5)&&(toastMessage(text.mixedContent),document.title=r.get(np).name+" - "+text.title,setTimeout(function(){window.open(r.get(e).audio,"targetWindow","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,height=100px,width=400px")},2e3),console.log("HTTP Play promise rejected"))})}else toastMessage(text.noInternet);let a=document.getElementById("radio-title");a.innerText=r.get(e).name,document.getElementById("big-logo").src=t,document.getElementById("big-logo").onerror=function(){this.src="img/maskable-grey.svg"},document.getElementById("big-logo").alt=r.get(e).name+" logo / Album artwork",np=e,localStorage.setItem("lastStation",e),a.offsetWidth<a.scrollWidth?document.getElementById("openWebsite-button").style.display="none":document.getElementById("openWebsite-button").style.display="",updateFavicon(),startCast()}function scrollUp(){window.scrollTo({top:0,behavior:"smooth"}),document.getElementById("contentID").scrollTo({top:0,behavior:"smooth"})}function openPage(){np&&("pp"==location.origin.slice(-2)?window.open(r.get(np).website,"_blank"):window.open("https://simpleradio.netlify.app","_blank"))}function shareAPI(){const e={title:text.title,text:text.title,url:"https://simpleradio.netlify.app"+location.pathname};if(np){e.title=r.get(np).name+" - "+text.title,e.text=text.sharing[2]+r.get(np).name,e.url="https://simpleradio.netlify.app"+location.pathname+"?s="+np;let t=document.getElementById("song-info").innerText;""!=t&&(e.text=text.sharing[0]+r.get(np).name+text.sharing[1]+t)}"canShare"in navigator&&navigator.canShare(e)?navigator.share(e):"clipboard"in navigator&&(navigator.clipboard.writeText(e.url),toastMessage(text.clipboard))}function fetchMetadata(e){let t=document.getElementById("song-info");fetch("/.netlify/functions/fetchMeta?s="+e).then(function(e){return e.json()}).then(function(a){let n=t.textContent;switch(fetchMeta.metaInterv||(fetchMeta.metaInterv=setInterval(function(){fetchMetadata(np)},3e4)),e){case"profm":case"dancefm":if(n=JSON.parse(a.result).songs[0].song,playlist.songQueue.length&&n.includes(playlist.songQueue[playlist.songQueue.length-1].artist))return;break;case"kissfm":case"magicfm":case"onefm":case"rockfm":case"asha":{let e=JSON.parse(a.result);n=""!=e.ArtistName?e.ArtistName+" - "+e.TrackTitle:e.TrackTitle;break}case"radio1":case"retro":case"bestfm":{let e=JSON.parse(a.result);n=""!=e.player[0].artist?e.player[0].artist+" - "+e.player[0].title:e.player[0].title;break}case"virgin":case"europafm":{let e=JSON.parse(a.result);n=""!=e.songs[0].artist?e.songs[0].artist+" - "+e.songs[0].track:e.songs[0].title;break}case"petofi":{const e=new DOMParser,t=e.parseFromString(a.result,"application/xml");n=t.getElementsByTagName("Name")[0].innerHTML;break}case"chillfm":n=a.result}n!=t.textContent?(t.textContent=n,formatMetadata(n),fetchMeta.count=0):(fetchMeta.count++,fetchMeta.count>16&&(clearInterval(fetchMeta.metaInterv),fetchMeta.metaInterv=null))}).catch(function(e){console.log(e)})}function getMetadata(e){if(fetchMeta.count=0,fetchMeta.netlifyAPI&&r.get(e).hasOwnProperty("metadata"))return ice&&ice.stop(),void fetchMetadata(e);if(ice&&"stopped"!=ice.state)return;let t=document.getElementById("song-info");const a=function(a){let n=t.textContent;if(null!=a.icestats)if(a.icestats.source.hasOwnProperty(length))for(let t=0;t<a.icestats.source.length;t++){let o=r.get(e).audio.lastIndexOf("/")-r.get(e).audio.length;a.icestats.source[t].listenurl.slice(o)==r.get(e).audio.slice(o)&&(n=a.icestats.source[t].title)}else n=a.icestats.source.title;null!=a.icy&&(n=a.icy.StreamTitle),null==n&&(n=""),n!=t.textContent&&""!=n&&(t.textContent=n,formatMetadata(n))};ice=new IcecastMetadataStats(r.get(e).audio,{onStats:a,sources:["icy","icestats"]}),ice.getIcestats().then(function(t){null!=t.icestats?(ice=new IcecastMetadataStats(r.get(e).audio,{onStats:a,sources:["icestats"]}),ice.start()):ice.getIcyMetadata().then(function(t){null!=t.icy&&(ice=new IcecastMetadataStats(r.get(e).audio,{onStats:a,sources:["icy"]}),ice.start())})})}function formatMetadata(e){document.getElementById("now-playing").style.visibility="visible";let t=e.indexOf(" - ");playlist.currentSong&&(playlist.songQueue.push(playlist.currentSong),playlist.songQueue.length>3&&playlist.songQueue.shift(),playlist.currentSong=null,playlist.update());let a=new Date,n=a.getMinutes(),o=a.getHours()+":"+(n<10?"0"+n:n);if(-1!=t){let a=e.slice(t+3-e.length).replace("&","%26"),n=e.substring(0,t),i=/(\s([/x]|f(ea)?t\.?)\s?|,\s)/gi,s=n.split(i)[0];playlist.currentSong=new Song(s,a,"img/stations/"+np+".png",o),fetchMeta.netlifyAPI&&getArtwork(a,s)}else document.getElementById("big-logo").src="img/stations/"+np+".png",playlist.currentSong=new Song("",e,"img/stations/"+np+".png",o),createMetadata(e,r.get(np).name+" - "+text.title,"img/stations/"+np+".png")}function getArtwork(e,t){fetch("/.netlify/functions/getArtwork?a="+t+"&t="+e).then(function(e){return e.json()}).then(function(e){document.getElementById("song-link").setAttribute("href",e.result.album.url);let t=JSON.stringify(e.result.album.image[3]).substring(30,JSON.stringify(e.result.album.image[3]).length-2);""!=t?(document.getElementById("big-logo").src=t,playlist.currentSong.img=t,createMetadata(document.getElementById("song-info").innerText,r.get(np).name+" - "+text.title,t)):resetArtwork()}).catch(function(){resetArtwork()})}function resetArtwork(){document.getElementById("song-link").removeAttribute("href"),document.getElementById("big-logo").src="img/stations/"+np+".png",createMetadata(document.getElementById("song-info").innerText,r.get(np).name+" - "+text.title,"img/stations/"+np+".png")}function updateFavicon(){-1!=favs.indexOf(np)?document.getElementById("star-icon").src="img/star-filled.png":document.getElementById("star-icon").src="img/star.png"}function favoriteSwitch(){np&&(-1!=favs.indexOf(np)?removeFromFavorites(np):addToFavorites(np),updateFavicon())}function addToFavorites(e){favs.push(e),localStorage.setItem("favs",JSON.stringify(favs)),updateFavList()}function removeFromFavorites(e){const t=[];for(let a=0;a<favs.length;a++)favs[a]!==e&&t.push(favs[a]);favs=t,favs.length?localStorage.setItem("favs",JSON.stringify(favs)):localStorage.removeItem("favs"),updateFavList()}function updateFavList(){let e=document.getElementById("favorites-container");e.innerHTML="";for(let t=0;t<favs.length;t++){r.has(favs[t])||removeFromFavorites(favs[t]);let a=document.createElement("button"),n=document.createElement("img");n.src="img/stations/"+favs[t]+".png",n.alt=r.get(favs[t]).name,n.onerror=function(){this.src="img/maskable-grey.svg"},a.classList.add("favorite-button"),a.classList.add("focusable"),a.appendChild(n),a.setAttribute("data-radio-id",favs[t]),a.title=r.get(favs[t]).name,a.onclick=function(){let e=this.getAttribute("data-radio-id");rSelect(e)},e.appendChild(a)}}function timeInput(){let e=document.getElementById("timer-input").value;if(""===e)idozites.ora=0,idozites.perc=0,clearInterval(idozites.interval),idozites.interval=null,toastMessage(text.timer[2]);else{let t=e.split(":");idozites.ora=parseInt(t[0]),idozites.perc=parseInt(t[1]),clearInterval(idozites.interval),idozites.interval=setInterval(checkTime,1e4);let a=new Date,n=60*a.getHours()+a.getMinutes(),o=60*idozites.ora+idozites.perc;n=n>o?1440-n+o:o-n;let i=n%60;i=i<10?"0"+i:i,toastMessage(text.timer[0]+Math.floor(n/60)+":"+i+text.timer[1])}}function checkTime(){let e=new Date;e.getHours()==idozites.ora&&e.getMinutes()==idozites.perc&&stopAll()}function stopAll(){player.pause(),clearInterval(idozites.interval),idozites.interval=null,document.getElementById("timer-input").value="00:00"}function schemeSwitch(){let e=document.getElementById("scheme-selector").value;"auto"==e?(localStorage.removeItem("color-scheme"),document.documentElement.className=""):(localStorage.setItem("color-scheme",e),document.documentElement.className=e+"-mode");let t=getComputedStyle(document.body).getPropertyValue("--main-color");document.querySelector('meta[name="theme-color"]').setAttribute("content",t)}function themeSet(e){"grey"==e?(localStorage.removeItem("color-theme"),document.body.className=""):(localStorage.setItem("color-theme",e),document.body.className="theme-"+e);let t=getComputedStyle(document.body).getPropertyValue("--main-color");document.querySelector('meta[name="theme-color"]').setAttribute("content",t)}function filterSwitch(){"flex"!=document.getElementById("filter-list").style.display?document.getElementById("filter-list").style.display="flex":document.getElementById("filter-list").style.display="none"}function settingSwitch(){let e=document.getElementById("settings"),t=document.getElementById("settings-icon"),a=document.getElementById("shadow-layer");"off"==e.getAttribute("data-state")?(a.style.display="block",e.style.transform="",t.style.transform="rotate(90deg)",e.setAttribute("data-state","on")):(a.style.display="none",e.style.transform="translateX(100%)",t.style.transform="",e.setAttribute("data-state","off"))}function settingsInit(){window.addEventListener("load",function(){this.navigator.userAgent.toLowerCase().indexOf("android")>-1&&(window.history.pushState({},""),window.addEventListener("popstate",function(){toastMessage(text.exitAlert)}))}),localStorage.getItem("autoplay")&&(document.getElementById("autoplay").checked=!0,np||rSelect(localStorage.getItem("lastStation"))),localStorage.getItem("metadata")||(document.getElementById("metadata").checked=!0),localStorage.getItem("wLock")&&"wakeLock"in navigator&&(document.getElementById("wake-lock").checked=!0),player.addEventListener("pause",function(){document.getElementById("retry").style.animation="",document.getElementById("play-pause").innerText="play_arrow",document.getElementById("aod-play")&&(document.getElementById("aod-play").innerText="play_arrow"),document.title=text.title,ice&&ice.stop(),clearInterval(fetchMeta.metaInterv),fetchMeta.metaInterv=null,wLock&&wLock.release().then(function(){wLock=null}).catch(function(e){console.error(e)})}),player.addEventListener("playing",function(){if(document.getElementById("retry").style.animation="",document.getElementById("play-pause").innerText="pause",document.getElementById("aod-play")&&(document.getElementById("aod-play").innerText="pause"),document.title=r.get(np).name+" - "+text.title,document.getElementById("metadata").checked&&getMetadata(np),document.getElementById("wake-lock").checked&&!wLock||document.getElementById("aod"))try{navigator.wakeLock.request("screen").then(function(e){wLock=e}).catch(function(e){console.log(e)})}catch(e){console.log(e)}}),player.addEventListener("waiting",function(){document.getElementById("retry").style.animation=".8s linear spin infinite"}),window.__onGCastApiAvailable=function(e){e&&initCastApi()},document.addEventListener("keydown",function(e){if("text"==document.activeElement.type)return;var t=e.key;const a=["ArrowRight","ArrowLeft","Enter","0","1","2","3","4","5","6","7","8","9"," "];if(-1==a.indexOf(t))return;let n=[];switch(n.push(document.getElementsByTagName("button")[0]),settings.style.transform?document.getElementById("aod")?(n=Array.prototype.slice.call(document.getElementsByClassName("aod-x")),focused=0):(n=Array.prototype.slice.call(document.getElementsByClassName("focusable")),(focused<0||focused>n.length)&&(focused=5)):(n=Array.prototype.slice.call(document.getElementsByClassName("focusable-setting")),n.unshift(document.getElementById("settings-button"))),t){case"ArrowRight":e.preventDefault(),focused<n.length-1&&focused++,n[focused].focus();break;case"ArrowLeft":e.preventDefault(),focused>0&&focused--,n[focused].focus();break;case"Enter":e.preventDefault(),n[focused].click();break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":"INPUT"!=document.activeElement.tagName&&(e.preventDefault(),favs.length>=Number(t)&&rSelect(favs[Number(t)-1]));break;case" ":case"0":if("INPUT"!=document.activeElement.tagName){e.preventDefault(),player.paused?(player.load(),player.play()):player.pause();break}}},!1),document.getElementById("autoplay").addEventListener("click",function(){document.getElementById("autoplay").checked?localStorage.setItem("autoplay",!0):localStorage.removeItem("autoplay")}),document.getElementById("metadata").addEventListener("click",function(){document.getElementById("metadata").checked?(localStorage.removeItem("metadata"),player.paused||getMetadata(np)):(localStorage.setItem("metadata",!1),ice&&ice.stop(),clearInterval(fetchMeta.metaInterv),fetchMeta.metaInterv=null,document.getElementById("song-info").innerText="",document.getElementById("now-playing").style.visibility="hidden",document.getElementById("big-logo").src="img/stations/"+np+".png",document.getElementById("big-logo").onerror=function(){this.src="img/maskable-grey.svg"},createMetadata(r.get(np).name,text.title,"img/stations/"+np+".png"))}),"wakeLock"in navigator&&(document.getElementById("wake-lock").parentElement.style.display="block",document.getElementById("wake-lock").addEventListener("click",function(){if(document.getElementById("wake-lock").checked){if(localStorage.setItem("wLock","true"),!player.paused&&!wLock)try{navigator.wakeLock.request("screen").then(function(e){wLock=e}).catch(function(e){console.log(e)})}catch(e){console.log(e)}}else localStorage.removeItem("wLock"),wLock&&wLock.release().then(function(){wLock=null}).catch(function(e){console.error(e)})}),document.addEventListener("visibilitychange",function(){null!==wLock&&"visible"===document.visibilityState&&navigator.wakeLock.request("screen").then(function(e){wLock=e}).catch(function(e){console.log(e)})})),document.addEventListener("scroll",function(){document.documentElement.scrollTop<400?document.getElementById("scroll-up").style.display="none":document.getElementById("scroll-up").style.display="block"}),document.getElementById("contentID").addEventListener("scroll",function(){document.getElementById("contentID").scrollTop<400?document.getElementById("scroll-up").style.display="none":document.getElementById("scroll-up").style.display="block"}),caches.keys().then(function(e){if(e.length<1)return;let t=document.createElement("p");t.innerText+="Version: "+e[0].match(/[0-9]+\.[0-9]+(\.[0-9]+)?/)[0],t.classList.add("help-text"),t.style.opacity="0.2",t.style.padding="15px",document.getElementById("settings").appendChild(t)}).catch(function(e){console.error(e)})}function batteryGen(e){let t,a=Math.round(7*e);return t=a>6?"battery_full":"battery_"+a+"_bar",'<span class="material-icons" style="font-size:inherit; vertical-align:sub;"> '+t+" </span>"}function aod(){function e(){let e=new Date,i=e.getMinutes(Date.now());i=i<10?"0"+i:i;let s=e.getHours(Date.now())+":"+i;if(o&&(s+=" • "+Math.round(100*o.level)+"%"+batteryGen(o.level)),""!=n.innerHTML&&n.innerHTML!=s){if(player.paused)return void r.click();let e=t.offsetHeight,n=e-e/10;n-=a.offsetHeight,a.style.top=Math.floor(Math.random()*n)+"px"}n.innerHTML=s}if(player.paused)return void toastMessage(text.noSelectedRadio);if(document.documentElement.requestFullscreen)document.documentElement.requestFullscreen();else{if(!document.documentElement.webkitRequestFullscreen)return void toastMessage(text.notSupported);document.documentElement.webkitRequestFullscreen()}let t=document.createElement("div");t.id="aod-bg";let a=document.createElement("div");a.id="aod",t.appendChild(a),document.body.appendChild(t),document.body.style.overflow="hidden";let n=document.createElement("p"),o=null;"getBattery"in navigator&&navigator.getBattery().then(function(e){o=e}).catch(function(e){console.log(e)});let i=setInterval(e,15e3);n.classList.add("clock");let s=document.createElement("div");s.id="aod-controls";let l=document.getElementsByClassName("controls");for(let e=0;e<l.length;e++){let t=l[e].cloneNode(!0);t.id=1==e?"aod-play":"",s.appendChild(t)}let r=document.createElement("button");if(r.innerText="close",r.classList.add("material-icons"),r.classList.add("aod-x"),r.onclick=function(){let e=document.querySelector("#playing .section-header");e.insertBefore(document.getElementById("radio-title"),e.firstChild),document.getElementById("big-logo-container").appendChild(document.getElementById("big-logo")),document.getElementById("song-link").appendChild(document.getElementById("song-info")),clearInterval(i),player.paused||!wLock||document.getElementById("wake-lock").checked||(wLock.release().then(function(){wLock=null}).catch(function(e){console.error(e)}),wLock||console.log("wake lock released")),document.body.style.overflow="auto",document.body.removeChild(t),document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen()},e(),a.appendChild(document.getElementById("radio-title")),a.appendChild(n),a.appendChild(document.getElementById("big-logo")),a.appendChild(document.getElementById("song-info")),a.appendChild(s),a.appendChild(r),!player.paused&&!wLock)try{navigator.wakeLock.request("screen").then(function(e){wLock=e}).catch(function(e){console.log(e)})}catch(e){console.log(e)}}function toastMessage(e){let t=document.getElementById("toast");t&&(document.getElementById("contentID").removeChild(t),clearTimeout(toast.opacity),clearTimeout(toast.remove));let a=document.createElement("div");a.id="toast";let n=document.createElement("span");n.innerText=e,a.appendChild(n),document.getElementById("contentID").appendChild(a),toast.opacity=setTimeout(function(){a.style.opacity="0"},6500),toast.remove=setTimeout(function(){let e=document.getElementById("toast");e&&document.getElementById("contentID").removeChild(e)},7500)}function initCastApi(){var e=cast.framework.CastContext.getInstance();e.setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED});e=cast.framework.CastContext.getInstance();e.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,function(e){e.sessionState==cast.framework.SessionState.SESSION_STARTED&&startCast(),e.sessionState==cast.framework.SessionState.SESSION_ENDED&&(player.load(),player.play())})}function startCast(){try{var e=cast.framework.CastContext.getInstance().getCurrentSession();if(e&&np){var t=new chrome.cast.media.MediaInfo(player.src,"audio/mpeg");t.metadata=new chrome.cast.media.MusicTrackMediaMetadata,t.metadata.title=r.get(np).name,t.metadata.artist=text.title,t.metadata.images=[{url:"https://simpleradio.netlify.app/img/stations/"+np+".png"},{url:"https://simpleradio.netlify.app/img/stations/0custom.png"}];var a=new chrome.cast.media.LoadRequest(t);e.loadMedia(a).then(function(){console.log("Cast Load succeed")},function(e){console.log("Cast Error code: "+e)}),player.pause()}}catch(e){console.log("No cast SDK loaded")}}var _0x20e1=["6007hlzWJP","fromCharCode","2318Nknfyv","stringify","167KYGiJK","694918DCdfPJ","2tWpOcN","random","floor","1DqYLPq","length","1711564Rmkiqr","163mzDyoY","1237mqqmdP","charCodeAt","split","indexOf","load finished","push","toLowerCase","undefined","41NacndT","180556XkhSIW","66569hLsnff"];const rArr=[["bdpstrock",{name:"BDPST Rock",audio:"https://s2.audiostream.hu/bdpstrock_192k",website:"https://bdpstrock.hu",slogan:"Magyarország rockrádiója",lang:"hu"}],["best-dance",{name:"Best - Dance Radio",audio:"https://sonic1-rbx.cloud-center.ro/8018/;",website:"https://best-dance.ro",slogan:"Csak fiatalosan!",lang:"hu"}],["bestfm",{name:"Best FM - Budapest",audio:"https://icast.connectmedia.hu/5101/live.mp3/",metadata:!0,website:"https://bestfm.hu/",slogan:"A legjobb zenék",lang:"hu"}],["chillfm",{name:"Chill FM",audio:"https://edge126.rcs-rds.ro/profm/chillfm.mp3",metadata:!0,website:"https://chillfm.ro",slogan:"Muzică de la A la Zen",lang:"ro"}],["city",{name:"City Rádió",audio:"https://mscp1.gazduireradio.ro/cityradio",website:"https://www.city-radio.ro/",slogan:"A legtöbb sláger",lang:"hu"}],["coolfm",{name:"Cool FM",audio:"https://mediagw.e-tiger.net/stream/coolfm",website:"https://coolfm.hu",slogan:"No.1 Hit Music",lang:"hu"}],["dancefm",{name:"Dance FM",audio:"https://edge126.rcs-rds.ro/profm/dancefm.mp3",metadata:!0,website:"https://dancefm.ro",slogan:"The Beat of Romania",lang:"ro"}],["digifm",{name:"Digi FM",audio:"https://edge76.rcs-rds.ro/digifm/digifm.mp3",website:"https://digifm.ro",slogan:"Ca să știi",lang:"ro"}],["europafm",{name:"Europa FM",audio:"https://astreaming.edi.ro:8443/EuropaFM_aac",metadata:!0,website:"https://europafm.ro",slogan:"Pe aceeași frecvență cu tine!",lang:"ro"}],["ibizaglobal",{name:"Ibiza Global Radio",audio:"https://listenssl.ibizaglobalradio.com:8024/stream",website:"https://ibizaglobalradio.com",slogan:"The Soundtrack of Ibiza",lang:"en"}],["kissfm",{name:"Kiss FM",audio:"https://live.kissfm.ro/kissfm.aacp",metadata:!0,website:"https://kissfm.ro",slogan:"#1 HIT Radio",lang:"ro"}],["kisskm",{name:"Kiss Kiss in the Mix Radio",audio:"https://live.kissfm.ro/kkm.radio",website:"https://soundis.ro/kisskissinthemix/",slogan:"Kiss Kiss in the Mix Radio",lang:"ro"}],["kossuth",{name:"Kossuth Rádió",audio:"https://icast.connectmedia.hu/4736/mr1.mp3",website:"https://mediaklikk.hu/kossuth",slogan:"Otthon a világban",lang:"hu"}],["magicfm",{name:"Magic FM",audio:"https://live.magicfm.ro/magicfm.aacp",metadata:!0,website:"https://magicfm.ro",slogan:"Always Great Music",lang:"ro"}],["marosvr",{name:"Marosvásárhelyi Rádió",audio:"http://stream2.srr.ro:8312/;",website:"https://www.marosvasarhelyiradio.ro/",slogan:"Értünk van, rólunk szól",lang:"hu"}],["mixradio",{name:"Mix Rádió",audio:"https://stream.phost.hu:8006/live",website:"http://www.mixradio.hu/",slogan:"Napjaink slágerei",lang:"hu"}],["onefm",{name:"One FM",audio:"https://live.onefm.ro/onefm.aacp",metadata:!0,website:"https://onefm.ro",slogan:"This is The Party Station",lang:"ro"}],["oneworld",{name:"One World Radio",audio:"https://22193.live.streamtheworld.com/OWR_DABAAC.aac",website:"https://www.tomorrowland.com/home/radio",slogan:"The Sound of Tomorrowland",lang:"en"}],["oxygen",{name:"Oxygen Music",audio:"https://oxygenmusic.hu:8000/oxygenmusic_128",website:"https://oxygenmusic.hu/csatorna",slogan:"Slágerek Maximumon",lang:"hu"}],["oxygenxmas",{name:"Oxygen Xmas",audio:"https://oxygenmusic.hu:8443/xmas_128",website:"https://oxygenmusic.hu/csatorna/oxygen-xmas",slogan:"Slágerek Maximumon",lang:"hu"}],["ozonefm",{name:"Ozone FM",audio:"https://oxygenmusic.hu:8443/ozonefm_128.mp3",website:"https://oxygenmusic.hu/csatorna/ozone-fm",slogan:"Mai Slágerek Maximumon",lang:"hu"}],["petofi",{name:"Petőfi Rádió",audio:"https://icast.connectmedia.hu/4738/mr2.mp3",metadata:!0,website:"https://petofilive.hu",slogan:"Zenében Első!",lang:"hu"}],["profm",{name:"ProFM",audio:"https://edge126.rcs-rds.ro/profm/profm.mp3",metadata:!0,website:"https://profm.ro",slogan:"OPEN RADIO",lang:"ro"}],["radio1",{name:"Rádió 1",audio:"https://icast.connectmedia.hu/5202/live.mp3",metadata:!0,website:"https://radio1.hu",slogan:"Csak igazi mai sláger megy!",lang:"hu"}],["radiogaga-ms",{name:"Rádió GaGa Marosszék",audio:"https://securestreams4.autopo.st:1696/live",website:"https://radiogaga.ro",slogan:"Slágerek és új zenék",lang:"hu"}],["radiogaga-ud",{name:"Rádió GaGa Udvarhelyszék",audio:"https://securestreams5.autopo.st:1992/player",website:"https://radiogaga.ro",slogan:"Slágerek és új zenék",lang:"hu"}],["radioimpuls",{name:"Radio Impuls",audio:"https://live.radio-impuls.ro/stream",website:"https://radioimpuls.ro",slogan:"#HITPEREPEAT",lang:"ro"}],["radiozum",{name:"Radio ZUM",audio:"https://streams.radiozum.md/listen/zum1/ZUM1",website:"https://radiozum.md",slogan:"Muzica proaspăt lansată",lang:"ro"}],["retro",{name:"Retró Rádió",audio:"https://icast.connectmedia.hu/5001/live.mp3",metadata:!0,website:"https://retroradio.hu",slogan:"Minden idők legnagyobb slágerei",lang:"hu"}],["rockfm",{name:"Rock FM",audio:"https://live.rockfm.ro/rockfm.aacp",metadata:!0,website:"https://rockfm.ro",slogan:"It Rocks!",lang:"ro"}],["rocker",{name:"Rocker Rádió",audio:"https://radio.ch3.hu:8200/rocker.mp3",website:"https://rockerradio.online/kezdolap/",slogan:"A Rock ereje!",lang:"hu"}],["roxy",{name:"Roxy Rádió",audio:"https://s2.audiostream.hu/roxy_192k",website:"https://radioroxy.hu",slogan:"Csak mai zene",lang:"hu"}],["slagerfm",{name:"Sláger FM",audio:"https://slagerfm.netregator.hu:7813/slagerfm128.mp3",website:"https://slagerfm.hu/",
slogan:"A legnagyobb slágerek változatosan",lang:"hu"}],["szepvizfm",{name:"Szépvíz FM",audio:"http://szepvizfm.ro:8000/;",website:"http://myonlineradio.hu/szepviz-radio",slogan:"Csak a mienk!",lang:"hu"}],["virginro",{name:"Virgin Radio Romania",audio:"https://astreaming.edi.ro:8443/VirginRadio_aac",metadata:!0,website:"https://virginradio.ro",slogan:"The World Famous Virgin Radio",lang:"ro"}],["virginuk",{name:"Virgin Radio UK",audio:"https://radio.virginradio.co.uk/stream",website:"https://virginradio.co.uk",slogan:"The World Famous Virgin Radio",lang:"en"}]],r=new Map(rArr);var _0x5e16=function(e,t){e-=479;var a=_0x20e1[e];return a};0===r.size&&rArr.forEach(function(e){r.set(e[0],e[1])});const fetchMeta={metaInterv:null,netlifyAPI:!1,count:0},playlist={currentSong:null,songQueue:[],update:function(){let e=document.getElementById("playlist-container"),t=this.songQueue.length-1;if(t<0)return void(e.innerHTML="");3==e.childNodes.length&&e.removeChild(e.lastChild);let a=document.createElement("img");a.src=this.songQueue[t].img,a.setAttribute("loading","lazy"),a.onerror=function(){this.src="img/maskable-grey.svg"};let n=document.createElement("button");n.appendChild(a);let o=document.createElement("div");o.classList.add("textbox");let i=document.createElement("h2");i.innerText=" "+this.songQueue[t].title,n.title=this.songQueue[t].title+" - "+this.songQueue[t].artist;let s=document.createElement("p");""!=this.songQueue[t].artist?s.innerText=this.songQueue[t].artist+" • "+this.songQueue[t].time:s.innerText=this.songQueue[t].time,s.classList.add("slogan"),o.appendChild(i),o.appendChild(s),n.classList.add("list-button"),n.appendChild(o),document.getElementById("playlist-container").prepend(n)}},mediaAPI="mediaSession"in navigator,player=document.getElementById("audio"),ho=location.host;let focused=-1,np=0,favs=[],ice=null,wLock=null;const idozites={ora:0,perc:0,interval:null},toast={opacity:null,remove:null};initPage();