2022-11-13 11:37:30 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Ulož.to Rychle</title>
|
|
|
|
<style>
|
2023-02-06 22:18:56 +01:00
|
|
|
body {display: flex; justify-content: center; align-items: center; height: 100vh; font-family: sans-serif; text-align: center; font-size: 17px; background: #4a0f4d; color: #fff; line-height: 1.5;}
|
2022-11-13 11:37:30 +01:00
|
|
|
.page {max-width: 550px; width: 100%;}
|
|
|
|
.input {display: flex; gap: 5px; flex-flow: row; justify-content: space-between; width: 100%; margin-top: 30px;}
|
2023-02-06 22:18:56 +01:00
|
|
|
.input *, .result {background-color: #702673; border: 2px solid #330a35; border-radius: 5px; padding: 10px 15px; font-size: 17px; outline: 0; color: #fff;}
|
2022-11-13 11:37:30 +01:00
|
|
|
.input input {width: 100%;}
|
|
|
|
.input button {background: #702673;}
|
|
|
|
.input button:hover {background-color: #4a0f4d; cursor: pointer;}
|
2023-02-06 22:18:56 +01:00
|
|
|
.result {padding: 15px; margin-top: 20px; display: none; text-align: left; flex-direction: column; gap: 10px;}
|
|
|
|
.result a {color: #fff8;}
|
|
|
|
.result .info {display: flex; flex-direction: column; gap: 5px;}
|
|
|
|
.result .download {display: flex; gap: 10px; flex-wrap: wrap; font-size: 15px;}
|
|
|
|
.result :is(small, .linkback) {font-size: 14px;}
|
|
|
|
.status {display: none; text-align: center; margin-top: 20px;}
|
2022-11-13 11:37:30 +01:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="page">
|
|
|
|
<h1>Ulož.to Rychle</h1>
|
|
|
|
<p>Stahujte z Ulož.to vysokou rychlostí</p>
|
|
|
|
<div class="input">
|
|
|
|
<input placeholder="Vložte odkaz z Ulož.to" /> <button onclick="download();">Získat</button>
|
|
|
|
</div>
|
|
|
|
<div class="result"></div>
|
2023-02-06 22:18:56 +01:00
|
|
|
<div class="status">Získávám informace o souboru...</div>
|
2022-11-13 11:37:30 +01:00
|
|
|
</div>
|
|
|
|
<script>
|
2023-02-06 22:18:56 +01:00
|
|
|
async function download() {
|
2022-11-13 11:37:30 +01:00
|
|
|
let url = document.querySelector("input").value;
|
|
|
|
let regex = new RegExp(/https:\/\/.*(ulozto\.cz|uloz\.to)\/file\/(.*?)\/.*/gm);
|
|
|
|
let res = regex.exec(url);
|
|
|
|
if(!res) return alert("Neplatná URL!");
|
|
|
|
let id = res[2];
|
|
|
|
let new_url = new URL(`/u/${id}`, location.origin);
|
2023-02-06 22:18:56 +01:00
|
|
|
let result = document.querySelector(".result");
|
|
|
|
let status = document.querySelector(".status");
|
|
|
|
status.style.display = "block";
|
|
|
|
try {
|
|
|
|
let info = await api(`/status/${id}`);
|
|
|
|
result.style.display = "flex";
|
2023-02-07 14:02:37 +01:00
|
|
|
result.innerHTML = `<div class="info"><div><b>${info.file.name}</b> <a target="_blank" class="linkback" href="https://uloz.to/file/${id}">ulož.to</a></div><small>${parse_size(info.file.size)}</small></div><div class="download"><code>${new_url}</code> <a href="${new_url}" download="${info.file.name}">Stáhnout</a></div>`;
|
2023-02-06 22:18:56 +01:00
|
|
|
} catch {
|
|
|
|
alert("Neplatná URL!");
|
|
|
|
}
|
|
|
|
status.style.display = "none";
|
|
|
|
}
|
|
|
|
async function api(url) {
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
|
if(this.readyState !== 4) return;
|
|
|
|
if(!this.responseText) reject(this);
|
|
|
|
try {
|
|
|
|
resolve(JSON.parse(this.responseText));
|
|
|
|
} catch(e) {
|
|
|
|
resolve({error: "api"});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
xhr.open("GET", url, true);
|
|
|
|
xhr.send();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function parse_size(bytes) {
|
|
|
|
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
|
|
let unitIndex = 0;
|
|
|
|
while (bytes >= 1024) {
|
|
|
|
bytes /= 1024;
|
|
|
|
unitIndex++;
|
|
|
|
}
|
|
|
|
return `${bytes.toFixed(2)} ${units[unitIndex]}`;
|
2022-11-13 11:37:30 +01:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|