AppleScript + JavaScript Tutorial mit Video
7/01/2011tell application "Safari"
activate
open location "http://www.heise.de/newsticker/"
set mysearch to text returned of (display dialog "Meldungen anzeigen die ... enthalten:" default answer "")
tell document 1
set mylinks to do JavaScript "
var myoutput = new Array();
for (var i=0;i<document.links.length;i++){
if (document.links[i].text.indexOf('" & mysearch & "')>-1 && document.links[i].href.indexOf('/newsticker/meldung/')>-1) {
myoutput.push(document.links[i].href)
}
}
myoutput
"
repeat with mylink in mylinks
my makeNewTab()
do JavaScript "document.location='" & mylink & "'"
end repeat
end tell
end tell
on makeNewTab()
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
keystroke "t" using command down
end tell
end tell
delay 0.5
end makeNewTab


