Skip to content

Instantly share code, notes, and snippets.

@magasine
Created August 31, 2022 23:39
Show Gist options
  • Save magasine/6cf6d6c4e75b82a9d823ab81d4547efc to your computer and use it in GitHub Desktop.
Save magasine/6cf6d6c4e75b82a9d823ab81d4547efc to your computer and use it in GitHub Desktop.
! QRcode Select or Input - Bookmarklet
javascript: (function (window, document, undefined) {
try {
var selectedText = document.getSelection().toString();
if (selectedText === "") {
selectedText = window.location.href;
}
if (selectedText !== "") {
var clipB = prompt("Content to qrCode renderize", selectedText);
if (clipB !== null) {
void navigator.clipboard.writeText(clipB);
var baseQRUrl =
"http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=" +
encodeURIComponent(clipB);
window.open(baseQRUrl, "_blank", "width=400,height=400");
}
}
} catch (e) {}
})(window, document);
// ! QRcode Select or Input - Bookmarklet
// Adapted from https://gist.github.com/lemieuxster/2579060
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment