Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
hung319 authored Jan 11, 2025
1 parent 1c388f7 commit 15b6ebb
Showing 1 changed file with 11 additions and 202 deletions.
213 changes: 11 additions & 202 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,199 +7,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js"></script>
<style>
:root {
--primary-color: #1a73e8;
--hover-color: #1557b0;
--background-color: #f0f8ff;
--card-background: white;
}

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
font-family: 'Segoe UI', Arial, sans-serif;
background-color: var(--background-color);
color: #333;
line-height: 1.6;
padding-top: 20px;
}

.top-info {
background-color: var(--primary-color);
color: white;
padding: 10px;
position: fixed;
top: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 0.9em;
z-index: 1000;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.container {
max-width: 800px;
margin: 60px auto 20px;
padding: 20px;
}

.download-card {
background-color: var(--card-background);
border-radius: 15px;
padding: 30px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
margin: 20px auto;
transition: transform 0.3s ease;
}

.download-card:hover {
transform: translateY(-5px);
}

h1 {
color: var(--primary-color);
margin-bottom: 30px;
font-size: 2.2em;
text-align: center;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.input-group {
margin: 20px 0;
text-align: center;
}

label {
font-weight: 500;
color: #444;
display: block;
margin-bottom: 10px;
}

input[type="number"] {
font-size: 16px;
padding: 12px 20px;
border: 2px solid #ddd;
border-radius: 8px;
width: 150px;
transition: all 0.3s ease;
text-align: center;
}

input[type="number"]:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.2);
}

button {
background-color: var(--primary-color);
color: white;
border: none;
border-radius: 8px;
padding: 12px 30px;
font-size: 16px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
display: block;
margin: 20px auto;
min-width: 200px;
}

button:hover {
background-color: var(--hover-color);
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

button:active {
transform: translateY(0);
}

button:disabled {
background-color: #cccccc;
cursor: not-allowed;
transform: none;
}

#status {
margin-top: 20px;
padding: 15px;
border-radius: 8px;
background-color: rgba(26, 115, 232, 0.1);
color: var(--primary-color);
font-weight: 500;
text-align: center;
animation: fadeIn 0.5s ease;
}

.loading {
display: none;
margin: 20px auto;
width: 50px;
height: 50px;
border: 5px solid #f3f3f3;
border-top: 5px solid var(--primary-color);
border-radius: 50%;
animation: spin 1s linear infinite;
}

.loading.active {
display: block;
}

@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}

@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

.input-group {
margin: 20px 0;
text-align: center; /* Căn giữa label */
}

select {
font-size: 16px;
padding: 12px;
border-radius: 8px;
border: 2px solid #ddd;
background-color: white;
width: 200px; /* Chiều rộng cho select */
transition: all 0.3s ease;
margin-top: 10px;
display: inline-block; /* Giúp select nằm giữa */
text-align: center; /* Căn giữa các tên API trong select */
}

option {
text-align: center; /* Căn giữa các tên API trong các option */
}

select:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.2);
}
/* (style không thay đổi) */
</style>
</head>
<body>
Expand All @@ -216,6 +24,7 @@ <h1>Tải ảnh NSFW</h1>
<input type="number" id="imageCount" value="50" min="1" max="100">
</div>

<!-- Dropdown để chọn API -->
<div class="input-group">
<label for="apiSelector">Chọn API:</label>
<select id="apiSelector">
Expand All @@ -232,6 +41,7 @@ <h1>Tải ảnh NSFW</h1>
</div>

<script>
// Cập nhật datetime
function updateDateTime() {
const now = new Date();
const options = { timeZone: "Asia/Ho_Chi_Minh", year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit", hour12: false };
Expand All @@ -242,15 +52,16 @@ <h1>Tải ảnh NSFW</h1>

const CONCURRENT_LIMIT = 1000000;

// URL API dựa trên lựa chọn của người dùng
const WORKER_URL = 'https://white-mud-f95d.hoangxg4.workers.dev/?apiUrl=';
const API_URLS = {
'waifu.pics': 'https://waifu.pics/api/nsfw/waifu',
'konachan': 'https://konachan.net/post.json?tags=order:random+rating:explicit&limit=1',
'yande.re': 'https://yande.re/post.json?tags=order:random+rating:explicit&limit=1'
'konachan': 'https://konachan.net/post.json?tags=order:random&limit=1',
'yande.re': 'https://yande.re/post.json?tags=order:random&limit=1'
};

const generateRandomString = (length) => Array.from({ length }, () => 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.charAt(Math.floor(Math.random() * 62))).join('');

const fetchWithRetry = async (url, retries = 3) => {
try {
const response = await fetch(url);
Expand All @@ -268,7 +79,7 @@ <h1>Tải ảnh NSFW</h1>
try {
const response = await fetchWithRetry(`${WORKER_URL}${encodeURIComponent(apiUrl)}`);
const data = await response.json();
const imageUrl = selectedApi === 'waifu.pics' ? data.url : data[0].file_url;
const imageUrl = selectedApi === 'waifu.pics' ? data.url : data[0].file_url; // Điều chỉnh cho từng API
const imageResponse = await fetchWithRetry(imageUrl);
const imageBlob = await imageResponse.blob();
const fileName = imageUrl.split('/').pop();
Expand Down Expand Up @@ -308,14 +119,12 @@ <h1>Tải ảnh NSFW</h1>
downloadBtn.disabled = true;
loadingAnimation.classList.add('active');
status.textContent = 'Đang tải ảnh...';

try {
const zipBlob = await downloadImages(imageCount);
const fileName = `images-${generateRandomString(6)}.zip`;
saveAs(zipBlob, fileName);
status.textContent = 'Tải về hoàn tất!';
saveAs(zipBlob, `${generateRandomString(10)}.zip`);
status.textContent = 'Đã tải xong!';
} catch (error) {
status.textContent = 'Lỗi khi tải ảnh!';
status.textContent = 'Lỗi khi tải ảnh.';
} finally {
downloadBtn.disabled = false;
loadingAnimation.classList.remove('active');
Expand Down

0 comments on commit 15b6ebb

Please sign in to comment.