Hi!
Is there any way to get the scrollbar position of a Safari window? Want to press Space until the end of the HTML document is reached and print a screenshot of every document part.
Thanks for any hints!
Regards, Lars
PS: Scrolling and screenshotting is really needed as I need to make screenshots. Don’t want to print document at once (e.g. as PDF, PNG, …).
Scripting Safari (Websites) is done using javascript.
tell application "Safari"
tell document 1
do JavaScript "scrollTo(0,99999999999);"
end tell
end tell
If you want to make a picture of the whole site… try FireFox… there are plugins for that
https://addons.mozilla.org/en-US/firefox/search?q=screenshot&cat=all
Great, I am using this code to scroll page wise:
--get document and browser height
set documentHeight to (do JavaScript "document.height" in document 1)
set windowHeight to (do JavaScript "window.innerHeight" in document 1)
--calculate number of pages to screenshot
set pageCount to documentHeight div windowHeight
if documentHeight mod windowHeight > 0 then set pageCount to pageCount + 1
--screenshot every page
do JavaScript "window.scrollTo(0, 0)" in document 1
repeat with i from 1 to pageCount
-- take screenshot here
--scroll to next page
do JavaScript "window.scrollBy(0, " & windowHeight & ")" in document 1
delay 0.1
end repeat