Applescript 将当前URL更改为JavaScript的脚本

Applescript 将当前URL更改为JavaScript的脚本,applescript,Applescript,这是我当前的代码 tell application "Google Chrome" to set the URL of the front document to "Javascript:buy();" 但是它不允许我使用Javascript,我需要做什么来解决这个问题?您可以使用“executeJavaScript”命令在Chrome中执行Javascript tell application "Google Chrome" activate tell window

这是我当前的代码

    tell application "Google Chrome" to set the URL of the front document to "Javascript:buy();"

但是它不允许我使用Javascript,我需要做什么来解决这个问题?

您可以使用“executeJavaScript”命令在Chrome中执行Javascript

tell application "Google Chrome"
    activate
    tell window 1 to tell active tab
        set URL to "http://stackoverflow.com/questions/13896927/applescript-script-to-make-current-url-change-to-a-javascript"
        repeat until not loading
            delay 0.2
        end repeat
        set myVar to execute javascript "document.getElementsByClassName('user-details')[0].childNodes[1].text"
    end tell
end tell

return myVar
tell application "Google Chrome"
    activate
    tell window 1 to tell active tab
        set the URL to "Javascript:buy();"
    end tell
end tell