gpt4 book ai didi

javascript - 按 Youtube 订阅表格按钮

转载 作者:行者123 更新时间:2023-12-02 19:26:04 30 4
gpt4 key购买 nike

我尝试编写一段 JS 代码,从 Youtube 订阅表单中按下“订阅”按钮。

这里是 YouTube 订阅表单的链接:http://www.youtube.com/subscribe_widget?p=aaaa

我试过这个:

document.getElementById("subscribe-button").getElementsByTagName("button")[0].click();

但它给了我这个错误:

/*
Exception: document.getElementById("subscribe-button") is null
@Scratchpad:1
*/

这是按钮 HTML 代码:

<button role="button" id="subscribe-button" class="action-initiator yt-uix-button yt-uix-button-default" type="button" onclick="controller.subscribe(null);return false;"><span class="yt-uix-button-content">Subscribe </span></button>

我该怎么做?

最佳答案

document.getElementById("subscribe-button") IS the button. 

您可以立即调用 click()

关于javascript - 按 Youtube 订阅表格按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12041790/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com