Pau*_*aul 0 html javascript checkbox google-chrome dom-events
我在以下 google chrome 页面上:chrome://history/?q=a
我有一个结果列表,我想确保通过浏览器控制台选择所有复选框。
我已经尝试过这些方法,从这里获取提示,但它似乎不起作用:
[].forEach.call( document.querySelectorAll('input[type="checkbox"]'),function(el){
el.checked=true;
}
);
Run Code Online (Sandbox Code Playgroud)
[].forEach.call( document.querySelectorAll('cr-checkbox#checkbox.no-label'),function(el){
el.checked=true;
}
);
Run Code Online (Sandbox Code Playgroud)
谁能帮我吗?
此页面使用带有 Shadow DOM 的 Web 组件来隔离它们。您需要遍历每个影子根级别:
document.querySelector('history-app')
.shadowRoot.querySelector('history-list')
.shadowRoot.querySelectorAll('history-item')
.forEach(item => {
item.shadowRoot.querySelector('cr-checkbox').click();
});
Run Code Online (Sandbox Code Playgroud)
请注意,该页面还实现了无限滚动,这意味着首先仅显示几个元素,当您滚动时会添加更多元素。当然,该脚本只会选择运行它时存在的脚本。
| 归档时间: |
|
| 查看次数: |
1510 次 |
| 最近记录: |