Greasy Fork is available in English.

Discussions » Développement

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

§
Posté le: 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

§
Posté le: 2024-03-04
Édité le: 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);
§
Posté le: 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

Poster une réponse

Connectez-vous pour poster une réponse.