Created
July 25, 2013 18:34
-
-
Save kosugi/6082475 to your computer and use it in GitHub Desktop.
opens a new tab on Google Chrome and renders given HTML via command-line arguments.
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
| on replace {src, tg, rp} | |
| set oldDel to AppleScript's text item delimiters | |
| set AppleScript's text item delimiters to tg | |
| set myList to text items of src | |
| set AppleScript's text item delimiters to rp | |
| set myText to myList as string | |
| set AppleScript's text item delimiters to oldDel | |
| return myText | |
| end replace | |
| on run argv | |
| set content to "" | |
| repeat with arg in argv | |
| set content to content & " " & arg as Unicode text | |
| end repeat | |
| set content to replace {content, "\r", ""} | |
| set content to replace {content, "\n", "\\n"} | |
| set content to replace {content, "'", "\\'"} | |
| tell application "Google Chrome" | |
| tell window 1 | |
| set newTab to make new tab with properties {URL:"about:blank"} | |
| delay 0.5 | |
| repeat while loading of newTab | |
| delay 0.5 | |
| end repeat | |
| end tell | |
| execute front window's active tab javascript "document.documentElement.innerHTML = '" & content & "';" | |
| end tell | |
| end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment