Daftar Isi Blogspot
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Ekstrak Daftar Isi Blogspot</title>
<style>
body { font-family: Arial, sans-serif; padding: 20px; }
input { width: 80%; padding: 10px; }
button { padding: 10px 15px; margin-left: 10px; }
ul { margin-top: 20px; padding-left: 20px; }
li { margin-bottom: 5px; }
</style>
</head>
<body>
<h2>Daftar Isi Blogspot</h2>
<input type="text" id="blogUrl" placeholder="Contoh: https://drop-co.blogspot.com">
<button onclick="generateTOC()">Ekstrak</button>
<ul id="toc"> </ul>
<script>
function generateTOC() {
const blogUrl = document.getElementById('blogUrl').value.trim();
if (!blogUrl.startsWith('http')) return alert('Masukkan URL blog lengkap!');
const feedUrl = blogUrl + '/feeds/posts/default?alt=json&max-results=999';
const proxy = 'https://api.allorigins.win/get?url=' + encodeURIComponent(feedUrl);
fetch(proxy)
.then(res => res.ok ? res.json() : Promise.reject())
.then(data => {
const json = JSON.parse(data.contents);
const posts = json.feed.entry;
const tocList = document.getElementById('toc');
tocList.innerHTML = '';
if (!posts) {
tocList.innerHTML = '<li>Tidak ada posting ditemukan.</li>';
return;
}
posts.forEach(post => {
const title = post.title.$t;
const link = post.link.find(l => l.rel === 'alternate').href;
tocList.innerHTML += `<li><a href="${link}" target="_blank">${title}</a></li>`;
});
})
.catch(() => {
document.getElementById('toc').innerHTML = '<li>Gagal mengambil daftar isi.</li>';
});
}
</script>
</body>
</html>


No comments:
Post a Comment