<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ekstrak Link Gambar UPDATE HARIAN</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
text-align: center;
}
textarea {
width: 100%;
height: 150px;
margin-bottom: 10px;
}
button {
margin: 5px;
padding: 10px;
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
}
button:hover {
background-color: #0056b3;
}
#output {
width: 100%;
height: 150px;
margin-top: 10px;
}
</style>
</head>
<body>
<h2>Ekstrak Link Gambar</h2>
<textarea id="inputText" placeholder="Masukkan teks yang berisi link gambar..."></textarea>
<br>
<button onclick="extractLinks()">Ekstrak</button>
<button onclick="copyToClipboard()">Salin ke Clipboard</button>
<button onclick="downloadAsTxt()">Unduh sebagai TXT</button>
<br>
<textarea id="output" readonly placeholder="Hasil ekstraksi akan muncul di sini..."></textarea>
<script>
function extractLinks() {
let inputText = document.getElementById("inputText").value;
let regex = /(https?:\/\/[^\s]+\.(?:jpg|jpeg|png|gif))/gi;
let matches = inputText.match(regex);
if (matches) {
let updatedLinks = matches.map(link => link.replace("/coverthumb/tiny-", "/cover/"));
document.getElementById("output").value = updatedLinks.join("\n");
} else {
document.getElementById("output").value = "Tidak ada link gambar yang ditemukan.";
}
}
function copyToClipboard() {
let output = document.getElementById("output");
output.select();
document.execCommand("copy");
alert("Hasil telah disalin ke clipboard!");
}
function downloadAsTxt() {
let outputText = document.getElementById("output").value;
if (outputText.trim() === "") {
alert("Tidak ada hasil untuk diunduh.");
return;
}
let blob = new Blob([outputText], { type: "text/plain" });
let link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "hasil_ekstraksi.txt";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
</script>
</body>
</html>
Comments