Tiny Customize

针对一些常用网站,例如 3DMGame、卡饭、巴哈姆特、流亡编年史、Chiphell、等的反反广告检测、自动化、屏蔽网站功能等。

As of 2016-07-04. See the latest version.

  1. // ==UserScript==
  2. // @name Tiny Customize
  3. // @description 针对一些常用网站,例如 3DMGame、卡饭、巴哈姆特、流亡编年史、Chiphell、等的反反广告检测、自动化、屏蔽网站功能等。
  4. // @namespace https://greatest.deepsurf.us/zh-CN/scripts/19823-tiny-customize
  5. // @homepageURL https://greatest.deepsurf.us/zh-CN/scripts/19823-tiny-customize
  6. // @author nonoroazoro
  7. // @include /^https?\:\/\/(bbs)\.3dmgame\.com/
  8. // @include /^https?\:\/\/(bbs)\.kafan\.cn/
  9. // @include /^https?\:\/\/(forum)\.gamer\.com\.tw/
  10. // @include /^https?\:\/\/(www)\.chiphell\.com/
  11. // @include /^https?\:\/\/poedb\.tw(\/?.*)\/dps/
  12. // @version 1.0.7
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. if (typeof unsafeWindow == "undefined")
  17. {
  18. unsafeWindow = window;
  19. }
  20.  
  21. /**
  22. * 获取立即执行的操作。
  23. */
  24. const getInstantActions = function()
  25. {
  26. const host = unsafeWindow.location.host;
  27. const href = unsafeWindow.location.href;
  28. const actions = [];
  29.  
  30. if (host === "forum.gamer.com.tw")
  31. {
  32. // 巴哈姆特。
  33.  
  34. // 反反广告检测。
  35. const action = function()
  36. {
  37. if (unsafeWindow.AntiAd)
  38. {
  39. unsafeWindow.AntiAd.check = function() {};
  40. }
  41. };
  42. actions.push(action);
  43. }
  44. else if (
  45. host === "bbs.kafan.cn" ||
  46. host === "bbs.3dmgame.com" ||
  47. host === "www.chiphell.com"
  48. )
  49. {
  50. // 卡饭、3DMGame、Chiphell 论坛(Discuz 驱动的论坛)。
  51.  
  52. // 屏蔽方向键翻页。
  53. const action = function()
  54. {
  55. if (unsafeWindow.keyPageScroll)
  56. {
  57. unsafeWindow.keyPageScroll = function() {};
  58. }
  59. };
  60. actions.push(action);
  61. }
  62. else if (/^https?\:\/\/poedb\.tw(\/?.*)\/dps/.test(href))
  63. {
  64. // 流亡编年史。
  65.  
  66. // 屏蔽默认自动全选物品信息、自动查询物品信息。
  67. const action = function()
  68. {
  69. const elem = document.querySelector(`#iteminfo`);
  70. elem.addEventListener("click", (e) =>
  71. {
  72. e.stopPropagation();
  73. }, true);
  74.  
  75. elem.addEventListener("keydown", (e) =>
  76. {
  77. if (e.key === "Enter")
  78. {
  79. document.querySelector(`form[action^="dps"]`).submit();
  80. e.preventDefault();
  81. }
  82. }, true);
  83.  
  84. elem.addEventListener("paste", (e) =>
  85. {
  86. document.querySelector(`form[action^="dps"]`).submit();
  87. });
  88. };
  89. actions.push(action);
  90. }
  91.  
  92. return actions;
  93. };
  94.  
  95. /**
  96. * 获取延迟执行的操作。
  97. */
  98. const getLazyActions = function()
  99. {
  100. const host = unsafeWindow.location.host;
  101. const actions = [];
  102.  
  103. if (host === "forum.gamer.com.tw")
  104. {
  105. // 巴哈姆特。
  106.  
  107. // 自动开启图片。
  108. let action = function()
  109. {
  110. if (unsafeWindow.forumShowAllMedia)
  111. {
  112. unsafeWindow.forumShowAllMedia();
  113. }
  114. };
  115. actions.push(action);
  116. }
  117.  
  118. return actions;
  119. };
  120.  
  121. /**
  122. * 立即执行指定的操作。
  123. */
  124. const exec = function(p_actions)
  125. {
  126. if (p_actions)
  127. {
  128. p_actions.forEach(function(p_action)
  129. {
  130. p_action();
  131. });
  132. }
  133. };
  134.  
  135. // 1. 立即执行。
  136. exec(getInstantActions());
  137.  
  138.  
  139. // 2. 延迟执行。
  140. unsafeWindow.addEventListener("load", function()
  141. {
  142. exec(getLazyActions());
  143. }, true);