Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
(function () {
|
|
var mask = document.getElementById("vipDialog");
|
|
if (!mask) return;
|
|
|
|
function openDialog(event) {
|
|
if (event) event.preventDefault();
|
|
mask.classList.add("is-open");
|
|
document.body.style.overflow = "hidden";
|
|
}
|
|
|
|
function closeDialog() {
|
|
mask.classList.remove("is-open");
|
|
document.body.style.overflow = "";
|
|
}
|
|
|
|
function isVipLockedEpisode(target) {
|
|
var episode = target.closest(
|
|
".detail-episode, .play-ep, .play-ep-sheet-item, .detail-h5-ep-item"
|
|
);
|
|
if (!episode) return false;
|
|
// 金币解锁走 coinDialog,不在此打开 VIP 弹窗
|
|
if (episode.hasAttribute("data-coin-dialog-open")) return false;
|
|
return !!episode.querySelector(
|
|
".detail-episode-lock[src*='vip'], .detail-episode-vip, .play-ep-lock[src*='vip'], .play-ep-sheet-lock[src*='vip'], .detail-h5-ep-lock[src*='vip']"
|
|
);
|
|
}
|
|
|
|
document.addEventListener("click", function (event) {
|
|
if (event.target.closest("[data-vip-dialog-open]") || isVipLockedEpisode(event.target)) {
|
|
openDialog(event);
|
|
return;
|
|
}
|
|
|
|
if (event.target.closest("[data-vip-dialog-close]")) {
|
|
closeDialog();
|
|
return;
|
|
}
|
|
|
|
if (event.target === mask) {
|
|
closeDialog();
|
|
}
|
|
});
|
|
|
|
document.addEventListener("keydown", function (event) {
|
|
if (event.key === "Escape" && mask.classList.contains("is-open")) {
|
|
closeDialog();
|
|
}
|
|
});
|
|
|
|
window.openVipDialog = openDialog;
|
|
window.closeVipDialog = closeDialog;
|
|
})();
|