How to add a bookmarklet with a specific favicon?

6

I made a small script bookmarklet and I'm trying to add a favicon, but I can not.

It is in this bookmarklet that I want to implement a favicon - keepvid.com

// Juntar a url ativa na barra de endereço, com url destino e redireciona
location.href='http://keepvid.com?url='+location.href;


<a href="javascript:location.href='http://keepvid.com?url='+location.href;">keevid : Download</a>
<br>
<p>OJETIVO - Baixar vídeos do "Youtube".</p><p>MODO DE USAR - Adicone na sua barra de favoritos. Abra um vídeo do site "Youtube" e clique no Bookmarklet.</p><p>AVISO - Ainda não há um ícone de identificação para este Bookmarklet.</p>

Accordingtotheimage,thefaviconIwishwouldbenexttothe"KeepVid: ..." title, well in the red red area. I want to add this icon to the bookmarklet above.

I quote two reference sources in the subject:

  

adding-favicon-to-javascript-bookmarklet-uses-window -open

     

How-to-have-favicon -icon-set-when-bookmarklet-dragged-to-toolbar

    
asked by anonymous 03.07.2016 / 08:55

1 answer

0

In this Q & A, the main intention was to find a way to only include a Favicon in Bookmarklet . I bring two Script for such purpose in pure Javascript. Let's see:

Observe the figure - 1:

  

ThisexampleisintendedtosetFavicondefinedintheWindowand/orPop-up

Example-A

javascript:varpic=document.createElement('link');pic.setAttribute('rel','shortcuticon');pic.setAttribute('href','http://keepvid.com/favicon.ico');document.getElementsByTagName('head')[0].appendChild(pic);void(0);

<a href="javascript:var pic = document.createElement('link'); pic.setAttribute('rel','shortcut icon');  pic.setAttribute('href','http://keepvid.com/favicon.ico'); document.getElementsByTagName('head')[0].appendChild(pic); void(0);">Adicionar Favicon Pop-Up</a>

Observe the figure - 2:

  

ThisotherexamplewillsetFaviconnotonlyintheBookmarkletintheBookmarks/BookmarksBar,butalsointheAddressBarandTabinuse

Example-B

javascript:varicone=document.getElementsByTagName('head')[0];ElementoTemporario=icone.innerHTML;NovoElemento='<linkrel=\'shortcuticon\'href=\'http://keepvid.com/favicon.ico\'>';ElementoTemporario=NovoElemento+ElementoTemporario;icone.innerHTML=ElementoTemporario;

<a href="javascript: var icone = document.getElementsByTagName('head')[0];ElementoTemporario = icone.innerHTML;NovoElemento ='<link rel=\'shortcut icon\' href=\'http://keepvid.com/favicon.ico\'>';ElementoTemporario =NovoElemento+ElementoTemporario;icone.innerHTML=ElementoTemporario;">Adicionar Favicon Favoritos</a>


  

For a better understanding of all, what I did was add a new element link in both Script, where the:

1) First - inserts the favicon in the address bar and the active tab

2) Second - already inserts the favicon into the address bar, the tab and the "Bookmaklet"

For easy listening, test in your browser.

Now it's up to you to adapt if you're going to use it with any third party service.

    
10.07.2016 / 04:26