您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Pour Thomas
当前为
// ==UserScript== // @name Robot Leboncoin Général V3 // @namespace http://tampermonkey.net/ // @version 2.6 // @description Pour Thomas // @author Thomas // @match https://www.leboncoin.fr/recherche?* // @icon https://t2.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://leboncoin.fr&size=64 // @require https://code.jquery.com/jquery-3.6.0.min.js // @require https://code.jquery.com/ui/1.14.0/jquery-ui.min.js // @license MIT // @grant none // ==/UserScript== (function() { 'use strict'; var lastLbcAnnoncesArray = []; var audioElement = ""; var sound = false; var theme_main_color = "#ec5a13"; var theme_grey_color = "#bbbbbb"; var refreshDelay = 5; var effetDuBoutonDuTemps = 2; var autorefresh = false; // var notify_sound_url = 'https://directory.audio/media/fc_local_media/audio_preview/pending-notification.mp3'; var notify_sound_url = 'https://directory.audio/media/fc_local_media/audio_preview/quick-bubble-pop2.mp3'; function switchSound(){ sound = !sound; if(sound){ $('#switchSound').removeClass('scriptButtonDisabled'); } else { $('#switchSound').addClass('scriptButtonDisabled'); } } function switchAutorefresh(){ autorefresh = !autorefresh; if(autorefresh){ $('#switchAutorefresh').removeClass('scriptButtonDisabled'); } else { $('#switchAutorefresh').addClass('scriptButtonDisabled'); } } function refreshLbc(){ updateDelayCounter(); $('.h-2xl').trigger('click'); EditDomLbc(); deletePremiumPosts(); var firstAnnonce = $('article[data-qa-id]').first().attr("aria-label"); // Selectionne le titre de la première annonce affichée if(lastLbcAnnoncesArray.indexOf(firstAnnonce) === -1){ if(lastLbcAnnoncesArray.length !== 0){ // Nouvelle annonce détectée if(sound){ audioElement.play(); annoncerObjet(firstAnnonce); } } lastLbcAnnoncesArray.push(firstAnnonce); console.log("Enregistré: "+firstAnnonce); } } function annoncerObjet(titre){ if ('speechSynthesis' in window) { var msg = new SpeechSynthesisUtterance(titre); window.speechSynthesis.speak(msg); } } function debug(){ cleanLeboncoin(); } function cleanLeboncoin(){ $('h1:first-child').hide(); $('.py-md:first-child').hide(); // Barre de recherche $('div[data-test-id="add-category-banner"]').hide(); } function EditDomLbc(){ $('<span id="scriptOverlay"></span>').insertAfter('nav:eq(0)'); $( "#scriptOverlay" ).append( $('<span id="removeToTimer" style="position: absolute;top: 0;left: 0;" class="scriptButton scriptButtonSmall">-'+effetDuBoutonDuTemps+'s</span>') ); $( "#scriptOverlay" ).append( $('<span id="addToTimer" style="position: absolute;top: 0;right: 0;" class="scriptButton scriptButtonSmall">+'+effetDuBoutonDuTemps+'s</span>') ); $( "#scriptOverlay" ).append( $('<span class="scriptButton scriptButtonDisabled"><span id="refreshCountdown">'+refreshDelay+'</span></span>') ); $( "#scriptOverlay" ).append( $('<span id="switchSound" class="scriptButton '+((sound)?'':'scriptButtonDisabled')+'">Son</span>') ); $( "#scriptOverlay" ).append( $('<span id="switchAutorefresh" class="scriptButton '+((autorefresh)?'':'scriptButtonDisabled')+'"><span class="turnOn">Stop</span><span class="turnOff">Lancer</span></span>') ); $( "#scriptOverlay" ).append( $('<span id="manualRefresh" class="scriptButton">Refresh</span>') ); $( "#scriptOverlay" ).append( $('<span id="debugButton" class="scriptButton">Debug</span>') ); $('.styles_Listing__isoog').css('margin-top', '-150px'); var style = $('<style>#switchAutorefresh .turnOff, #switchAutorefresh .turnOn {display: none;} #switchAutorefresh.scriptButtonDisabled .turnOff, #switchAutorefresh .turnOn {display: block !important;} #switchAutorefresh.scriptButtonDisabled .turnOn {display: none !important;} #scriptOverlay { position: fixed;left: 50px;top:80px; z-index: 999999;background: #000000c7; border-radius: 5px; padding: 30px 10px; cursor: move;} .scriptButtonDisabled {background: '+theme_grey_color+' !important;} .scriptButton { background: '+theme_main_color+';font-size: 30px;padding: 5px;cursor: pointer;text-align:center; min-width: 120px;border-radius: 5px; margin: 5px; display: block; } .scriptButtonSmall {padding: 0px 8px; min-width: 1px; font-size: 15px; display: inline;}</style>'); $('html > head').append(style); $('#scriptOverlay').draggable(); } function deletePremiumPosts(){ document.querySelectorAll('.bg-accent').forEach(function(child){ child.closest('article[data-qa-id]').parentNode.remove(); console.log('+1 annonce sponsorisées supprimées'); }); } function updateDelayCounter(){ $('#refreshCountdown').text(refreshDelay); } function init(){ audioElement = document.createElement('audio'); // audioElement.setAttribute('src', 'https://directory.audio/media/fc_local_media/audio_preview/pending-notification.mp3'); audioElement.setAttribute('src', notify_sound_url); cleanLeboncoin(); EditDomLbc(); deletePremiumPosts(); } window.addEventListener('load', function() { init(); setInterval(function(){ var timer = parseInt($('#refreshCountdown').text()); if(autorefresh){ timer = timer -1; if(timer == 0){ timer = refreshDelay; refreshLbc(); } else { $('#refreshCountdown').text(timer); } } }, 1000); $(document).on('click', '#switchSound', function(){ switchSound(); }); $(document).on('click', '#switchAutorefresh', function(){ switchAutorefresh(); }); $(document).on('click', '#manualRefresh', function(){ refreshLbc(); }); $(document).on('click', '#debugButton', function(){ debug(); }); $(document).on('click', '#addToTimer', function(){ refreshDelay += effetDuBoutonDuTemps; updateDelayCounter(); }); $(document).on('click', '#removeToTimer', function(){ refreshDelay -= effetDuBoutonDuTemps; if(refreshDelay <= 0 ){ refreshDelay = 1; } updateDelayCounter(); }); }, false); })();