aio

个人实用小插件

  1. // ==UserScript==
  2. // @name aio
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-01-13
  5. // @description 个人实用小插件
  6. // @author jiejiejie
  7. // @match *://*.juquge.com/*
  8. // @match *://geek-docs.com/*
  9. // @match *://weixin110.qq.com/*
  10. // @match *://cowork.apexsoft.com.cn/*
  11. // @match *://www.bilibili.com/*
  12. // @icon https://www.google.com/s2/favicons?sz=64&domain=juquge.com
  13. // @grant none
  14. // ==/UserScript==
  15. var timer = null;
  16. var aio = () => {
  17. // 等待页面加载完成
  18. // 获取当前用户 url
  19. const getCurrentUrl = () => window.location.href;
  20. const getWebSite = (url) => {
  21. let juqugeReg = /juquge/;
  22. let geekDocsReg = /geek-docs/;
  23. let coworkReg = /cowork/;
  24. let bilibili = /bilibili/;
  25. if (juqugeReg.test(url)) {
  26. return "juquge";
  27. } else if (geekDocsReg.test(url)) {
  28. return "geekDocs";
  29. } else if (coworkReg.test(url)) {
  30. return "cowork";
  31. } else if (bilibili.test(url)) {
  32. return "bilibili";
  33. }
  34. };
  35. // 处理笔趣阁样式
  36. const DealJuquge = () => {
  37. const init = () => {
  38. };
  39. const main = () => {
  40. };
  41. init();
  42. main();
  43. };
  44. // 处理极客文档
  45. const DealGeekDocs = () => {
  46. // 解锁无法滚动
  47. const unlockScroll = () => {
  48. document.body.setAttribute("style", "overflow: auto");
  49. console.log("滚动条已解锁");
  50. };
  51. // 删除广告
  52. const deleteAds = () => {
  53. // 删除开屏广告
  54. let viewAdEle = document.querySelector(".fc-message-root");
  55. viewAdEle?.parentElement?.removeChild(viewAdEle);
  56. // 删除右侧广告
  57. let rightAds = document.querySelector(".tbrside");
  58. rightAds?.parentElement?.removeChild(rightAds);
  59. // 删除底部广告
  60. let bottomAds = document.querySelector(".adsbygoogle");
  61. bottomAds?.parentElement?.removeChild(bottomAds);
  62. // 去除文章中广告
  63. let contentAds = document.querySelectorAll(".eaa_desktop");
  64. contentAds.forEach((item) => {
  65. item.parentElement?.removeChild(item);
  66. });
  67. console.log("广告已删除");
  68. };
  69. // 平铺文章
  70. const fullContent = () => {
  71. let contentWrapEle = document.querySelector(".content-wrap");
  72. let contentEle = document.querySelector(".content");
  73. contentWrapEle.setAttribute("style", "margin-right: 0 !important");
  74. contentEle.setAttribute("style", "margin-right: 0 !important");
  75. console.log("文章已平铺");
  76. };
  77. const init = () => {
  78. let clearButton = document.createElement("button");
  79. clearButton.innerHTML = "清除广告";
  80. clearButton.setAttribute("style", "position: fixed; bottom: 100px; right: 0; z-index: 9999999999;");
  81. clearButton.onclick = main;
  82. document.body.appendChild(clearButton);
  83. // deal_geekDocs()
  84. };
  85. const main = () => {
  86. unlockScroll();
  87. deleteAds();
  88. fullContent();
  89. };
  90. init();
  91. };
  92. // 处理系统浏览器打开微信 110 页面
  93. const DealWeixin110 = () => {
  94. };
  95. // 处理 cowork 在 firefox 上的样式问题
  96. const DealCowork = () => {
  97. let iframeEle = document.querySelector("iframe").contentWindow;
  98. const dealAlert = () => {
  99. iframeEle.alert = () => {
  100. };
  101. window.alert = () => {
  102. };
  103. };
  104. const dealStyle = () => {
  105. let fixButton = document.createElement("button");
  106. fixButton.innerHTML = "修复样式";
  107. fixButton.onclick = () => {
  108. let contentEle = iframeEle.document.querySelector(".mainContainer");
  109. contentEle.setAttribute("style", "width:-webkit-fill-available;height: 100%;");
  110. };
  111. let mountNodeLength = iframeEle.document.querySelectorAll(".left_menu").length;
  112. let buttonForm = iframeEle.document.querySelectorAll(".left_menu")[mountNodeLength - 1 > 0 ? mountNodeLength - 1 : 0];
  113. buttonForm.appendChild(fixButton);
  114. };
  115. dealAlert();
  116. dealStyle();
  117. };
  118. // 添加 bilibili 控件
  119. const DealBilibili = () => {
  120. console.log("bilibili-aio-loaded");
  121. let toolboxLeft = document.querySelector(".video-toolbar-left");
  122. let playbackRateBtnPlus = document.createElement("button");
  123. let playbackRateBtnMinus = document.createElement("button");
  124. playbackRateBtnPlus.innerHTML = ">>+";
  125. playbackRateBtnMinus.innerHTML = "<<-";
  126. playbackRateBtnPlus.setAttribute("style", "padding: 0px 12px;font-size:14px;");
  127. playbackRateBtnMinus.setAttribute("style", "padding: 0px 12px;font-size:14px;");
  128. playbackRateBtnPlus.onclick = () => {
  129. let video = document.querySelector("video");
  130. let currentRate = video.playbackRate;
  131. video.playbackRate = currentRate + 0.5;
  132. };
  133. playbackRateBtnMinus.onclick = () => {
  134. let video = document.querySelector("video");
  135. let currentRate = video.playbackRate;
  136. video.playbackRate = currentRate - 0.5;
  137. };
  138. toolboxLeft.appendChild(playbackRateBtnPlus);
  139. toolboxLeft.appendChild(playbackRateBtnMinus);
  140. };
  141. if (!window || !window.addEventListener) {
  142. if (timer) {
  143. console.log("by aio: window dont exist and timer is empty");
  144. clearTimeout(timer);
  145. }
  146. timer = setTimeout(() => {
  147. console.log("by aio: aio will run after 2s");
  148. aio();
  149. }, 2000);
  150. } else {
  151. if (timer) {
  152. console.log("by aio: window exist and timer is not empty, timer will be cleared");
  153. clearTimeout(timer);
  154. }
  155. window.addEventListener("load", () => {
  156. console.log("by aio: window loaded");
  157. let currentUrl = getCurrentUrl();
  158. let webSite = getWebSite(currentUrl);
  159. console.log(webSite);
  160. switch (webSite) {
  161. case "juquge":
  162. DealJuquge();
  163. break;
  164. case "geekDocs":
  165. DealGeekDocs();
  166. break;
  167. case "weixin110":
  168. break;
  169. case "cowork":
  170. DealCowork();
  171. break;
  172. case "bilibili":
  173. DealBilibili();
  174. break;
  175. default:
  176. console.log("当前页面无法处理");
  177. }
  178. // DealWeixin110()
  179. window.removeEventListener("load", () => {
  180. });
  181. });
  182. }
  183. };
  184. aio();