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 5
  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. $(this.__content).attr({
  29. 'class': 'prev_content bloc-message-forum'
  30. })
  31.  
  32. $(container).on('mouseenter', function() {
  33. $(this_.__content).html('<img style="margin: auto; display: block !important; width: 25%;" src="http://s3.noelshack.com/uploads/images/20188032684831_loading.gif" alt="Loading" />');
  34. $.get(this_.__url)
  35. .done(function(response) {
  36. var success = $($.parseHTML(response)).find(".bloc-message-forum");
  37. $(this_.__content).html($(success[0]).html());
  38. })
  39. })
  40. .find('img:first-child')
  41. .wrap('<a href="' + this.__url + '"></a>');
  42. $(container).append(this.__content);
  43. }
  44. }
  45.  
  46. $('#sortable div.titre-topic').each(function() {
  47. new Link(this);
  48. })
  49.  
  50. GM_addStyle(
  51. '.prev_content {position: absolute; z-index: 1000; width: 595px; max-height: 500px; overflow-y: scroll; display: none; margin-left: 18px; font-weight: 200;}\n'
  52. + '.info-img:hover .prev_content {display: block;}\n'
  53. + '.sujet-topic {overflow: visible !important;}\n'
  54. + '.prev_content img {position: relative !important; display: inline !important;}\n'
  55. );
  56.  
  57. })();