Previsualizer

Permet de prévisualiser un topic.

当前为 2015-04-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Previsualizer
  3. // @namespace JVScript
  4. // @include http://www.jeuxvideo.com/forums/0*
  5. // @version 4
  6. // @require http://code.jquery.com/jquery-2.1.3.min.js
  7. // @grant GM_addStyle
  8. // @copyright MIT
  9. // @description Permet de prévisualiser un topic.
  10. // ==/UserScript==
  11.  
  12. "use strict";
  13.  
  14. (function() {
  15.  
  16. function Link(node) {
  17. this.__content = document.createElement('div');
  18. this.__url = $(node).find('a')[0].href;
  19. this.__node = node;
  20. this.initialize();
  21. }
  22.  
  23. Link.prototype = {
  24. initialize: function() {
  25. var this_ = this;
  26. var container = $(this.__node).parent().parent().find('.info-img')[0];
  27.  
  28. $(container).on('mouseenter', function() {
  29. $(this_.__content).html('<img style="margin: auto; display: block !important; width: 25%;" src="http://s3.noelshack.com/uploads/images/20188032684831_loading.gif" alt="Loading" />');
  30. $.get(this_.__url)
  31. .done(function(response) {
  32. var success = $($.parseHTML(response)).find(".bloc-message-forum");
  33. $(this_.__content).html($(success[0]).html());
  34. })
  35. });
  36. $(this.__content).attr({
  37. 'class': 'prev_content bloc-message-forum'
  38. })
  39. $(container).find('img:first-child').wrap('<a href="' + this.__url + '"></a>');
  40. $(container).append(this.__content);
  41. }
  42. }
  43.  
  44. $('#sortable div.titre-topic').each(function() {
  45. new Link(this);
  46. })
  47.  
  48. GM_addStyle(
  49. '.prev_content {position: absolute; z-index: 1000; width: 595px; max-height: 500px; overflow-y: scroll; display: none; margin-left: 18px; font-weight: 200;}\n'
  50. + '.info-img:hover .prev_content {display: block;}\n'
  51. + '.sujet-topic {overflow: visible !important;}\n'
  52. + '.prev_content img {position: relative !important; display: inline !important;}\n'
  53. );
  54.  
  55. })();