Skip to content

Instantly share code, notes, and snippets.

@CSFelix
Created December 3, 2020 14:44
Show Gist options
  • Save CSFelix/58140de40542b61ad1af2dbe18772f2a to your computer and use it in GitHub Desktop.
Save CSFelix/58140de40542b61ad1af2dbe18772f2a to your computer and use it in GitHub Desktop.
let Btn = document.getElementById('btn');
let URLinput = document.getElementById('URL-input');
let select = document.querySelector('.opt');
let serverURL = 'http://localhost:4000';
Btn.addEventListener('click', () => {
if (!URLinput.value) { alert('Put the link before to download!'); }
else {
if (select.value == 'mp3') { redirectMp3(URLinput.value); }
else if (select.value == 'mp4') { redirectMp4(URLinput.value); }
}
});
function redirectMp3(query) { window.location.href = `${serverURL}/downloadmp3?url=${query}`; }
function redirectMp4(query) { window.location.href = `${serverURL}/downloadmp4?url=${query}`; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment