From 8e2a91940811f88d786a8e7b00800d4db7c49191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A9=E7=81=B5=20from=20Fedora?= <1362432220@qq.com> Date: Wed, 13 May 2026 14:51:33 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=B2=20random=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index_template.html | 1 + script.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/index_template.html b/index_template.html index 3b02f08..4431708 100644 --- a/index_template.html +++ b/index_template.html @@ -25,6 +25,7 @@
sina ken tawa jan wan tan nasa.
sina wile kama la o lukin e nasin kama :)
diff --git a/script.js b/script.js index e69de29..9b640f4 100644 --- a/script.js +++ b/script.js @@ -0,0 +1,15 @@ +document.addEventListener('DOMContentLoaded', function () { + const nasaLink = document.getElementById('nasa') + const links = document.querySelectorAll('#peoplelist a') + if (!nasaLink || !links.length) + return + const randomUrl = function () { return links[Math.floor(Math.random() * links.length)].href } + const redirectIfHash = function () { if (location.hash == '#nasa') { location.hash = '', location.href = randomUrl() }} + + redirectIfHash() + if (navigation) { + navigation.addEventListener('navigatesuccess', redirectIfHash) + } else { + nasaLink.addEventListener('click', function () { location.href = randomUrl() }) + } +}) \ No newline at end of file