Update html/watch.ejs
This commit is contained in:
parent
276d698626
commit
145cd1a694
@ -2481,42 +2481,22 @@ if (/[?&]autoplay=/.test(location.search)) {
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
function sendStats(videoId) {
|
(function addStats() {
|
||||||
if (!videoId) return
|
const url = "/static/improving-poke.js"
|
||||||
|
|
||||||
// respect per-browser opt-out
|
if (document.querySelector(`script[src="${url}"]`)) return
|
||||||
try {
|
|
||||||
if (localStorage.getItem("poke_stats_optout") === "1") return
|
|
||||||
} catch (e) {
|
|
||||||
// if localStorage is blocked, just don't send anything
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let userId
|
const s = document.createElement("script")
|
||||||
|
s.src = url
|
||||||
|
s.type = "text/javascript"
|
||||||
|
s.async = true
|
||||||
|
s.defer = true
|
||||||
|
|
||||||
try {
|
s.onload = () => console.log("[Poke] improving-poke.js loaded successfully")
|
||||||
userId = localStorage.getItem("poke_uid")
|
s.onerror = () => console.warn("[Poke] failed to load improving-poke.js")
|
||||||
if (!userId) {
|
|
||||||
userId = "u_" + Math.random().toString(36).slice(2) + Date.now()
|
|
||||||
localStorage.setItem("poke_uid", userId)
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// if we can't read/write localStorage, don't send stats
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const payload = { videoId, userId }
|
|
||||||
|
|
||||||
fetch("/api/stats", {
|
|
||||||
method: "POST",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify(payload),
|
|
||||||
keepalive: true
|
|
||||||
}).catch(() => {})
|
|
||||||
}
|
|
||||||
|
|
||||||
sendStats(new URLSearchParams(location.search).get("v"))
|
|
||||||
|
|
||||||
|
document.head.appendChild(s)
|
||||||
|
})()
|
||||||
function toggleTheaterMode() {
|
function toggleTheaterMode() {
|
||||||
var videoPlayerContainer = document.querySelector('.video-player-container');
|
var videoPlayerContainer = document.querySelector('.video-player-container');
|
||||||
if (videoPlayerContainer.classList.contains('theatermodeon')) {
|
if (videoPlayerContainer.classList.contains('theatermodeon')) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user