V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Alesso
V2EX  ›  问与答

如何用 JavaScript 点击 Google Voice 页面的这个 Continue 按钮?

  •  
  •   Alesso · Feb 15, 2017 · 1549 views
    This topic created in 3362 days ago, the information mentioned may be changed or developed.

    看了几个注册 Google Voice 的帖子,都提到最后一步必须用按键精灵来狂按,直到成功。但因为我的系统是 macOS ,所以只好用 AppleScript 来实现。

    找了一堆资料,模仿着写出这样的脚本:

    tell application "Google Chrome"
        activate
        set theTab to tab 6 of window 1
        repeat while 1 is 1
            execute theTab javascript "document.getElementsByClassName('continueButton').click();"
            delay (random number from 0.5 to 1)
        end repeat
    end tell
    

    但无法生效,然后测试了一下,应该是中间 JS 这一行不对。我试着直接在页面的 consle 里输入, 结果提示 document.getElementsByClassName(...).click is not a function at <anonymous>:1:100

    因为我不懂编程,到这一步就不知接下来该怎么解决了,还望好心人指点一二。

    3 replies    2017-02-15 22:38:03 +08:00
    tux
        1
    tux  
       Feb 15, 2017 via Android
    [0].click();
    zbinlin
        2
    zbinlin  
       Feb 15, 2017
    d4rkb1ue
        3
    d4rkb1ue  
       Feb 15, 2017
    我用 macOS 自带工具 automator 解决: https://drkbl.com/automator-as-autohotkey/
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   813 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 22:30 · PVG 06:30 · LAX 15:30 · JFK 18:30
    ♥ Do have faith in what you're doing.