Spaces:
Sleeping
Sleeping
TXAVLOG commited on
Commit ·
a9cf72a
1
Parent(s): 1acb655
Fix third-party cookie blocking and infinite reload loops inside iframes
Browse files- src/layouts/Layout.astro +28 -7
- src/pages/index.astro +2 -2
src/layouts/Layout.astro
CHANGED
|
@@ -209,7 +209,7 @@ if (showDecoy) {
|
|
| 209 |
if (bypass === 'true') {
|
| 210 |
localStorage.setItem('zalo_browser_token', 'txabypass');
|
| 211 |
localStorage.setItem('zalo_access_status', 'approved');
|
| 212 |
-
document.cookie = "zalo_access_approved=true; path=/; max-age=" + (365 * 24 * 60 * 60);
|
| 213 |
}
|
| 214 |
|
| 215 |
// Dọn dẹp thanh địa chỉ ngay lập tức để giữ URL sạch đẹp
|
|
@@ -220,11 +220,32 @@ if (showDecoy) {
|
|
| 220 |
}
|
| 221 |
// 2. Nếu truy cập trực tiếp nhưng đã có token trong localStorage từ trước
|
| 222 |
else if (hasLocalToken) {
|
| 223 |
-
const hasCookie = document.cookie.split('; ').some(row => row.startsWith('nrotxa_referred='));
|
| 224 |
if (!hasCookie) {
|
| 225 |
-
// Tự động khôi phục cookie
|
| 226 |
-
document.cookie = "nrotxa_referred=true; path=/; max-age=" + (365 * 24 * 60 * 60);
|
| 227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
}
|
| 229 |
}
|
| 230 |
|
|
@@ -268,7 +289,7 @@ if (showDecoy) {
|
|
| 268 |
onConfirm: (pass) => {
|
| 269 |
if (pass === 'phimtxadinhvai') {
|
| 270 |
localStorage.setItem('txa_referred_token', 'true');
|
| 271 |
-
document.cookie = "nrotxa_referred=true; path=/; max-age=" + (365 * 24 * 60 * 60);
|
| 272 |
|
| 273 |
if (window.txatoast) {
|
| 274 |
window.txatoast.success("🎉 Mật mã chính xác! Đang kết nối rạp phim...", 2000);
|
|
@@ -291,7 +312,7 @@ if (showDecoy) {
|
|
| 291 |
const pass = prompt("Vui lòng nhập mật mã mở khóa DPTXA Cinema:");
|
| 292 |
if (pass === 'phimtxadinhvai') {
|
| 293 |
localStorage.setItem('txa_referred_token', 'true');
|
| 294 |
-
document.cookie = "nrotxa_referred=true; path=/; max-age=" + (365 * 24 * 60 * 60);
|
| 295 |
alert("🎉 Mật mã chính xác! Đang kết nối rạp phim...");
|
| 296 |
window.location.reload();
|
| 297 |
} else if (pass !== null) {
|
|
|
|
| 209 |
if (bypass === 'true') {
|
| 210 |
localStorage.setItem('zalo_browser_token', 'txabypass');
|
| 211 |
localStorage.setItem('zalo_access_status', 'approved');
|
| 212 |
+
document.cookie = "zalo_access_approved=true; path=/; max-age=" + (365 * 24 * 60 * 60) + "; SameSite=None; Secure";
|
| 213 |
}
|
| 214 |
|
| 215 |
// Dọn dẹp thanh địa chỉ ngay lập tức để giữ URL sạch đẹp
|
|
|
|
| 220 |
}
|
| 221 |
// 2. Nếu truy cập trực tiếp nhưng đã có token trong localStorage từ trước
|
| 222 |
else if (hasLocalToken) {
|
| 223 |
+
const hasCookie = document.cookie.split('; ').some(row => row.trim().startsWith('nrotxa_referred='));
|
| 224 |
if (!hasCookie) {
|
| 225 |
+
// Tự động khôi phục cookie với cờ hỗ trợ iframe (SameSite=None; Secure)
|
| 226 |
+
document.cookie = "nrotxa_referred=true; path=/; max-age=" + (365 * 24 * 60 * 60) + "; SameSite=None; Secure";
|
| 227 |
+
|
| 228 |
+
// Kiểm tra xem cookie có thực sự set được không (tránh lặp reload vô tận nếu trình duyệt chặn cookie trong iframe)
|
| 229 |
+
const verifyCookie = document.cookie.split('; ').some(row => row.trim().startsWith('nrotxa_referred='));
|
| 230 |
+
if (verifyCookie) {
|
| 231 |
+
window.location.reload();
|
| 232 |
+
} else {
|
| 233 |
+
console.warn("[DPTXA] Cookies are blocked by the browser inside this iframe (Hugging Face). Please access directly.");
|
| 234 |
+
// Nếu đang ở trong iframe của Hugging Face và bị chặn cookie, hiển thị thông báo đẹp mắt hướng dẫn truy cập trực tiếp
|
| 235 |
+
if (window.self !== window.top) {
|
| 236 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 237 |
+
const noticeDiv = document.createElement('div');
|
| 238 |
+
noticeDiv.style.cssText = "position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 100000; background: rgba(18, 20, 29, 0.95); backdrop-filter: blur(20px); color: white; padding: 32px; border-radius: 24px; font-family: 'Outfit', sans-serif; text-align: center; box-shadow: 0 30px 100px rgba(0,0,0,0.8); border: 1px solid rgba(255,255,255,0.1); max-width: 90%; width: 440px; animation: modal-enter 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;";
|
| 239 |
+
noticeDiv.innerHTML = `
|
| 240 |
+
<div style="font-size: 40px; margin-bottom: 20px;">⚠️</div>
|
| 241 |
+
<div style="font-size: 16px; margin-bottom: 12px; font-weight: 900; text-transform: uppercase; tracking-wider; color: #f43f5e;">Bị chặn Cookie trên Iframe</div>
|
| 242 |
+
<div style="font-size: 13px; opacity: 0.8; margin-bottom: 24px; font-weight: 500; line-height: 1.6; color: #9ca3af;">Trình duyệt của bạn đang chặn Cookie bên thứ ba trong khung Iframe của Hugging Face. Để mở khóa và xem phim mượt mà, vui lòng truy cập trực tiếp bằng liên kết dưới đây:</div>
|
| 243 |
+
<a href="https://txavlog-dptxa-proxy.hf.space" target="_blank" style="display: block; background: linear-gradient(135deg, #8b5cf6, #6366f1); color: white; padding: 14px 20px; border-radius: 12px; text-decoration: none; font-weight: 900; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; transition: all 0.3s; box-shadow: 0 10px 25px rgba(124,58,237,0.3);">Vào rạp phim trực tiếp ngay</a>
|
| 244 |
+
`;
|
| 245 |
+
document.body.appendChild(noticeDiv);
|
| 246 |
+
});
|
| 247 |
+
}
|
| 248 |
+
}
|
| 249 |
}
|
| 250 |
}
|
| 251 |
|
|
|
|
| 289 |
onConfirm: (pass) => {
|
| 290 |
if (pass === 'phimtxadinhvai') {
|
| 291 |
localStorage.setItem('txa_referred_token', 'true');
|
| 292 |
+
document.cookie = "nrotxa_referred=true; path=/; max-age=" + (365 * 24 * 60 * 60) + "; SameSite=None; Secure";
|
| 293 |
|
| 294 |
if (window.txatoast) {
|
| 295 |
window.txatoast.success("🎉 Mật mã chính xác! Đang kết nối rạp phim...", 2000);
|
|
|
|
| 312 |
const pass = prompt("Vui lòng nhập mật mã mở khóa DPTXA Cinema:");
|
| 313 |
if (pass === 'phimtxadinhvai') {
|
| 314 |
localStorage.setItem('txa_referred_token', 'true');
|
| 315 |
+
document.cookie = "nrotxa_referred=true; path=/; max-age=" + (365 * 24 * 60 * 60) + "; SameSite=None; Secure";
|
| 316 |
alert("🎉 Mật mã chính xác! Đang kết nối rạp phim...");
|
| 317 |
window.location.reload();
|
| 318 |
} else if (pass !== null) {
|
src/pages/index.astro
CHANGED
|
@@ -425,7 +425,7 @@ const isApprovedServer = Astro.cookies.get('zalo_access_approved')?.value === 't
|
|
| 425 |
// --- ADMIN ABSOLUTE BYPASS ---
|
| 426 |
const isAdmin = document.cookie.split('; ').some(row => row.trim().startsWith('auth_token='));
|
| 427 |
if (isAdmin) {
|
| 428 |
-
document.cookie = "zalo_access_approved=true; path=/; max-age=" + (365 * 24 * 60 * 60);
|
| 429 |
localStorage.setItem('zalo_access_status', 'approved');
|
| 430 |
container.innerHTML = `
|
| 431 |
<a
|
|
@@ -451,7 +451,7 @@ const isApprovedServer = Astro.cookies.get('zalo_access_approved')?.value === 't
|
|
| 451 |
async function proceedWithSetup() {
|
| 452 |
// 2. Hàm set cookie phê duyệt
|
| 453 |
function setApprovedCookie() {
|
| 454 |
-
document.cookie = "zalo_access_approved=true; path=/; max-age=" + (365 * 24 * 60 * 60);
|
| 455 |
localStorage.setItem('zalo_access_status', 'approved');
|
| 456 |
}
|
| 457 |
|
|
|
|
| 425 |
// --- ADMIN ABSOLUTE BYPASS ---
|
| 426 |
const isAdmin = document.cookie.split('; ').some(row => row.trim().startsWith('auth_token='));
|
| 427 |
if (isAdmin) {
|
| 428 |
+
document.cookie = "zalo_access_approved=true; path=/; max-age=" + (365 * 24 * 60 * 60) + "; SameSite=None; Secure";
|
| 429 |
localStorage.setItem('zalo_access_status', 'approved');
|
| 430 |
container.innerHTML = `
|
| 431 |
<a
|
|
|
|
| 451 |
async function proceedWithSetup() {
|
| 452 |
// 2. Hàm set cookie phê duyệt
|
| 453 |
function setApprovedCookie() {
|
| 454 |
+
document.cookie = "zalo_access_approved=true; path=/; max-age=" + (365 * 24 * 60 * 60) + "; SameSite=None; Secure";
|
| 455 |
localStorage.setItem('zalo_access_status', 'approved');
|
| 456 |
}
|
| 457 |
|