Tiny Customize

针对一些常用网站的反反广告、自动化等。

As of 2016-05-20. See the latest version.

  1. // ==UserScript==
  2. // @name Tiny Customize
  3. // @description 针对一些常用网站的反反广告、自动化等。
  4. // @namespace xiaochao.k@gmail.com
  5. // @author xiaochao.k@gmail.com
  6. // @include http://forum.gamer.com.tw/*
  7. // @version 1.0.1
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. if (typeof unsafeWindow == "undefined")
  12. {
  13. unsafeWindow = window;
  14. }
  15.  
  16. /**
  17. * 获取立即执行的操作。
  18. */
  19. const getInstantActions = function()
  20. {
  21. const actions = [];
  22.  
  23. // 巴哈姆特 - 反广告检测。
  24. const action = function()
  25. {
  26. if (unsafeWindow.AntiAd)
  27. {
  28. unsafeWindow.AntiAd.check = function() {};
  29. }
  30. };
  31. actions.push(action);
  32.  
  33. return actions;
  34. };
  35.  
  36. /**
  37. * 获取延迟执行的操作。
  38. */
  39. const getLazyActions = function()
  40. {
  41. const actions = [];
  42.  
  43. // 巴哈姆特 - 自动开启图片。
  44. let action = function()
  45. {
  46. if (unsafeWindow.forumShowAllMedia)
  47. {
  48. unsafeWindow.forumShowAllMedia();
  49. }
  50. };
  51. actions.push(action);
  52.  
  53. return actions;
  54. };
  55.  
  56. /**
  57. * 执行指定的操作。
  58. */
  59. const exec = function(p_actions)
  60. {
  61. if (p_actions)
  62. {
  63. p_actions.forEach(function(p_action)
  64. {
  65. p_action();
  66. });
  67. }
  68. };
  69.  
  70. // 1. 立即执行。
  71. exec(getInstantActions());
  72.  
  73.  
  74. // 2. 延迟执行。
  75. unsafeWindow.addEventListener("load", function()
  76. {
  77. exec(getLazyActions());
  78. }, true);