Tiny Customize

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

Verze ze dne 13. 08. 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?\:\/\/login\.taobao\.com/
  12. // @include /^https?\:\/\/poedb\.tw(\/?.*)\/dps/
  13. // @include /^https?\:\/\/tieba\.baidu\.com/
  14. // @version 1.1.2
  15. // @grant none
  16. // ==/UserScript==
  17.  
  18. if (typeof unsafeWindow == "undefined")
  19. {
  20. unsafeWindow = window;
  21. }
  22.  
  23. /**
  24. * 获取立即执行的操作。
  25. */
  26. const getInstantActions = function()
  27. {
  28. const host = unsafeWindow.location.host;
  29. const href = unsafeWindow.location.href;
  30. const actions = [];
  31.  
  32. if (host === "forum.gamer.com.tw")
  33. {
  34. // 巴哈姆特。
  35.  
  36. // 反反广告检测。
  37. const action = function()
  38. {
  39. if (unsafeWindow.AntiAd)
  40. {
  41. unsafeWindow.AntiAd.check = function() {};
  42. }
  43. };
  44. actions.push(action);
  45. }
  46. else if (
  47. host === "bbs.kafan.cn" ||
  48. host === "bbs.3dmgame.com" ||
  49. host === "www.chiphell.com"
  50. )
  51. {
  52. // 卡饭、3DMGame、Chiphell 论坛(Discuz 驱动的论坛)。
  53.  
  54. // 屏蔽方向键翻页。
  55. const action = function()
  56. {
  57. if (unsafeWindow.keyPageScroll)
  58. {
  59. unsafeWindow.keyPageScroll = function() {};
  60. }
  61. };
  62. actions.push(action);
  63. }
  64. else if (/^https?\:\/\/poedb\.tw(\/?.*)\/dps/.test(href))
  65. {
  66. // 流亡编年史。
  67.  
  68. // 屏蔽默认自动全选物品信息、自动查询物品信息。
  69. const action = function()
  70. {
  71. const elem = document.querySelector(`#iteminfo`);
  72. elem.addEventListener("click", (e) =>
  73. {
  74. e.stopPropagation();
  75. }, true);
  76.  
  77. elem.addEventListener("keydown", (e) =>
  78. {
  79. if (e.key === "Enter")
  80. {
  81. document.querySelector(`form[action^="dps"]`).submit();
  82. e.preventDefault();
  83. }
  84. }, true);
  85.  
  86. elem.addEventListener("keyup", (e) =>
  87. {
  88. if (e.ctrlKey && (e.key === "v" || e.key === "V"))
  89. {
  90. document.querySelector(`form[action^="dps"]`).submit();
  91. }
  92. });
  93. };
  94. actions.push(action);
  95. }
  96.  
  97. return actions;
  98. };
  99.  
  100. /**
  101. * 获取延迟执行的操作。
  102. */
  103. const getLazyActions = function()
  104. {
  105. const host = unsafeWindow.location.host;
  106. const actions = [];
  107.  
  108. if (host === "forum.gamer.com.tw")
  109. {
  110. // 巴哈姆特。
  111.  
  112. // 自动开启图片。
  113. let action = function()
  114. {
  115. if (unsafeWindow.forumShowAllMedia)
  116. {
  117. unsafeWindow.forumShowAllMedia();
  118. }
  119. };
  120. actions.push(action);
  121. }
  122. else if (host === "tieba.baidu.com")
  123. {
  124. // 贴吧。
  125.  
  126. // 个人中心新标签打开。
  127. let action = function()
  128. {
  129. const timer = unsafeWindow.setInterval(() =>
  130. {
  131. const elem = document.querySelector(`a.u_menu_wrap[title^="点击到个人中心"`);
  132. if (elem)
  133. {
  134. elem.target = "_blank";
  135. unsafeWindow.clearInterval(timer);
  136. }
  137. }, 100);
  138. };
  139. actions.push(action);
  140.  
  141. // 删除广告贴。
  142. action = function()
  143. {
  144. const parent = document.querySelector(`#j_p_postlist`);
  145. const elems = document.querySelectorAll(`#j_p_postlist > div`);
  146. for (let elem of elems)
  147. {
  148. if (elem.className.trim() !== "l_post l_post_bright j_l_post clearfix")
  149. {
  150. parent.removeChild(elem);
  151. }
  152. }
  153. };
  154. actions.push(action);
  155. }
  156. else if (host === "login.taobao.com")
  157. {
  158. // 淘宝。
  159.  
  160. // 默认显示密码登录(而非 QR 码登录)界面。
  161. let action = function()
  162. {
  163. const elem = document.querySelector(`.iconfont.static`);
  164. if (elem)
  165. {
  166. elem.click();
  167. }
  168. };
  169. actions.push(action);
  170. }
  171.  
  172. return actions;
  173. };
  174.  
  175. /**
  176. * 立即执行指定的操作。
  177. */
  178. const exec = function(p_actions)
  179. {
  180. if (p_actions)
  181. {
  182. p_actions.forEach(function(p_action)
  183. {
  184. p_action();
  185. });
  186. }
  187. };
  188.  
  189. // 1. 立即执行。
  190. exec(getInstantActions());
  191.  
  192.  
  193. // 2. 延迟执行。
  194. unsafeWindow.addEventListener("load", function()
  195. {
  196. exec(getLazyActions());
  197. }, true);