Last active
January 31, 2024 15:45
-
-
Save jgarber623/b92ea2f7adf0965c2f28eaca6267362c to your computer and use it in GitHub Desktop.
A bookmarklet that generates a QR Code of the current page's URL and displays it in a <dialog> element (assuming a Content Security Policy doesn't prevent the script from running). Inspired by https://til.therealadam.com/2024/01/31/sneakerneting-urls-to.html.
This file contains hidden or 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
<a href="javascript:(()=>{const script=document.createElement('script');script.type='module';script.append(document.createTextNode=`import QRCode from 'https://cdn.jsdelivr.net/npm/[email protected]/+esm';const dialog=document.createElement('dialog');const img=document.createElement('img');img.src=await QRCode.toDataURL(location.href);dialog.append(img);document.body.append(dialog);dialog.showModal();`);document.body.append(script)})()">Generate QR Code</a> |
This file contains hidden or 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
(() => { | |
const script = document.createElement("script"); | |
script.type = "module"; | |
script.append( | |
document.createTextNode = `\ | |
import QRCode from "https://cdn.jsdelivr.net/npm/[email protected]/+esm"; | |
const dialog = document.createElement("dialog"); | |
const img = document.createElement("img"); | |
img.src = await QRCode.toDataURL(location.href); | |
dialog.append(img); | |
document.body.append(dialog); | |
dialog.showModal();` | |
); | |
document.body.append(script); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment