V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Alesso
V2EX  ›  问与答

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

  •  
  •   Alesso · 2017-02-15 19:00:35 +08:00 · 1184 次点击
    这是一个创建于 2625 天前的主题,其中的信息可能已经有所发展或是发生改变。

    看了几个注册 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 条回复    2017-02-15 22:38:03 +08:00
    tux
        1
    tux  
       2017-02-15 19:29:29 +08:00 via Android
    [0].click();
    zbinlin
        2
    zbinlin  
       2017-02-15 20:10:46 +08:00
    d4rkb1ue
        3
    d4rkb1ue  
       2017-02-15 22:38:03 +08:00
    我用 macOS 自带工具 automator 解决: https://drkbl.com/automator-as-autohotkey/
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3606 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 10:43 · PVG 18:43 · LAX 03:43 · JFK 06:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.