-
-
Save brunogama/fa80584d0fff2cdad84b9098205101e6 to your computer and use it in GitHub Desktop.
QR Code Bookmarklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment