···11+Copyright (c) 2025 joshua stein <jcs@jcs.org>
22+33+Permission to use, copy, modify, and distribute this software for any
44+purpose with or without fee is hereby granted, provided that the above
55+copyright notice and this permission notice appear in all copies.
66+77+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
88+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
99+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1010+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1111+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1212+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1313+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+5
README.md
···11+# crossword.script
22+33+A dumb AppleScript to automate fetching the current day's
44+["Stan Newman's Daily Crossword"](https://www.arkadium.com/games/stan-newmans-daily-crossword/)
55+as a PDF, suitable for e-mailing to my wife's Kindle Scribe.
+89
crossword.script
···11+--
22+-- Copyright (c) 2025 joshua stein <jcs@jcs.org>
33+--
44+-- Permission to use, copy, modify, and distribute this software for any
55+-- purpose with or without fee is hereby granted, provided that the above
66+-- copyright notice and this permission notice appear in all copies.
77+--
88+-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
99+-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1010+-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1111+-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1212+-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1313+-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1414+-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515+--
1616+1717+-- AppleScript to open Safari, open a private window, navigate to the
1818+-- "Stan Newman's Daily Crossword" page, bypass all the junk, then bring
1919+-- up the printable version of today's crossword as a PDF, and then save
2020+-- it to the desktop as "crossword.pdf"
2121+2222+tell application "System Events"
2323+ tell application "Safari" to activate
2424+ delay 1
2525+ keystroke "n" using {command down, shift down}
2626+ delay 1
2727+ set u to "https://www.arkadium.com/games/stan-newmans-daily-crossword/"
2828+ keystroke u
2929+ keystroke return
3030+ delay 5
3131+3232+ -- bypass cookie screen
3333+ tell application "Safari"
3434+ tell document 1
3535+ do JavaScript "Array.from(document.getElementsByTagName('button')).filter((b) => b.innerHTML == 'CONFIRM').at(0).click();"
3636+ end tell
3737+ end tell
3838+ delay 1
3939+4040+ -- click 'play now'
4141+ tell application "Safari"
4242+ tell document 1
4343+ -- do JavaScript "Array.from(document.getElementsByTagName('button')).filter((b) => b.innerHTML == 'Play Now').at(0).click();"
4444+ do JavaScript "document.getElementsByClassName('ark-ad-button-text ctaButtonText')[0].parentElement.click();"
4545+ end tell
4646+ end tell
4747+4848+ -- sit through some ads
4949+ delay 60
5050+5151+ -- click default 'PLAY' button on today
5252+ tell application "Safari"
5353+ tell document 1
5454+ do JavaScript "Array.from(document.getElementsByTagName('button')).filter((b) => b.innerHTML == 'PLAY').at(-1).click();"
5555+ end tell
5656+ end tell
5757+ delay 2
5858+5959+ -- bring up the webpage's print dialog (not safari's)
6060+ keystroke "p" using {control down}
6161+ delay 2
6262+6363+ -- click 'Print'
6464+ tell application "Safari"
6565+ tell document 1
6666+ do JavaScript "Array.from(document.getElementsByTagName('button')).filter((b) => b.innerHTML == 'Print')[0].click();"
6767+ end tell
6868+ end tell
6969+ delay 4
7070+7171+ -- once PDF is up, save it in safari
7272+ keystroke "s" using {command down}
7373+ delay 2
7474+7575+ -- and navigate to ~/Desktop and save it as "crossword.pdf"
7676+ keystroke "~"
7777+ delay 2
7878+ keystroke "/Desktop/"
7979+ delay 2
8080+ keystroke return
8181+ keystroke "crossword.pdf"
8282+ delay 1
8383+ keystroke return
8484+ delay 1
8585+8686+ -- quit safari
8787+ delay 1
8888+ keystroke "q" using {command down}
8989+end tell