Skip to content

Instantly share code, notes, and snippets.

@msurguy
Last active January 8, 2020 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msurguy/49cbedf55147033b6ab9c0b3baf0d43e to your computer and use it in GitHub Desktop.
Save msurguy/49cbedf55147033b6ab9c0b3baf0d43e to your computer and use it in GitHub Desktop.
Make QR Code for Chrome URL

An Apple Script for quickly generating qr code for the URL of the front-most Chrome window.

Instructions:

  1. Install qrcode Node package globally by
npm install -g qrcode
  1. Download qrcode.scpt provided here
  2. Make the script into an app by opening qrcode.scpt in Script Editor, then File > Export > File Format : Application and save it to your Applications.
  3. You should be able to use Launcher (or Alfred) to launch this script quickly.
on replaceText(find, replace, subject)
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to find
set subject to text items of subject
set text item delimiters of AppleScript to replace
set subject to subject as text
set text item delimiters of AppleScript to prevTIDs
return subject
end replaceText
tell application "Google Chrome"
set activeUrl to get URL of active tab of first window
end tell
set ipAddr to IPv4 address of (get system info)
set fullAddr to replaceText("localhost", ipAddr, activeUrl)
tell application "Terminal"
activate
tell application "System Events"
keystroke "n" using command down
delay 0.1
tell window 1 of application "Terminal"
set number of columns to 80
set number of rows to 60
end tell
keystroke "-" using command down
keystroke "-" using command down
keystroke "-" using command down
keystroke "-" using command down
keystroke "-" using command down
keystroke "qrcode " & fullAddr # Could be npx qrcode if Node version changes a lot
key code 36
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment