// Toggle the navigation menu on mobile document.getElementById('menu-icon').addEventListener('click', function() { const navMenu = document.getElementById('nav-menu'); navMenu.classList.toggle('open'); // Toggle the open class for the menu }); document.getElementById('pasteUrlButton').addEventListener('click', async function () { try { // Use the Clipboard API to read text from the clipboard const text = await navigator.clipboard.readText(); document.getElementById('tweetUrl').value = text; } catch (error) { console.error('Failed to read clipboard contents: ', error); alert('Your browser does not support clipboard access, or you did not allow access.'); } }); function clearInput() { document.getElementById("tweetUrl").value = ""; } function loadVideos() { const tweetUrl = document.getElementById('tweetUrl').value; const API_URL = "https://bk.twdownloader.com" $.ajax({ url: API_URL, method: 'POST', contentType: 'application/json', data: JSON.stringify({ videoUrl: tweetUrl }), beforeSend: function (xhr) { $('.spinner-border').removeClass('hidden'); }, success: function(response) { // console.log('Success:', response); // Set screen name and title $('.spinner-border').addClass('hidden'); $(".download-box").hide(); $("#davideo").show(); $("#screen_name").text(response.screen_name); $("#title").text(response.title); // Set video const videoElement = $('#videoSrc'); videoElement.attr('src', atob(response.media.at(-1).url)); videoElement.attr('autoplay', false); // Creating download buttons for (let m of response.media) { downloadRow = $( `
` ); $("#download-section").append(downloadRow); } $("#video-section").css("display", "block").css("visibility", "visible"); }, error: function(jqXHR, textStatus, errorThrown) { $('.error-alert').removeClass('hidden'); setTimeout(()=>{ $('.error-alert').addClass('hidden'); }, 5000) $('.spinner-border').addClass('hidden'); console.error('Error:', textStatus, errorThrown); } }); } function toggleFAQ(element) { const activeItem = document.querySelector('.faq-item.active'); if (activeItem && activeItem !== element) { activeItem.classList.remove('active'); } element.classList.toggle('active'); } async function downloadBlob(encodedUrl, extension) { const apiUrl = "https://bk.twdownloader.com/"; const url = apiUrl + encodedUrl; try { const response = await fetch(url, { cache: "no-store" }); const blob = await response.blob(); const downloadUrl = window.URL.createObjectURL(blob); const a = document.createElement("a"); a.href = downloadUrl; a.download = `video.mp4`; document.body.appendChild(a); a.click(); document.body.removeChild(a); window.URL.revokeObjectURL(downloadUrl); } catch (error) { console.error('Failed to download video blob: ', error); } }