Skip to content

Instantly share code, notes, and snippets.

@greatghoul
Created July 21, 2018 00:18
Show Gist options
  • Save greatghoul/91c3c8b0b80f487a6b3205dce2d7f538 to your computer and use it in GitHub Desktop.
Save greatghoul/91c3c8b0b80f487a6b3205dce2d7f538 to your computer and use it in GitHub Desktop.
// javascript:(function()%7B(function(window%2C%20document%2C%20undefined)%20%7Btry%20%7Bvar%20selectedText%20%3D%20document.getSelection().toString()%3Bif%20(selectedText%20%3D%3D%3D%20'')%20%7BselectedText%20%3D%20window.location.href%3B%7Dif%20(selectedText%20!%3D%3D%20'')%20%7Bvar%20baseQRUrl%20%3D%20'http%3A%2F%2Fchart.apis.google.com%2Fchart%3Fcht%3Dqr%26chs%3D300x300%26chl%3D'%20%2B%20encodeURIComponent(selectedText)%3Bwindow.open(baseQRUrl%2C%20'_blank'%2C%20'width%3D400%2Cheight%3D400')%3B%7D%7Dcatch%20(e)%20%7B%7D%7D)(window%2C%20document)%7D)()
// https://gist.github.com/lemieuxster/2579060
(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