Download link (#235)

This commit is contained in:
Zkitefly 2025-07-30 12:35:07 +08:00 committed by GitHub
parent 6a45ef1c6c
commit 32cef46dd2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 56 deletions

View File

@ -28,34 +28,13 @@ Can't download? [Click here to download (alternative)](https://alist.8mi.tech/d/
<script>
async function checkUrl(url) {
try {
const response = await fetch(url, { method: 'HEAD' });
return response.ok;
} catch {
return false;
}
}
async function redirect() {
setTimeout(function() {
const isZhCN = /^zh-CN/i.test(navigator.language);
const url1 = "https://alist.8mi.tech/d/mirror/ms-jdk/Auto/microsoft-jdk-21-windows-aarch64.msi";
const url2 = "https://aka.ms/download-jdk/microsoft-jdk-21-windows-aarch64.msi";
const [url1Available, url2Available] = await Promise.all([
checkUrl(url1),
checkUrl(url2)
]);
if (url1Available && !url2Available) {
window.location.href = url1;
} else if (!url1Available && url2Available) {
window.location.href = url2;
} else {
window.location.href = isZhCN ? url1 : url2;
}
}
setTimeout(redirect, 5000); // Wait 5 seconds
const url = isZhCN
? "https://aka.ms/download-jdk/microsoft-jdk-21-windows-aarch64.msi"
: "https://aka.ms/download-jdk/microsoft-jdk-21-windows-aarch64.msi";
location.href = url;
}, 5000); // Wait 5 seconds
</script>

View File

@ -28,34 +28,12 @@ Can't download? [Click here to download (alternative)](https://alist.8mi.tech/d/
<script>
async function checkUrl(url) {
try {
const response = await fetch(url, { method: 'HEAD' });
return response.ok;
} catch {
return false;
}
}
async function redirect() {
setTimeout(function() {
const isZhCN = /^zh-CN/i.test(navigator.language);
const url1 = "https://alist.8mi.tech/d/mirror/ms-jdk/Auto/microsoft-jdk-21-windows-x64.msi";
const url2 = "https://aka.ms/download-jdk/microsoft-jdk-21-windows-x64.msi";
const [url1Available, url2Available] = await Promise.all([
checkUrl(url1),
checkUrl(url2)
]);
if (url1Available && !url2Available) {
window.location.href = url1;
} else if (!url1Available && url2Available) {
window.location.href = url2;
} else {
window.location.href = isZhCN ? url1 : url2;
}
}
setTimeout(redirect, 5000); // Wait 5 seconds
const url = isZhCN
? "https://aka.ms/download-jdk/microsoft-jdk-21-windows-x64.msi"
: "https://aka.ms/download-jdk/microsoft-jdk-21-windows-x64.msi";
window.location.href = url;
}, 5000); // Wait 5 seconds
</script>