d/div€�æ° æ°dfooter>
最多�留 30 �本机记录
清空记录�æ°æ°æ° d/button€�°æ°
d/div€��
�
�
� �æ°
(() => {
const config = document.getElementById("playerConfig");
const stage = document.getElementById("playerStage");
const nextLink = document.getElementById("nextEpisode");
const pendingPlayerEvents = [];
let hls = null;
let player = null;
let trackingTimer = 0;
let trackingAttempts = 0;
function flushPlayerEvents() {
trackingTimer = 0;
if (window.FlowTrack?.track) {
while (pendingPlayerEvents.length) {
const event = pendingPlayerEvents.shift();
window.FlowTrack.track(event.name, event.properties);
}
return;
}
trackingAttempts += 1;
if (pendingPlayerEvents.length && trackingAttempts < 100) {
trackingTimer = window.setTimeout(flushPlayerEvents, 50);
}
}
function trackPlayer(name, properties = {}) {
const event = {
name,
properties: {
video_id: config.dataset.videoId,
authenticated: Boolean(localStorage.getItem("auth_token")),
need_vip: Number(config.dataset.needVip || "0"),
play_source: config.dataset.playSource,
play_index: config.dataset.playIndex,
...properties
}
};
if (window.FlowTrack?.track) {
window.FlowTrack.track(event.name, event.properties);
return;
}
pendingPlayerEvents.push(event);
if (!trackingTimer) trackingTimer = window.setTimeout(flushPlayerEvents, 0);
}
function durationBucket(seconds) {
if (!Number.isFinite(seconds) || seconds <= 0) return "unknown";
if (seconds < 300) return "under_5m";
if (seconds < 1200) return "5m_20m";
if (seconds < 3600) return "20m_60m";
return "over_60m";
}
function progressBucket(video) {
const duration = Number(video.duration);
const currentTime = Number(video.currentTime);
if (!Number.isFinite(duration) || duration <= 0 || !Number.isFinite(currentTime)) {
return "unknown";
}
const percent = Math.max(0, Math.min(100, (currentTime / duration) * 100));
if (percent < 25) return "0_25";
if (percent < 50) return "25_50";
if (percent < 75) return "50_75";
if (percent < 90) return "75_90";
return "90_100";
}
function authHeaders() {
const token = localStorage.getItem("auth_token");
return token ? { Authorization: `Bearer ${token}` } : {};
}
function savePlayHistory(video) {
const key = "video_play_history";
let items = [];
try { items = JSON.parse(localStorage.getItem(key) || "[]"); } catch (_) {}
const record = {
id: config.dataset.videoId,
name: config.dataset.videoT
-è¯,
episode: config.dataset.episodeName || "æ£ç‰‡",
url: window.location.href,
poster: config.dataset.videoPoster,
watchTime: new Date().toISOString()
};
const currentTime = Number(video?.currentTime);
const duration = Number(video?.duration);
if (Number.isFinite(currentTime) && currentTime >= 0) record.currentTime = currentTime;
if (Number.isFinite(duration)