function getConfigInstance(){let Config=require('conf');return new Config('yout-playlist');}
function loadPlaylistItems(){let configuration=getConfigInstance();playlists=configuration.get('playlist');for(let value in playlists){let body=document.getElementById('menu');let button=document.createElement('button');body.appendChild(button);button.setAttribute('id',value);button.setAttribute('class','playlists-item');button.setAttribute('onclick','changePlaylist("'+value+'")');button.innerHTML=configuration.get('playlist.'+value+'.name');}
configuration=null;}
function convertPlaylistLink(url){let old_url=url.split('=');let new_url;if(old_url.length==3){new_url='https://www.youtube.com/embed/'+old_url[1].replace('&','?')+'='+old_url[2]+'&iv_load_policy=3&loop=1&hd=1&rel=0&fs=0';}else{new_url='https://www.youtube.com/embed/videoseries?list='+old_url[1]+'&iv_load_policy=3&loop=1&hd=1&rel=0&fs=0';}
return new_url;}
function changePlaylistBackgroundColor(playlist){let configuration=getConfigInstance();if(configuration.has('playlist.'+playlist)){let reset=document.getElementsByClassName("playlists-item");for(i=0;i<reset.length;i++){reset[i].style.backgroundColor='#262626';}
document.getElementById(playlist).style.backgroundColor='#821f31';}}
function changePlaylist(playlist){let configuration=getConfigInstance();let url=configuration.get('playlist.'+playlist+'.url');document.getElementById("webview").loadURL(convertPlaylistLink(url),{httpReferrer:"https://www.youtube.com"});changePlaylistBackgroundColor(playlist);configuration=null;}
function refreshPlaylist(){let webview=document.getElementById("webview");webview.loadURL(webview.getURL(),{httpReferrer:"https://www.youtube.com"});}
