我正在尝试用铬做一个用户脚本,它会自动点击像this这样的页面中的"Gen.lib.rus.ec“链接。类名始终是动态的,但不是标题名。我知道如何让它通过类名工作,但不知道标题。请给我一些建议。
// ==UserScript==
// @name libgen clicker
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @include *://libgen.rs/*
// @match *://libgen.rs/*
// @include *://library.lol/*
// @icon https://www.google.com/s2/favicons?domain=libgen.rs
// @grant none
// ==/UserScript==
setTimeout(function() {
document.getattribute("Gen.lib.rus.ec")[0].click();
}, 500);
发布于 2021-07-20 00:30:52
您可以使用带有document.querySelector
的a[title="Gen.lib.rus.ec"]
CSS选择器来根据标题属性获取适当的元素。
https://stackoverflow.com/questions/68443933
复制相似问题