Skip to content

Instantly share code, notes, and snippets.

View michitux's full-sized avatar

Michael Hamann michitux

View GitHub Profile
@michitux
michitux / goQR.js
Created July 26, 2010 18:32
Bookmarklet for quickly creating QR-codes from URLs using QR-Server
/* This bookmarklet tries to find the first selected link and opens the QR code. When no link is selected the current URL is used. */
javascript:(function(){%20function%20openqr(url){window.open('http://api.qrserver.com/v1/create-qr-code/?data='+encodeURIComponent(url)+'&size=700x700&qzone=6');}%20var%20selected,dl,i;%20dl%20=%20document.links;%20if%20(window.getSelection%20&&%20window.getSelection().containsNode)%20{%20/*%20mozilla%20*/%20for(i=0;%20i<dl.length;%20++i)%20{%20if%20(window.getSelection().containsNode(dl[i],%20true))%20{%20selected%20=%20true;%20openqr(dl[i].href);%20break;%20}%20}%20}%20if%20(!selected)%20{%20/*ie,%20or%20mozilla%20with%20no%20links%20selected%20*/%20openqr(document.URL);%20}%20})();
/* This bookmarklet uses the current URL. On some pages the above bookmarklet doesn't work/always uses an unwanted URL. If you experience this issue or don't need selected links try this one. */
javascript:(function(){window.open('http://api.qrserver.com/v1/create-qr-code/?data='+encodeURICompo