Greasy Fork is available in English.

讨论 » 开发

How to click on this 'Voir plus' button on this webpage ?

§
发表于:2024-03-04

Hi, I am new to userscripts, how can I click on this button (there is only 1 per webpage, not more for info) on this webpage https://www.leboncoin.fr/jeux_video/2540607208.htm

I am using this scripts:
"
const buttonElem = [...document.querySelectorAll('button')].find(x => x.innerText.includes('Voir plus'));
console.log(buttonElem);
buttonElem.click();
"

The button is properly found (1st line), but I don't understand why the click does not work. Regards

§
发表于:2024-03-04
编辑于:2024-03-04
// ==UserScript==
// @name         New Userscript
// @namespace    https://greasyfork.org/en/users/670188-hacker09?sort=daily_installs
// @version      1
// @description  try to take over the world!
// @author       hacker09
// @include      *
// @run-at       document-end
// @grant        none
// ==/UserScript==

setTimeout(() => {
  [...document.querySelectorAll('button')].find(x => x.innerText.includes('Voir plus')).click();
}, 3000);
§
发表于:2024-03-04

Thank you, I have just tested it works great.
I had 2 mistakes:
- @run-at was document-load
- I did not used a timeout

发表回复

登录以发表回复。