Tiny Customize

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

Verze ze dne 28. 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.4
  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. else if (host === "login.taobao.com")
  97. {
  98. // 淘宝。
  99.  
  100. // 默认显示密码登录(而非 QR 码登录)界面。
  101. let action = function()
  102. {
  103. // 始终显示密码登录。
  104. let elems = document.querySelectorAll(`.static-form, .iconfont.static`);
  105. for (let elem of elems)
  106. {
  107. elem.setAttribute("style", "display: block !important");
  108. }
  109.  
  110. // 删除扫码登录。
  111. elems = document.querySelectorAll(`.login-switch, .login-tip, .iconfont.quick, .quick-form`);
  112. for (let elem of elems)
  113. {
  114. elem.parentNode.removeChild(elem);
  115. }
  116. };
  117. actions.push(action);
  118. }
  119.  
  120. return actions;
  121. };
  122.  
  123. /**
  124. * 获取延迟执行的操作。
  125. */
  126. const getLazyActions = function()
  127. {
  128. const host = unsafeWindow.location.host;
  129. const actions = [];
  130.  
  131. if (host === "forum.gamer.com.tw")
  132. {
  133. // 巴哈姆特。
  134.  
  135. // 自动开启图片。
  136. let action = function()
  137. {
  138. if (unsafeWindow.forumShowAllMedia)
  139. {
  140. unsafeWindow.forumShowAllMedia();
  141. }
  142. };
  143. actions.push(action);
  144. }
  145. else if (host === "tieba.baidu.com")
  146. {
  147. // 贴吧。
  148.  
  149. // 个人中心新标签打开。
  150. let action = function()
  151. {
  152. const timer = unsafeWindow.setInterval(() =>
  153. {
  154. const elem = document.querySelector(`a.u_menu_wrap[title^="点击到个人中心"`);
  155. if (elem)
  156. {
  157. elem.target = "_blank";
  158. unsafeWindow.clearInterval(timer);
  159. }
  160. }, 100);
  161. };
  162. actions.push(action);
  163.  
  164. // 删除广告贴。
  165. action = function()
  166. {
  167. let spans;
  168. const parent = document.querySelector(`#j_p_postlist`);
  169. const elems = document.querySelectorAll(`#j_p_postlist > div`);
  170. for (let elem of elems)
  171. {
  172. spans = elem.querySelectorAll(`.core_reply_tail span`);
  173. for (let s of spans)
  174. {
  175. if (s.innerText.trim() === "商业推广")
  176. {
  177. parent.removeChild(elem);
  178. break;
  179. }
  180. }
  181. }
  182. };
  183. actions.push(action);
  184. }
  185.  
  186. return actions;
  187. };
  188.  
  189. /**
  190. * 立即执行指定的操作。
  191. */
  192. const exec = function(p_actions)
  193. {
  194. if (p_actions)
  195. {
  196. p_actions.forEach(function(p_action)
  197. {
  198. p_action();
  199. });
  200. }
  201. };
  202.  
  203. // 1. 立即执行。
  204. exec(getInstantActions());
  205.  
  206.  
  207. // 2. 延迟执行。
  208. unsafeWindow.addEventListener("load", function()
  209. {
  210. exec(getLazyActions());
  211. }, true);