Tiny Customize

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

目前為 2016-06-28 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Tiny Customize
  3. // @description 针对一些常用网站,例如 3DMGame、卡饭、巴哈姆特、Chiphell 等的反反广告检测、自动化、屏蔽网站功能等。
  4. // @namespace https://greasyfork.org/zh-CN/scripts/19823-tiny-customize
  5. // @author nonoroazoro
  6. // @include /^https?\:\/\/(bbs)\.3dmgame\.com/
  7. // @include /^https?\:\/\/(bbs)\.kafan\.cn/
  8. // @include /^https?\:\/\/(forum)\.gamer\.com\.tw/
  9. // @include /^https?\:\/\/(www)\.chiphell\.com/
  10. // @version 1.0.5
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. if (typeof unsafeWindow == "undefined")
  15. {
  16. unsafeWindow = window;
  17. }
  18.  
  19. /**
  20. * 获取立即执行的操作。
  21. */
  22. const getInstantActions = function()
  23. {
  24. const host = unsafeWindow.location.host;
  25. const actions = [];
  26.  
  27. if (host === "forum.gamer.com.tw")
  28. {
  29. // 巴哈姆特。
  30.  
  31. // 反反广告检测。
  32. const action = function()
  33. {
  34. if (unsafeWindow.AntiAd)
  35. {
  36. unsafeWindow.AntiAd.check = function() {};
  37. }
  38. };
  39. actions.push(action);
  40. }
  41. else if (
  42. host === "bbs.kafan.cn" ||
  43. host === "bbs.3dmgame.com" ||
  44. host === "www.chiphell.com"
  45. )
  46. {
  47. // 卡饭、3DMGame、Chiphell 论坛(Discuz 驱动的论坛)。
  48.  
  49. // 屏蔽方向键翻页。
  50. const action = function()
  51. {
  52. if (unsafeWindow.keyPageScroll)
  53. {
  54. unsafeWindow.keyPageScroll = function() {};
  55. }
  56. };
  57. actions.push(action);
  58. }
  59.  
  60. return actions;
  61. };
  62.  
  63. /**
  64. * 获取延迟执行的操作。
  65. */
  66. const getLazyActions = function()
  67. {
  68. const host = unsafeWindow.location.host;
  69. const actions = [];
  70.  
  71. if (host === "forum.gamer.com.tw")
  72. {
  73. // 巴哈姆特。
  74.  
  75. // 自动开启图片。
  76. let action = function()
  77. {
  78. if (unsafeWindow.forumShowAllMedia)
  79. {
  80. unsafeWindow.forumShowAllMedia();
  81. }
  82. };
  83. actions.push(action);
  84. }
  85.  
  86. return actions;
  87. };
  88.  
  89. /**
  90. * 立即执行指定的操作。
  91. */
  92. const exec = function(p_actions)
  93. {
  94. if (p_actions)
  95. {
  96. p_actions.forEach(function(p_action)
  97. {
  98. p_action();
  99. });
  100. }
  101. };
  102.  
  103. // 1. 立即执行。
  104. exec(getInstantActions());
  105.  
  106.  
  107. // 2. 延迟执行。
  108. unsafeWindow.addEventListener("load", function()
  109. {
  110. exec(getLazyActions());
  111. }, true);