LeBonCode

Améliore l'UX sur LebonCoin (affiche les téls, masque les annonces vendus et en cours d'achat)

目前为 2022-12-08 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name LeBonCode
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Améliore l'UX sur LebonCoin (affiche les téls, masque les annonces vendus et en cours d'achat)
  6. // @author Yohann Nizon
  7. // @match https://www.leboncoin.fr/*
  8. // @icon https://www.leboncoin.fr/_next/static/media/favicon-16.fe104e12.png
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. let showPhone = true;
  14. let showVendu = true;
  15. let showAchat = true;
  16.  
  17. const phoneButtons = document.querySelectorAll('button[title="voir le numéro"]');
  18.  
  19. if (phoneButtons && showPhone) {
  20. const delay = Math.floor(2000 + Math.random() * 1000); // Random delay between 2 et 3 seconds
  21. setTimeout(() => phoneButtons.forEach(button => button.click()), delay);
  22. }
  23.  
  24. let nbRemove = 0;
  25. let mosaic = document.querySelectorAll('div[data-test-id=listing-mosaic]');
  26. if (mosaic.length == 1){
  27. for (const div of mosaic[0].childNodes) {
  28. if (div.innerText.indexOf('Vendu') > -1 && showVendu) {
  29. nbRemove++;
  30. div.remove();
  31. }
  32. if (div.innerText.indexOf('Achat en cours') > -1 && showAchat) {
  33. nbRemove++;
  34. div.remove();
  35. }
  36. }
  37. } else {
  38. let divs = document.getElementsByTagName('div');
  39. for (let div of divs) {
  40. if (div.className.indexOf('styles_adCard') > -1){
  41. if (div.innerText.indexOf('Vendu') > -1 && showVendu) {
  42. nbRemove++;
  43. div.remove();
  44. }
  45. if (div.innerText.indexOf('Achat en cours') > -1 && showAchat) {
  46. nbRemove++;
  47. div.remove();
  48. }
  49. }
  50. }
  51. }
  52. console.log(nbRemove + " annonce(s) supprimée(s)");