I know there is probably a simple answer for this question but days of searching and trying examples have left my eyes bloodshot and my brain not so sure 2+2 really does equal 4. Here is what I would like to do:
Open pageMain in Safari
Check entire page for any occurrences of textTarget
Open a new Safari tab for each occurrence of textTarget
End program
Any suggestions or code examples would be great. Thank you in advance.
That should not be too hard to do, But what are the text targets, and what are the tabs loading??
Example. if the below script runs on a thread page here, it will open all the posters profile pages
set textTarget to "profile.php?"
tell application "Safari"
set theCounter to 0
repeat (do JavaScript "document.links.length" in document 1) times
set theCounter to theCounter + 1
set a_Link to (do JavaScript "document.links[" & theCounter & "].href" in document 1) as list -- has to be a list
try
if item 1 of a_Link contains textTarget then
make new tab at end of window 1 with properties {URL:(item 1 of a_Link as string)}
end if
end try
set a_Link to {}
end repeat
end tell