function addOffline(url,res) { var videos = JSON.parse(localStorage.getItem("videos") ?? "[]"); videos.push({ url: url, res: res }); localStorage.setItem('videos',JSON.stringify(videos)); } async function syncOffline() { const json = localStorage.getItem("videos") ?? "[]"; if(json !== "[]") { const resp = await fetch('/api/v1/add',{ body: json, headers: { 'Content-Type': 'application/json' }, method: "POST" }); if(resp.ok) { localStorage.removeItem('videos'); } } } if(navigator.online) { syncOffline(); } window.addEventListener('online',()=>{ syncOffline(); }); async function getPersonalTempLink() { const searchParams = new URLSearchParams(window.location.search); const ent = searchParams.get("name"); if(ent) { const resp=await fetch(`./api/v1/personal_tmp_link?name=${encodeURIComponent(ent)}`); if(resp.ok) { const text = await resp.text(); the_playlist_url.innerText = text; the_playlist_url.href = text; ui("#dialog"); } } }