Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
QR Code Bookmarklet
javascript:(function(window, document, undefined) {try {var selectedText = document.getSelection().toString(); if (selectedText === ''){selectedText = window.location.href;} if(selectedText !== ''){var baseQRUrl = 'http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=' + encodeURIComponent(selectedText); window.open(baseQRUrl, '_blank', 'width=400,height=400');}} catch (e) {}})(window, document);
//Opens a window with a QR code for either selected text on the page or the current page URL if no text is selected.
//Bookmarklet-ify it by removing whitespace and prepending javascript:
//Like so: javascript:(function ....)()
(function(window, document, undefined) {
try {
var selectedText = document.getSelection().toString();
if (selectedText === '') {
selectedText = window.location.href;
}
if (selectedText !== '') {
var baseQRUrl = 'http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=' + encodeURIComponent(selectedText);
window.open(baseQRUrl, '_blank', 'width=400,height=400');
}
} catch (e) {
}
})(window, document);
@greatghoul

This comment has been minimized.

Copy link

greatghoul commented Mar 3, 2018

I like this simple bookmarklet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.