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:
@@ -2886,27 +2886,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;
|
||||
@@ -2917,20 +2925,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;
|
||||
}
|
||||
});
|
||||
@@ -2940,6 +2946,7 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||
document.body.classList.remove("body-locked");
|
||||
pendingURL = null;
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user