Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用Applescript通过Chrome自动登录网站?_Javascript_Google Chrome_Applescript - Fatal编程技术网

Javascript 如何使用Applescript通过Chrome自动登录网站?

Javascript 如何使用Applescript通过Chrome自动登录网站?,javascript,google-chrome,applescript,Javascript,Google Chrome,Applescript,我想使用谷歌浏览器自动登录到该网站 我知道如何在Safari中使用Applescript,但我不知道如何为Chrome编写脚本 这是我的Safari自动登录的Applescript。我怎么能用Chrome做同样的事情呢 您执行javascript,对象被附加到窗口的选项卡上。因此: tell application "Google Chrome" activate tell window 1 tell active tab if (its

我想使用谷歌浏览器自动登录到该网站

我知道如何在Safari中使用Applescript,但我不知道如何为Chrome编写脚本

这是我的Safari自动登录的Applescript。我怎么能用Chrome做同样的事情呢


您执行javascript,对象被附加到窗口的选项卡上。因此:

tell application "Google Chrome"
    activate
    tell window 1
        tell active tab
            if (its URL) starts with "https://account.nicovideo.jp/login" or (its URL) starts with "https://secure.nicoga.jp/" then
                execute javascript "document.forms[0].mail_tel.value='example@email.com'"
                execute javascript "document.forms[0].password.value='password in here'"
                execute javascript "document.forms[0].submit()"
            end if
        end tell
    end tell
end tell
tell application "Google Chrome"
    activate
    tell window 1
        tell active tab
            if (its URL) starts with "https://account.nicovideo.jp/login" or (its URL) starts with "https://secure.nicoga.jp/" then
                execute javascript "document.forms[0].mail_tel.value='example@email.com'"
                execute javascript "document.forms[0].password.value='password in here'"
                execute javascript "document.forms[0].submit()"
            end if
        end tell
    end tell
end tell