繁体   English   中英

使用 Google Chrome DevTools 点击页面上的“Follow”按钮

[英]Use Google Chrome DevTools to click on the "Follow" buttons on the page

在此处输入图像描述

我当前的脚本:

document.querySelectorAll('.components-button components-button-size-mini components-button-type-orange desktop components-button-inline').forEach(btn => btn.click());

我无法理解为什么它不起作用,直到上周我发送脚本并点击输入按钮时一切正常,现在这种情况不再发生。

我需要调整什么才能使其正常工作?

网站链接:
https://booyah.live/users/42973126/followers

当您想要定位包含您指定的所有类的元素时,您需要用点分隔 class 名称。 例如:

<div class="my-class another-class" />

document.querySelector('.my-class.another-class')

你所拥有的是一些带有 class 的元素 .components .components-button包含另一个元素名为components-button-size-mini的元素,其中包含另一个名为components-button-type-orange元素,依此类推。 当然,在这个示例中,我认为您没有具有此类名称的实际元素。

因此,要修复您的代码,请遵循我上面为选择器字符串提供的模式:

.some-class.another-class.yet-another-class

以上将针对具有指定的三个类的元素: some-classanother-classyet-another-class

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM