Last active
December 3, 2024 10:39
-
-
Save RobTrew/e06df61f257ec1168cbe to your computer and use it in GitHub Desktop.
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
set strJS to " | |
var xpathResults = document.evaluate('//*[@class=\\'r\\']/a', document, null, 0, null), | |
lst = [], | |
oNode; | |
while (oNode = xpathResults.iterateNext()) { | |
lst.push([ | |
'[', | |
oNode.text, | |
'](', | |
oNode.href, | |
')' | |
].join('')); | |
} | |
lst | |
" | |
tell application "Safari" | |
tell front document | |
if name contains "Google Search" then | |
set {dlm, my text item delimiters} to {my text item delimiters, linefeed} | |
set strMD to (do JavaScript strJS in it) as string | |
set my text item delimiters to dlm | |
set the clipboard to strMD | |
return strMD | |
else | |
return ("Not a Google Search page: " & linefeed & tab & URL) | |
end if | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compare with JXA (Yosemite Javascript for Applications) version:
https://gist.github.com/RobTrew/416ae1a896e06234c92c