diff --git a/html/poketube.ejs b/html/poketube.ejs index 8eb5e9d..ca1e238 100644 --- a/html/poketube.ejs +++ b/html/poketube.ejs @@ -1493,7 +1493,7 @@ Recommended Videos <% if (!f) { %> - <% k.Video.Recommendations.Video.forEach(x => { %> + <% k.Video.Recommendations?.Video?.forEach(x => { %>
<% if (!optout) { %> @@ -1643,13 +1643,16 @@ Recommended Videos } } + + <% if (k.Video.Recommendations.Video) { %> + let checkbox = document.getElementById("continue"); checkbox.addEventListener('change', function(e) { if (checkbox.checked) { console.log("[AUTOPLAY] enabled"); document.getElementById('video').addEventListener('ended', autoplaynextvideo, false); - let url = window.location.hostname + "/watch?v=<%- k.Video.Recommendations.Video[0].id%>"; + let url = window.location.hostname + "/watch?v=<%- k?.Video?.Recommendations?.Video[0]?.id%>"; function autoplaynextvideo(e) { location.href = "/watch?v=<%- k.Video.Recommendations.Video[0].id%>&autoplay=<%-btoa("1f739d935676111cfff4b4693e3816e664797050" + k.Video.Recommendations.Video[0].id ) %>"; @@ -1663,7 +1666,7 @@ checkbox.addEventListener('change', function(e) { if (/[?&]autoplay=/.test(location.search)) { if (checkbox.checked) { - fetch("https://" + window.location.hostname + "/watch?v=<%- k.Video.Recommendations.Video[0].id%>").then(() => {}) + fetch("https://" + window.location.hostname + "/watch?v=<%- k.Video.Recommendations?.Video[0].id%>").then(() => {}) } } }); @@ -1671,7 +1674,7 @@ checkbox.addEventListener('change', function(e) { if (/[?&]autoplay=/.test(location.search)) { checkbox.checked = true; console.log("[AUTOPLAY] enabled"); - let url = window.location.hostname + "/watch?v=<%- k.Video.Recommendations.Video[0].id%>"; + let url = window.location.hostname + "/watch?v=<%- k.Video.Recommendations?.Video[0].id%>"; document.body.style.cursor = "wait"; // set cursor to "wait" before the fetch request starts fetch(url) .then(response => response.json()) @@ -1686,13 +1689,14 @@ if (/[?&]autoplay=/.test(location.search)) { document.getElementById('video').addEventListener('ended', autoplaynextvideo, false); if (/[?&]autoplay=/.test(location.search)) { if (checkbox.checked) { - fetch("https://" + window.location.hostname + "/watch?v=<%- k.Video.Recommendations.Video[0].id%>").then(() => {}) + fetch("https://" + window.location.hostname + "/watch?v=<%- k.Video.Recommendations?.Video[0].id%>").then(() => {}) } } function autoplaynextvideo(e) { - location.href = "/watch?v=<%- k.Video.Recommendations.Video[0].id%>&autoplay=<%-btoa("1f739d935676111cfff4b4693e3816e664797050" + k.Video.Recommendations.Video[0].id ) %>"; + location.href = "/watch?v=<%- k.Video.Recommendations?.Video[0].id%>&autoplay=<%-btoa("1f739d935676111cfff4b4693e3816e664797050" + k.Video.Recommendations.Video[0].id ) %>"; } } + <% } %> const lazyElements = document.querySelectorAll('*'); @@ -1746,7 +1750,8 @@ if (isFirstLoad) { - + +