It's child's play to do this in Safari, which has good Applescript support. Google Chrome's AS support has just arrived so I'm giving them the benefit of the doubt. I am basically trying to grab the current HTML via the clipboard so I can get information out. We have some nifty commands like this:
tell application "Google Chrome"
view source of active tab of window 1
save active tab of window 1
print active tab of window 1
reload active tab of window 1
go back active tab of window 1
go forward active tab of window 1
copy selection of active tab of window 1
paste selection active tab of window 1
end tell
but alas you can't say "set X to source of active tab of window 1
". Anyone have any suggestions for me? My current ideas are to load the code I need in the background in Safari (pretty ugly) or try to display source and grab it with UI script, but that's also ugly. Also I keep encountering scripting bugs that keep it from working.
Any help would be appreciated.
Since google chrome supports Javascript
--Applescript code
tell active tab of window 1
set sourcehtml to execute javascript
document.getElementsByTagName('html')[0].innerHTML
end tell
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With