Tiny Customize

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

当前为 2016-11-22 提交的版本,查看 最新版本

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