Tiny Customize

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

As of 2016-09-22. See the latest version.

  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 http://bbs.3dmgame.com/*
  8. // @include http://bbs.kafan.cn/*
  9. // @include http://forum.gamer.com.tw/*
  10. // @include http://poedb.tw/dps/*
  11. // @include http://tieba.baidu.com/*
  12. // @include http://www.poelab.com/*
  13. // @include https://login.taobao.com/*
  14. // @include https://www.chiphell.com/*
  15. // @version 1.1.5
  16. // @grant none
  17. // ==/UserScript==
  18.  
  19. if (typeof unsafeWindow == "undefined")
  20. {
  21. unsafeWindow = window;
  22. }
  23.  
  24. const host = unsafeWindow.location.host;
  25. const href = unsafeWindow.location.href;
  26. const pathname = unsafeWindow.location.pathname;
  27.  
  28. /**
  29. * 获取立即执行的操作。
  30. */
  31. const getInstantActions = function ()
  32. {
  33. const actions = [];
  34.  
  35. if (host === "forum.gamer.com.tw")
  36. {
  37. // 巴哈姆特。
  38.  
  39. // 反反广告检测。
  40. const action = function ()
  41. {
  42. if (unsafeWindow.AntiAd)
  43. {
  44. unsafeWindow.AntiAd.check = function () { };
  45. }
  46. };
  47. actions.push(action);
  48. }
  49. else if (
  50. host === "bbs.kafan.cn" ||
  51. host === "bbs.3dmgame.com" ||
  52. host === "www.chiphell.com"
  53. )
  54. {
  55. // 卡饭、3DMGame、Chiphell 论坛(Discuz 驱动的论坛)。
  56.  
  57. // 屏蔽方向键翻页。
  58. const action = function ()
  59. {
  60. if (unsafeWindow.keyPageScroll)
  61. {
  62. unsafeWindow.keyPageScroll = function () { };
  63. }
  64. };
  65. actions.push(action);
  66. }
  67. else if (/^https?\:\/\/poedb\.tw(\/?.*)\/dps/.test(href))
  68. {
  69. // 流亡编年史。
  70.  
  71. // 屏蔽默认自动全选物品信息、自动查询物品信息。
  72. const action = function ()
  73. {
  74. const elem = document.querySelector(`#iteminfo`);
  75. elem.addEventListener("click", (e) =>
  76. {
  77. e.stopPropagation();
  78. }, true);
  79.  
  80. elem.addEventListener("keydown", (e) =>
  81. {
  82. if (e.key === "Enter")
  83. {
  84. document.querySelector(`form[action^="dps"]`).submit();
  85. e.preventDefault();
  86. }
  87. }, true);
  88.  
  89. elem.addEventListener("keyup", (e) =>
  90. {
  91. if (e.ctrlKey && (e.key === "v" || e.key === "V"))
  92. {
  93. document.querySelector(`form[action^="dps"]`).submit();
  94. }
  95. });
  96. };
  97. actions.push(action);
  98. }
  99. else if (host === "login.taobao.com")
  100. {
  101. // 淘宝。
  102.  
  103. // 默认显示密码登录(而非 QR 码登录)界面。
  104. let action = function ()
  105. {
  106. // 始终显示密码登录。
  107. let elems = document.querySelectorAll(`.static-form, .iconfont.static`);
  108. for (let elem of elems)
  109. {
  110. elem.setAttribute("style", "display: block !important");
  111. }
  112.  
  113. // 删除扫码登录。
  114. elems = document.querySelectorAll(`.login-switch, .login-tip, .iconfont.quick, .quick-form`);
  115. for (let elem of elems)
  116. {
  117. elem.remove();
  118. }
  119. };
  120. actions.push(action);
  121. }
  122.  
  123. return actions;
  124. };
  125.  
  126. /**
  127. * 获取延迟执行的操作。
  128. */
  129. const getLazyActions = function ()
  130. {
  131. const actions = [];
  132.  
  133. if (host === "forum.gamer.com.tw")
  134. {
  135. // 巴哈姆特。
  136.  
  137. // 自动开启图片。
  138. let action = function ()
  139. {
  140. if (unsafeWindow.forumShowAllMedia)
  141. {
  142. unsafeWindow.forumShowAllMedia();
  143. }
  144. };
  145. actions.push(action);
  146. }
  147. else if (host === "www.poelab.com")
  148. {
  149. // POE Lab
  150.  
  151. let action = function ()
  152. {
  153. const selectors = {
  154. "/": [
  155. "#comp-iqi4593u",
  156. "#comp-iqi4593h",
  157. "#comp-iqi45938",
  158. "#comp-iqi4593d"
  159. ],
  160. "/normal": ["#comp-inp50zrf"],
  161. "/cruel": ["#comp-inp5lj3v"],
  162. "/merciless": ["#comp-inpbrgjs"],
  163. "/uber": ["#comp-ip1tde81"],
  164. }[pathname];
  165.  
  166. if (selectors)
  167. {
  168. let elem;
  169. selectors.forEach(function (selector)
  170. {
  171. elem = document.querySelector(selector);
  172. if (elem)
  173. {
  174. document.body.appendChild(elem);
  175. elem.style.position = "unset";
  176. elem.style.margin = "10px auto";
  177. }
  178. });
  179. document.getElementById("SITE_CONTAINER").remove();
  180. document.body.style.backgroundColor = "#232323";
  181. }
  182. };
  183. actions.push(action);
  184. }
  185. else if (host === "tieba.baidu.com")
  186. {
  187. // 贴吧。
  188. console.log(host);
  189.  
  190. // 个人中心新标签打开。
  191. let action = function ()
  192. {
  193. const timer = unsafeWindow.setInterval(() =>
  194. {
  195. const elem = document.querySelector(`a.u_menu_wrap[title^="点击到个人中心"`);
  196. if (elem)
  197. {
  198. elem.target = "_blank";
  199. unsafeWindow.clearInterval(timer);
  200. }
  201. }, 100);
  202. };
  203. actions.push(action);
  204.  
  205. // 删除广告贴。
  206. action = function ()
  207. {
  208. let spans;
  209. const elems = document.querySelectorAll(`#j_p_postlist > div`);
  210. for (let elem of elems)
  211. {
  212. spans = elem.querySelectorAll(`.core_reply_tail span`);
  213. for (let s of spans)
  214. {
  215. if (s.innerText.trim() === "商业推广")
  216. {
  217. elem.remove();
  218. break;
  219. }
  220. }
  221. }
  222. };
  223. actions.push(action);
  224. }
  225.  
  226. return actions;
  227. };
  228.  
  229. /**
  230. * 立即执行指定的操作。
  231. */
  232. const exec = function (p_actions)
  233. {
  234. if (p_actions)
  235. {
  236. p_actions.forEach(function (p_action)
  237. {
  238. p_action();
  239. });
  240. }
  241. };
  242.  
  243. // 1. 立即执行。
  244. exec(getInstantActions());
  245.  
  246. // 2. 延迟执行。
  247. unsafeWindow.addEventListener("load", function ()
  248. {
  249. exec(getLazyActions());
  250. }, true);