clicking attribute on a page via Userscript

Viewed 78

i am trying to make a userscript in chrome tampermonkey that will auto click the "Gen.lib.rus.ec" link in pages like this. classname is always dynamic but not the title name. i know how to make it work by classname but not title. kindly suggest something.

// ==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);  
1 Answers

You can use the a[title="Gen.lib.rus.ec"] CSS selector with e.g. document.querySelector to get the proper element based on the title attribute.

Related