(function(bspage) { let searchEnabled = true; let searchBox = document.getElementById('txt-url'); let searchButton = document.getElementById('btn-search'); let pageDomain = document.getElementById('txt-url').getAttribute('data-site'); let server = bspage.getServer(); searchBox.addEventListener('paste', function(e) { e.preventDefault(); const keyup = new Event('keyup'); const searchUrl = e.clipboardData.getData('text'); searchBox.value = searchUrl; validateSearchInput(searchUrl); searchBox.dispatchEvent(keyup); searchButton.click(); }); searchBox.addEventListener('keyup', function(e) { if (e.keyCode === 13) { searchButton.click(); return; } if (this.value.length === 0) { document.getElementById('bd-info') && document.getElementById('bd-info').remove() } validateSearchInput(searchBox.value); }); searchButton.onclick = function() { let searchURL = searchBox.value.replace(/ /g, '').replace(/#(.+)?/, ''); if (!searchEnabled || searchURL === '') { return; } if (!validURL(searchURL)) { bsmsg.display('', 'Hi sexy, please paste a valid link!
Winky Wink ;)', false, true); return; } let searchDomain = getDomain(searchURL); if (searchDomain != 'none') { if ((pageDomain == 'all' && domainDown(searchDomain)) || domainDown(pageDomain)) { bsmsg.display('', "Looks like the website or its links aren't working right now.
Try again later! Winky Wink ;)", false, true); return; } if (pageDomain != 'all' && (pageDomain != searchDomain)) { showInfo(true, searchDomain); return; } loading(true); getInfo(`info=${JSON.stringify({url: encodeURIComponent(searchURL), domain: searchDomain.toLowerCase()})}`); } }; function validateSearchInput(input) { if (!validURL(input)) { document.getElementById('bd-info') && document.getElementById('bd-info').remove(); return; } let searchDomain = getDomain(input); if (searchDomain == 'none') { showDomainInfo(false); return; } if (pageDomain != 'all' && (pageDomain != searchDomain)) { showDomainInfo(true, searchDomain); return; } document.getElementById('bd-info') && document.getElementById('bd-info').remove(); } function validURL(url) { let match = url.match(/^http[s]?:\/\/(?:[\w-]+\.)?[\w-]+\.\w+\/(?:[^<>:])+$/); return match === null ? false : true; } function getDomain(url) { let domain = url.match(/[\w-]+\.\w+(?=\/)/)[0]; for (let i = 0; i < bspage.sitesList.length; i++) { let site = bspage.sitesList[i].toLowerCase(); if (site == 'badass-softcore.com') { site = 'badassoftcore.com'; } if (domain == site) { return bspage.sitesList[i]; } } return 'none'; } function domainDown(domain) { for (let i = 0; i < bspage.sitesDown.length; i++) { if (domain.toLowerCase() == bspage.sitesDown[i].toLowerCase()) { return true; } } return false; } function showDomainInfo(found, domain = '') { let msg = ''; document.getElementById('bd-info') && document.getElementById('bd-info').remove(); if (found) { let cleanDomain = cleanDomainName(domain); let link = `${cleanDomain}`; msg = `You can download this video on our ${link} page!`; } else { msg = "Sorry, we don't support this website!"; } msg = document.createRange().createContextualFragment(`${msg}`); document.querySelector('.search-cont').after(msg); } function cleanDomainName(domain) { for (let i = 0; i < bspage.sitesMultiple.length; i++) { if (domain == bspage.sitesMultiple[i]) { return domain; } } return domain.match(/[\w-]+(?=\.)/)[0]; } if (typeof(downloadItUrl) != 'undefined') { const keyup = new Event('keyup'); searchBox.value = downloadItUrl; searchBox.dispatchEvent(keyup); searchButton.click(); } function loading(active) { if (active) { searchEnabled = false; searchButton.classList.remove('enabled'); bsmsg.display('', 'Please wait sexily while we retrieve your videos...', true, false); } else { searchEnabled = true; searchButton.classList.add('enabled'); } } function getInfo(data) { let xhr = new XMLHttpRequest(); xhr.onload = () => { let data = xhr.response; if (data !== null && data['success']) { infoSuccess(data); } else { infoError(data); } }; xhr.onerror = function() { infoError(null); }; xhr.timeout = 60000; xhr.open("POST", `${server}/get-info`); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.responseType = 'json'; xhr.send(data); } function infoSuccess(data) { document.querySelector('.down-cont') && document.querySelector('.down-cont').remove(); document.querySelector('.file-info') && document.querySelector('.file-info').remove(); let table = "
bd-title
SizeQuality
"; let thumbnail = data.thumbnail === null ? 'https://badassdownloader.com/wp-content/uploads/2019/05/bdlogo2.png' : `https://m.badassdownloader.com/get-image?image=${data.thumbnail}`; let ban = "

x

CLOSE

"; table = table.replace('bd-title', data['title']); table = table.replace('bd-thumb', thumbnail); table = document.createRange().createContextualFragment(table); ban = document.createRange().createContextualFragment(ban); document.querySelector('.bslinks-cont').after(table); // document.querySelector('.down-cont').append(ban); if (!bdml) { document.querySelector('.down-cont').append(ban); } for (const media in data.sources) { for (const quality in data.sources[media]) { let id = media == 'm3u8' ? `${quality}-stream` : quality; let link = `${server}/download?data=${data.sources[media][quality].src}`; let sizeText = document.createRange().createContextualFragment(`
${formatBytes(data.sources[media][quality].size, 0)}
`); let qualityButton = document.createRange().createContextualFragment(`${quality.replace('_', ' ')}`); document.getElementById('size-cont').append(sizeText); document.getElementById('links-cont').append(qualityButton); if (!bdml && (bscheck && bscheck.adblocker())) { // if (bscheck.adblocker()) { document.getElementById(id).onclick = function() { bsmsg.display('', 'Looks like you have a sexy ad blocker!
Help us out by disabling it and refreshing the page. Winky Wink ;)', false, true); return; }; } else { document.getElementById(id).href = link; document.getElementById(id).target = '_blank'; } } } if (!bdml) { document.getElementById('close-x').onclick = function() { document.getElementById('ban-cont').style.display = 'none'; document.body.lastChild.remove(); } document.getElementById('close-ban').onclick = function() { document.getElementById('ban-cont').style.display = 'none'; document.body.lastChild.remove(); } } if (data.media == 'stream' || data.media == 'mixed') { let info = document.createRange().createContextualFragment("
Some or all videos come from stream files ( m3u8 ). BadAssDownloader recommends re-encoding these downloads to .mp4 format using a tool like FFmpeg or Any Video Converter Free ;)
"); document.querySelector('.down-cont').after(info); } document.querySelector('.down-cont').scrollIntoView({behavior: 'smooth', block: 'center'}); bsmsg.hide() loading(false); } function infoError(data) { if (data !== null && ('message' in data)) { bsmsg.display(data.message.title, data.message.text, false, true); } else { bsmsg.display('', 'An error ocurred, try again later!
Winky Wink ;)', false, true); } loading(false); } function formatBytes(bytes, decimals = 2) { if (bytes === 0) return '0 Bytes'; if (bytes === -2) return 'N/A'; const k = 1024; const dm = decimals < 0 ? 0 : decimals; const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; } }(window.bspage = window.bspage || {}));