Is it possible to hide the redirect, but keep the link for the download?

Asked

Viewed 428 times

4

I made a simple favlet, to facilitate the task of converting videos from Youtube 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 make it elegant as an app. By clicking on favlet located in the bookmark bar, would like to display only the download window while avoiding showing the site - http://www.youtubeto.com.

So I thought I’d put it in favlet the method window.close() in milliseconds.

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

But it didn’t work as expected.

I know there’s a way, because this online service - http://baixar r-videos.com/ does this. It uses the infrastructure of youtubeinmp4, but in case he occult the site that generates the download.

1 answer

4


I elaborated using reverse engineering, that is, observing and imagining how such behavior would be. Check out below how 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 come on!

What we’re doing is a Dynamic iframe in a pop-up window

Here we have a window bringing the iframe width=0 height=0 frameborder=0 in occult.

The timer setTimeout is there to wait for the load the site be started for download.

NOTE - The timer is set at 10 seconds. This made it necessary to put for those who use modest connection(2G or 3G), because the speed change oscillates too much.

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


To add a little charm to that "bookmarklet", see - How to add a bookmarklet with a specific favicon?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.