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.

Revisions

  1. CSFelix created this gist Dec 3, 2020.
    15 changes: 15 additions & 0 deletions how-to-do-web-tube-me-script.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    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}`; }