fb-dl / test.html
devusman's picture
update
a2e646a
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FB Video Downloader</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
<style>
* {
box-sizing: border-box;
}
body {
font-family: 'Poppins', sans-serif;
max-width: 700px;
margin: 0 auto;
padding: 20px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #333;
min-height: 100vh;
}
h1 {
text-align: center;
color: white;
margin-bottom: 30px;
font-weight: 600;
font-size: 2.5em;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
form {
display: flex;
margin-bottom: 30px;
background: white;
border-radius: 50px;
overflow: hidden;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}
input {
flex: 1;
padding: 15px 20px;
border: none;
font-size: 16px;
outline: none;
}
button {
padding: 15px 30px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
cursor: pointer;
font-weight: 600;
transition: transform 0.2s;
}
button:hover {
transform: translateY(-2px);
}
#results {
display: none;
background: white;
border-radius: 20px;
padding: 30px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}
#loader {
display: none;
text-align: center;
margin: 40px;
color: white;
font-size: 18px;
}
.story {
margin-bottom: 30px;
border: 1px solid #e0e0e0;
padding: 20px;
border-radius: 15px;
background: #fafafa;
transition: box-shadow 0.3s;
}
.story:hover {
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}
.story h3 {
margin: 0 0 15px 0;
color: #667eea;
font-size: 1.2em;
font-weight: 600;
}
.preview-container {
text-align: center;
margin-bottom: 20px;
}
video,
img,
audio {
width: 200px;
height: 200px;
object-fit: cover;
border-radius: 10px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
display: block;
margin: 0 auto;
}
audio {
height: auto;
width: 200px;
}
ul {
list-style: none;
padding: 0;
display: flex;
flex-wrap: wrap;
gap: 10px;
}
li {
flex: 1;
min-width: 150px;
}
a {
display: block;
padding: 12px;
background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
color: white;
text-decoration: none;
border-radius: 8px;
text-align: center;
font-weight: 500;
transition: transform 0.2s, box-shadow 0.2s;
}
a:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}
#back {
background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
border: none;
padding: 12px 24px;
color: white;
border-radius: 8px;
cursor: pointer;
font-weight: 500;
transition: transform 0.2s;
margin-top: 20px;
}
#back:hover {
transform: translateY(-2px);
}
</style>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
<h1>Facebook Video Downloader</h1>
<form id="form">
<input type="text" id="url" placeholder="Enter Facebook URL" required>
<button type="submit">Get Downloads</button>
</form>
<div id="loader">Loading...</div>
<div id="results">
<h2 style="text-align: center; color: #333; margin-bottom: 20px;">Download Links</h2>
<div id="stories-container"></div>
<button id="back">Back</button>
</div>
<script>
const form = document.getElementById('form');
const urlInput = document.getElementById('url');
const loader = document.getElementById('loader');
const results = document.getElementById('results');
const storiesContainer = document.getElementById('stories-container');
const back = document.getElementById('back');
const proxy = 'https://corsproxy.io/?';
form.addEventListener('submit', async (e) => {
e.preventDefault();
const fbUrl = urlInput.value;
loader.style.display = 'block';
try {
const targetUrl = 'https://getvidfb.com/';
const proxiedUrl = proxy + encodeURIComponent(targetUrl);
const response = await axios.post(proxiedUrl, {
url: fbUrl,
lang: 'en',
type: 'redirect'
}, {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
const parser = new DOMParser();
const doc = parser.parseFromString(response.data, 'text/html');
const storyBlocks = doc.querySelectorAll('.snaptikvid');
storiesContainer.innerHTML = '';
if (storyBlocks.length === 0) {
const links = doc.querySelectorAll('#snaptik-video a.abutton');
const storyDiv = document.createElement('div');
storyDiv.className = 'story';
storyDiv.innerHTML = '<h3>Story #0</h3>';
const previewContainer = document.createElement('div');
previewContainer.className = 'preview-container';
let previewAdded = false;
const ul = document.createElement('ul');
links.forEach(link => {
const title = link.querySelector('span').textContent.trim();
const href = link.getAttribute('href');
const li = document.createElement('li');
let preview;
if (!previewAdded && title.includes('Video/Mp4')) {
preview = document.createElement('video');
preview.controls = true;
preview.src = href;
previewContainer.appendChild(preview);
previewAdded = true;
} else if (!previewAdded && title.includes('Photo/Jpg')) {
preview = document.createElement('img');
preview.src = href;
previewContainer.appendChild(preview);
previewAdded = true;
} else if (!previewAdded && title.includes('Audio/Mp3')) {
preview = document.createElement('audio');
preview.controls = true;
preview.src = href;
previewContainer.appendChild(preview);
previewAdded = true;
}
const a = document.createElement('a');
a.href = href;
a.textContent = title;
a.download = '';
li.appendChild(a);
ul.appendChild(li);
});
storyDiv.appendChild(previewContainer);
storyDiv.appendChild(ul);
storiesContainer.appendChild(storyDiv);
} else {
storyBlocks.forEach((storyBlock, index) => {
const storyDiv = document.createElement('div');
storyDiv.className = 'story';
storyDiv.innerHTML = `<h3>Story #${index}</h3>`;
const previewContainer = document.createElement('div');
previewContainer.className = 'preview-container';
const links = storyBlock.querySelectorAll('a.abutton');
let previewAdded = false;
const ul = document.createElement('ul');
links.forEach(link => {
const title = link.querySelector('span').textContent.trim();
const href = link.getAttribute('href');
const li = document.createElement('li');
let preview;
if (!previewAdded && title.includes('Video/Mp4')) {
preview = document.createElement('video');
preview.controls = true;
preview.src = href;
previewContainer.appendChild(preview);
previewAdded = true;
} else if (!previewAdded && title.includes('Photo/Jpg')) {
preview = document.createElement('img');
preview.src = href;
previewContainer.appendChild(preview);
previewAdded = true;
} else if (!previewAdded && title.includes('Audio/Mp3')) {
preview = document.createElement('audio');
preview.controls = true;
preview.src = href;
previewContainer.appendChild(preview);
previewAdded = true;
}
const a = document.createElement('a');
a.href = href;
a.textContent = title;
a.download = '';
li.appendChild(a);
ul.appendChild(li);
});
if (!previewAdded) {
const thumbImg = storyBlock.querySelector('.snaptik-left img');
if (thumbImg) {
const preview = document.createElement('img');
preview.src = thumbImg.src;
previewContainer.appendChild(preview);
}
}
storyDiv.appendChild(previewContainer);
storyDiv.appendChild(ul);
storiesContainer.appendChild(storyDiv);
});
}
form.style.display = 'none';
results.style.display = 'block';
} catch (error) {
alert('Error fetching links: ' + error.message);
}
loader.style.display = 'none';
});
back.addEventListener('click', () => {
form.style.display = 'flex';
results.style.display = 'none';
urlInput.value = '';
});
</script>
</body>
</html>