NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name JVCPreview // @version 0.1 // @description Preview des topics JVC // @author JesusSympa // @match http://www.jeuxvideo.com/forums/* // @match http://www.jeuxvideo.com/recherche/forums/* // @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js // @license MIT // ==/UserScript== $("body").prepend('<style>.jvcpreview-popup{visibility:hidden;position:absolute;display:block;z-index:999;width:600px;background:#f2f2f2}.jvcpreview-loading{padding:20px;border:1px solid #d5d5d5}.jvcpreview-close{cursor:pointer;position:absolute;right:13px;top:13px;background:#d40000;width:16px;height:16px;color:#fff;z-index:999;border-radius:3px;opacity:.33;text-align:center;font-weight:700;font-size:10px;padding-top:2px}.jvcpreview-close:hover{opacity:1;color:#fff}</style>'); $("body").prepend('<div class="jvcpreview-popup"><a class="jvcpreview-close" title="Fermer">X</a><div class="jvcpreview-loading"><center><img src="http://gifimage.net/wp-content/uploads/2017/09/ajax-loading-gif-transparent-background-8.gif" style="width:64px;height:64px;"></img></center></div><div class="jvcpreview-content"></div></div>'); $(".jvcpreview-close").click(function() { $('.jvcpreview-popup').css({'visibility':'hidden'}); }); var cachedTopics = new Array(); var currentTopic = ""; $( document ).ready(function() { $(".lien-jv.topic-title").each(function(){ $(this).attr("title", ""); }); $( ".lien-jv.topic-title" ).mouseenter(function() { currentTopic = "http://www.jeuxvideo.com/" + $(this).attr("href"); $(".jvcpreview-popup").find(".jvcpreview-loading").css("display", "block"); $(".jvcpreview-popup").find(".jvcpreview-content").css("display", "none"); $(".jvcpreview-popup").css({'visibility':'visible'}); var offset = $(this).offset(); $(".jvcpreview-popup").css({'top':offset.top,'left':offset.left + $(this).width()}); if(cachedTopics["http://www.jeuxvideo.com/" + $(this).attr("href")]) { data = cachedTopics["http://www.jeuxvideo.com/" + $(this).attr("href")]; if($(data).find(".bloc-message-forum")[0]) { $(".jvcpreview-popup").find(".jvcpreview-content").html($(data).find(".bloc-message-forum")[0].outerHTML); $(".jvcpreview-popup").find(".bloc-message-forum").css("margin", "0"); $(".jvcpreview-popup").find(".bloc-message-forum").prepend('<a href="' + this.url + '">' + $(data).find(".titre-head-bloc")[0].outerHTML + '</a>'); $(".jvcpreview-popup").find(".titre-head-bloc").css("border-top", "0"); $(".jvcpreview-popup").find(".titre-head-bloc").css("padding-top", "10px"); $(".jvcpreview-popup").find(".titre-head-bloc").css("padding-left", "10px"); $(".jvcpreview-popup").find(".titre-head-bloc").css("padding-bottom", "0"); $(".jvcpreview-popup").find(".picto-msg-quote").remove(); $(".jvcpreview-popup").find(".picto-msg-tronche").remove(); $(".jvcpreview-popup").find(".picto-msg-exclam").remove(); $(".jvcpreview-popup").find(".jvcpreview-loading").css("display", "none"); $(".jvcpreview-popup").find(".jvcpreview-content").css("display", "block"); $("#forumjs").remove(); $("body").append('<script id="forumjs" src="http://static.jvc.gg/1.62.1/js/forum.js"></script>'); return; } } $.ajax( "http://www.jeuxvideo.com/" + $(this).attr("href") ) .done(function(data) { cachedTopics[this.url] = data; if(currentTopic != this.url) { return; } if($(data).find(".bloc-message-forum")[0]) { $(".jvcpreview-popup").find(".jvcpreview-content").html($(data).find(".bloc-message-forum")[0].outerHTML); $(".jvcpreview-popup").find(".bloc-message-forum").css("margin", "0"); $(".jvcpreview-popup").find(".bloc-message-forum").prepend('<a href="' + this.url + '">' + $(data).find(".titre-head-bloc")[0].outerHTML + '</a>'); $(".jvcpreview-popup").find(".titre-head-bloc").css("border-top", "0"); $(".jvcpreview-popup").find(".titre-head-bloc").css("padding-top", "10px"); $(".jvcpreview-popup").find(".titre-head-bloc").css("padding-left", "10px"); $(".jvcpreview-popup").find(".titre-head-bloc").css("padding-bottom", "0"); $(".jvcpreview-popup").find(".picto-msg-quote").remove(); $(".jvcpreview-popup").find(".picto-msg-tronche").remove(); $(".jvcpreview-popup").find(".picto-msg-exclam").remove(); $(".jvcpreview-popup").find(".jvcpreview-loading").css("display", "none"); $(".jvcpreview-popup").find(".jvcpreview-content").css("display", "block"); $("#forumjs").remove(); $("body").append('<script id="forumjs" src="http://static.jvc.gg/1.62.1/js/forum.js"></script>'); } }) .fail(function( jqXHR, textStatus, errorThrown ) { if(currentTopic != this.url) { return; } if(errorThrown == "Gone"){ $(".jvcpreview-popup").find(".jvcpreview-content").html('<div style="border: 1px solid #d5d5d5;padding:20px;"><center><img src="http://www.jeuxvideo.com/img/erreurs/e410.png" style="width:100%;top:100px;"></img></center></div>'); $(".jvcpreview-popup").find(".jvcpreview-loading").css("display", "none"); $(".jvcpreview-popup").find(".jvcpreview-content").css("display", "block"); } }); }); });