Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --PREREQUISITE: "downloadLocation" must be a favorite (drag and drop to sidebar in finder)
- set downloadLocation to "bevyPDF"
- set clickScript to "document.getElementById('book-pager-bar-next').click()"
- --https://stackoverflow.com/questions/6941630/script-safari-5-1-to-open-a-tab
- tell first window of application "Safari"
- activate
- set newTab to make new tab
- set the URL of newTab to "https://bevyengine.org/learn/book/introduction/"
- set the current tab to newTab
- delay 1
- end tell
- set prevURL to "tmp1"
- set currURL to "tmp2"
- set currPage to 1
- repeat until (prevURL = currURL)
- --Slightly modified version of https://apple.stackexchange.com/questions/224392/applescript-save-as-dialog-in-safari-reader-save-as-pdf
- tell application "System Events"
- tell application process "Safari"
- set frontmost to true
- tell menu bar 1
- click menu item "Show Reader" of menu "View" of menu bar item "View"
- repeat until menu item "Hide Reader" of menu "View" of menu bar item "View" exists
- end repeat
- delay 1
- click menu item "Export as PDF…" of menu "File" of menu bar item "File"
- end tell
- tell window 1
- repeat until sheet 1 exists
- end repeat
- tell sheet 1
- keystroke currPage
- set currPage to currPage + 1
- click pop up button "Where:"
- repeat until menu 1 of pop up button "Where:" exists
- end repeat
- click menu item downloadLocation of menu 1 of pop up button "Where:"
- click button "Save"
- end tell
- end tell
- end tell
- end tell
- tell first window of application "Safari"
- set prevURL to URL of current tab
- do JavaScript clickScript in current tab
- delay 1
- set currURL to URL of current tab
- end tell
- end repeat
Advertisement
Add Comment
Please, Sign In to add comment