Greasy Fork is available in English.

jandan.net - 煎蛋网

鼠标悬浮至GIF自动播放,鼠标悬浮至[ShowMore]上自动展开/收起。

  1. // ==UserScript==
  2. // @name jandan.net - 煎蛋网
  3. // @namespace https://github.com/maijz128
  4. // @version 0.2.0
  5. // @description 鼠标悬浮至GIF自动播放,鼠标悬浮至[ShowMore]上自动展开/收起。
  6. // @author MaiJZ
  7. // @match *://*.jandan.net/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11.  
  12. (function () {
  13. main();
  14. })();
  15.  
  16. function main() {
  17. setTimeout(function () {
  18. GIF();
  19. ShowMore();
  20. }, 1000);
  21. }
  22.  
  23. function GIF() {
  24. $(".gif-mask").hover(function () { // mouseenter event
  25. $(this).click();
  26.  
  27. var el_acv_comment = $(this).parent().parent();
  28. el_acv_comment.click();
  29. }, function () { // mouseleave event
  30. // do some thing...
  31. });
  32. }
  33.  
  34. function ShowMore_Trigger(hoverTime, callback) {
  35. var self = this;
  36. this._element = null;
  37. this._timeout = null;
  38. this._hoverTime = hoverTime;
  39. this._callback = callback;
  40.  
  41. this.start = function (element) {
  42. self.cancel();
  43.  
  44. self._element = element;
  45. self._timeout = setTimeout(function () {
  46. if (self._element !== null && self._callback !== null) {
  47. self._callback(self._element);
  48. }
  49. }, self._hoverTime);
  50. };
  51.  
  52. this.cancel = function () {
  53. self._element = null;
  54. clearTimeout(self._timeout);
  55. };
  56. }
  57.  
  58. function ShowMore() {
  59. var trigger = new ShowMore_Trigger(500, function (element) {
  60. $(element).click();
  61. });
  62.  
  63. $('.show_more').each(function (index, element) {
  64. $(this).hover(function () { // mouseenter event
  65. trigger.start($(this));
  66. }, function () { // mouseleave event
  67. trigger.cancel();
  68. });
  69. });
  70.  
  71. }
  72.  
  73. function matchURL(url) {
  74. const URL = window.location.href;
  75. return URL.indexOf(url) > -1;
  76. }
  77.  
  78. function addStyle(styleContent) {
  79. var elStyle = document.createElement("style");
  80. elStyle.innerHTML = styleContent;
  81. document.head.appendChild(elStyle);
  82. }