1
0
mirror of https://gitlab.com/lolmam/Phigros-Android-History.git synced 2026-02-04 16:21:11 +00:00

Fix popup

This commit is contained in:
2025-12-08 17:22:04 +03:00
parent 3144a68112
commit 423b74c613
3 changed files with 87 additions and 66 deletions

View File

@@ -1215,27 +1215,35 @@
</html>
<script>
function setCookie(name, value, days) {
const expires = new Date(Date.now() + days * 864e5).toUTCString();
document.cookie = `${name}=${value}; expires=${expires}; path=/`;
}
document.addEventListener("DOMContentLoaded", () => {
function getCookie(name) {
return document.cookie.split("; ").find(c => c.startsWith(name + "="))?.split("=")[1];
}
let pendingURL = null;
window.addEventListener("DOMContentLoaded", () => {
const popup = document.getElementById("license-popup");
const agree = document.getElementById("agree");
const closeBtn = document.getElementById("close-popup");
document.querySelectorAll(".btn, .btn.alt").forEach(el => {
function setCookie(name, value, days) {
const expires = new Date(Date.now() + days * 864e5).toUTCString();
document.cookie = `${name}=${value}; expires=${expires}; path=/; SameSite=Lax`;
}
function getCookie(name) {
return document.cookie
.split("; ")
.find(c => c.startsWith(name + "="))
?.split("=")[1];
}
let pendingURL = null;
const buttons = document.querySelectorAll(".btn, .btn.alt");
buttons.forEach(el => {
el.addEventListener("click", e => {
if (el.classList.contains("btn-unavailable")) return;
if (getCookie("licenseAccepted")) return;
if (getCookie("licenseAccepted")) {
return;
}
e.preventDefault();
pendingURL = el.href;
@@ -1246,20 +1254,18 @@ window.addEventListener("DOMContentLoaded", () => {
});
agree.addEventListener("click", () => {
setCookie("licenseAccepted", "true", 30);
setCookie("licenseAccepted", "true", 365);
popup.classList.add("hidden");
document.body.classList.remove("body-locked");
if (pendingURL) {
// Auto-trigger download immediately
const directDownload = document.createElement("a");
directDownload.href = pendingURL;
directDownload.download = "";
document.body.appendChild(directDownload);
directDownload.click();
directDownload.remove();
const a = document.createElement("a");
a.href = pendingURL;
a.download = "";
document.body.appendChild(a);
a.click();
a.remove();
pendingURL = null;
}
});
@@ -1269,6 +1275,7 @@ window.addEventListener("DOMContentLoaded", () => {
document.body.classList.remove("body-locked");
pendingURL = null;
});
});
</script>