0

这是我当前的代码。

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

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

4

1 回答 1

0

您可以使用“执行 javascript”命令在 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
于 2012-12-16T00:03:55.330 回答