Tiny Customize

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

Verze ze dne 05. 07. 2016. Zobrazit nejnovější verzi.

  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.8
  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("keyup", (e) =>
  85. {
  86. if (e.ctrlKey && (e.key === "v" || e.key === "V"))
  87. {
  88. document.querySelector(`form[action^="dps"]`).submit();
  89. }
  90. });
  91. };
  92. actions.push(action);
  93. }
  94.  
  95. return actions;
  96. };
  97.  
  98. /**
  99. * 获取延迟执行的操作。
  100. */
  101. const getLazyActions = function()
  102. {
  103. const host = unsafeWindow.location.host;
  104. const actions = [];
  105.  
  106. if (host === "forum.gamer.com.tw")
  107. {
  108. // 巴哈姆特。
  109.  
  110. // 自动开启图片。
  111. let action = function()
  112. {
  113. if (unsafeWindow.forumShowAllMedia)
  114. {
  115. unsafeWindow.forumShowAllMedia();
  116. }
  117. };
  118. actions.push(action);
  119. }
  120.  
  121. return actions;
  122. };
  123.  
  124. /**
  125. * 立即执行指定的操作。
  126. */
  127. const exec = function(p_actions)
  128. {
  129. if (p_actions)
  130. {
  131. p_actions.forEach(function(p_action)
  132. {
  133. p_action();
  134. });
  135. }
  136. };
  137.  
  138. // 1. 立即执行。
  139. exec(getInstantActions());
  140.  
  141.  
  142. // 2. 延迟执行。
  143. unsafeWindow.addEventListener("load", function()
  144. {
  145. exec(getLazyActions());
  146. }, true);