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