MyFigureCollection: instant tooltip

Override tooltip function

  1. // ==UserScript==
  2. // @name MyFigureCollection: instant tooltip
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Override tooltip function
  6. // @author Rafael Vuijk
  7. // @match http*://myfigurecollection.net/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var tooltip_index = null; // added to prevent duplicate tooltips
  15.  
  16. $(".tbx-tooltip").each(function() {
  17. var $this=$(this), _move=function(e){
  18. if(!TB.tooltip){return false;}
  19. TB.tooltip.show().css({
  20. top:e.pageY>TB.window.height()/2+TB.window.scrollTop()?e.pageY-TB.tooltip.innerHeight()-10:e.pageY+20,left:e.pageX>TB.window.width()/2?e.pageX-TB.tooltip.innerWidth()-10:e.pageX+20
  21. });
  22. };
  23. $this.off(".tooltip")
  24. .on("mouseenter.tooltip",function(e) {
  25. _resetTooltip();
  26. var vars = _getVars($this).split(":"), index = vars[0]+":"+vars[1];
  27. tooltip_index = index;
  28. if (!(index in TB.cache.tooltip)) {
  29. TB.timer.tooltip = setTimeout(function(){
  30. if (tooltip_index == index) { // added extra check
  31. $.post(jroot+"/actions.php","commit=loadTooltip&objectId="+vars[1]+"&objectType="+vars[0],function(j){
  32. if(TB.timer.tooltip){
  33. if (tooltip_index == index) { // added extra check
  34. TB.cache.tooltip[index]=$("<div></div>").addClass("tooltip").appendTo("#content").html(j.htmlValues.TOOLTIP);
  35. TB.tooltip=TB.cache.tooltip[index]; _move(e);
  36. }
  37. }
  38. }, "json");
  39. }
  40. },0);
  41. } else {
  42. TB.tooltip=TB.cache.tooltip[index]; _move(e);
  43. }
  44. })
  45. .on("mousemove.tooltip",function(e){
  46. _move(e);
  47. })
  48. .on("mouseleave.tooltip",function(){
  49. _resetTooltip();
  50. });
  51. });
  52.  
  53. })();