• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari


  • Subject: Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 31 Mar 2017 03:35:17 -0500

Hey Folks,

Would someone test this for me on a completed Google Search on 10.12.4?

-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2017/03/29 04:44
# dMod: 2017/03/31 03:14
# Appl: Safari, System Events
# Task: Open the First Hit on a Google Search
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Safari, @System_Events, @Open, @First, @Hit, @Google, @Search
-------------------------------------------------------------------------------------------

set xpathStr to "//*[@class=\\'r\\']/a"
set jsCmdStr to "

var xpathResults = document.evaluate('" & xpathStr & "', document, null, 0, null),
  nodeList = [],
  oNode;

while (_oNode_ = xpathResults.iterateNext()) {
  nodeList.push(oNode.href);
}

nodeList.join('\\n');

"

# Allow for the possibility that Safari has been hidden.
# When Safari is hidden it does correctly discern window 1.
tell application "System Events"
    tell application process "Safari"
        if its visible is false then set its visible to true
    end tell
end tell

tell application "Safari"
    set linkList to (do _javascript_ jsCmdStr in front document)
end tell

-------------------------------------------------------------------------------------------

If it returns a string of links then I'm back in business and can safely update to 10.12.4.

TIA.

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari
      • From: Shane Stanley <email@hidden>
References: 
 >Sierra 10.12.4 and JavaScript by AppleEvents in Safari (From: Christopher Stone <email@hidden>)
 >Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari (From: Takaaki Naganoya <email@hidden>)
 >Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari (From: Christopher Stone <email@hidden>)
 >Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari (From: Takaaki Naganoya <email@hidden>)
 >Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari (From: Christopher Stone <email@hidden>)
 >Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari (From: Takaaki Naganoya <email@hidden>)
 >Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari (From: Christopher Stone <email@hidden>)
 >Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari (From: 2551phil <email@hidden>)
 >Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari (From: Christopher Stone <email@hidden>)
 >Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari (From: Shane Stanley <email@hidden>)
 >Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari
  • Next by Date: Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari
  • Previous by thread: Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari
  • Next by thread: Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari
  • Index(es):
    • Date
    • Thread