Can you hide the redirect, but keep the link for download?

4

I made a simple favlet to make it easy to convert videos from YouTube for audio:

<a href="javascript:!function(){window.location.href='http://www.youtubeto.com?task=MP3&url='+window.location.href;}();">youtubeto : mp3</a>

<br>

<p> MODO DE USAR - Adicone na sua barra de favoritos. Abra um vídeo do site "Youtube" e clique sobre o Bookmarklet.</p>

Now, I want to leave it as an elegant application. By clicking on the favlet located in the bookmarks bar, I would like to display only the download window, avoiding showing the site - link .

Then I thought of inserting the method window.close() in milliseconds into the favlet

window.setTimeout (window.close(), 5 * 1000);

But it did not work as expected.

I know what you have, because this online service - link does it. It uses the youtubeinmp4 infrastructure, but in case it hides the site that generates the download.

    
asked by anonymous 09.01.2017 / 18:44

1 answer

4

I worked using reverse engineering , that is, observing and imagining what such behavior would be like. Check below as it was:

<a href="javascript:(function(){var popup = window.open(); URL = 'http://www.youtubeto.com?task=MP3&url='+window.location.href; popup.document.write('<iframe src='+URL+' width=0 height=0 frameborder=0></iframe><script>function fechar(){window.opener = window;window.close()}setTimeout(fechar, 10000)</script>')})()">Youtube MP3</a>

<br><br>

<a href="javascript:(function(){var popup = window.open(); URL = 'http://www.youtubeto.com?task=MP4&url='+window.location.href; popup.document.write('<iframe src='+URL+' width=0 height=0 frameborder=0></iframe><script>function fechar(){window.opener = window;window.close()}setTimeout(fechar, 10000)</script>')})()">Youtube MP4</a>

<br>

<p> Arraste-o para sua barra de favoritos. Abra um vídeo do site "Youtube" e clique sobre o Bookmarklet, aguarde 10 segundos e verá a janela de download e logo em seguida é fechada automaticamente a aba do download.</p>

A brief explanation is always welcome, so let's go!

What we're doing is a dynamic iframe in a pop-up window

Here we have a window bringing iframe width=0 height=0 frameborder=0 to hidden .

The timer setTimeout is there to wait for the load of the site to start downloading.

  

NOTE - The timer is set to 10 seconds . This has become necessary for those using a modest connection ( 2G or 3G ), since the speed variation fluctuates too much.

     

For those who have broadband wired or wireless , there is no need for a high number above 3 seconds , the download will start almost immediately.


To give more charm to this " bookmarklet ", see - How to add a bookmarklet with a specific favicon?

    
13.01.2017 / 21:22