Greasy Fork is available in English.

123Pan去广告

去广告、修改会员[会员无实际效果,仅供娱乐]

  1. // ==UserScript==
  2. // @name 123Pan去广告
  3. // @namespace http://tampermonkey.net/
  4. // @match https://www.123pan.com/*
  5. // @match https://www.123pan.cn/*
  6. // @match https://www.123684.com/*
  7. // @match https://www.123865.com/*
  8. // @grant unsafeWindow
  9. // @grant GM_addStyle
  10. // @run-at document-start
  11. // @version 2.0
  12. // @license MIT
  13. // @author Berger
  14. // @description 去广告、修改会员[会员无实际效果,仅供娱乐]
  15.  
  16.  
  17. // @note 2.0 [修复]精简失效等问题
  18. // @note 1.9 [适配]域名
  19. // @note 1.8 [修复]一些已知的BUG
  20. // @note 1.7 [新增]适配网页下载
  21. // @note 1.6 [适配]123Pan cn域名
  22. // @note 1.5 [修复]无法上传文件的BUG
  23. // @note 1.4 [修复]一些已知的BUG
  24. // @note 1.3 [新增]文件列表默认修改为更新时间降序排序
  25. // @note 1.2 [修复]一些已知的BUG
  26. // @note 1.1 [新增]手机端去广告
  27. // @note 1.0 [新增]PC去广告 [新增]会员修改
  28. // ==/UserScript==
  29.  
  30.  
  31. (function () {
  32. 'use strict';
  33.  
  34. const store = {
  35. modifiedUserInfo: null, path: null,
  36. };
  37.  
  38. const utils = {
  39. removeElement(element) {
  40. if (element) {
  41. element.remove()
  42. }
  43. },
  44.  
  45. removeElementWithCheck(className) {
  46. this.checkElement(className, function (element) {
  47. utils.removeElement(element)
  48. })
  49. },
  50.  
  51. checkElement(className, callback) {
  52. const observer = new MutationObserver(function (mutationsList, observer) {
  53. const element = document.querySelector(className);
  54. if (element) {
  55. observer.disconnect();
  56. callback(element)
  57. }
  58. });
  59.  
  60. observer.observe(document.body, {childList: true, subtree: true});
  61. }
  62. }
  63.  
  64. store.path = new URLSearchParams(new URL(location.href).search).get('path');
  65.  
  66. function modifyUserInfoResponse(originalResponse) {
  67. try {
  68. const modifiedUserInfoResponse = originalResponse
  69. modifiedUserInfoResponse.data.SpacePermanent = 5 * 1024 * 1024 * 1024 * 1024 //总容量
  70. modifiedUserInfoResponse.data.SpaceTempExpr = "2099-01-01T00:00:00+00:00" //容量过期时间
  71. modifiedUserInfoResponse.data.Vip = true // 是否为VIP
  72. modifiedUserInfoResponse.data.VipLevel = 2 // VIP等级
  73. modifiedUserInfoResponse.data.VipExpire = "2099-01-01 08:00:00" // VIP过期时间
  74. modifiedUserInfoResponse.data.SpaceBuy = true // 是否购买容量
  75. modifiedUserInfoResponse.data.GrowSpaceAddCount = 128 // 容量等级
  76. modifiedUserInfoResponse.data.IsAuthentication = true
  77. modifiedUserInfoResponse.data.SignType = 1
  78.  
  79. store.modifiedUserInfo = modifiedUserInfoResponse.data.user
  80. return modifiedUserInfoResponse
  81. } catch (error) {
  82. console.log(error)
  83. return originalResponse // 返回原始响应内容
  84. }
  85. }
  86.  
  87. function applyInterceptors() {
  88. const originOpen = XMLHttpRequest.prototype.open;
  89. const originalSend = XMLHttpRequest.prototype.send;
  90. const originalRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
  91.  
  92. XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
  93. this._url = url;
  94. this._method = method;
  95.  
  96. // 检查并修改 /b/api/share/get 请求的 orderBy 和 orderDirection 参数
  97. if (url.includes('/b/api/share/get')) {
  98. if (!url.includes('orderBy=create_at') && !url.includes('orderDirection=desc')) {
  99. this._url = url.replace('orderBy=file_name', 'orderBy=create_at')
  100. .replace('orderDirection=asc', 'orderDirection=desc');
  101. }
  102. }
  103.  
  104. // 监听 /info 请求的响应
  105. if (url.indexOf('/info') !== -1) {
  106. this.addEventListener('readystatechange', function () {
  107. if (this.readyState === 4) {
  108. const res = JSON.parse(this.responseText);
  109. const modifiedUserInfoResponse = modifyUserInfoResponse(res);
  110. Object.defineProperty(this, "responseText", {
  111. writable: true,
  112. });
  113. this.responseText = modifiedUserInfoResponse;
  114. }
  115. });
  116. }
  117.  
  118. originOpen.call(this, method, this._url, async, user, password);
  119. };
  120.  
  121. XMLHttpRequest.prototype.setRequestHeader = function (header, value) {
  122. if (this._url.includes('/b/api/share/download/info')) {
  123. let headers = {
  124. "user-agent": "123pan/v2.4.0(Android_7.1.2;Xiaomi)",
  125. "platform": "android",
  126. "app-version": "61",
  127. "x-app-version": "2.4.0"
  128. }
  129. if (header.toLowerCase() in headers) {
  130. value = headers[header.toLowerCase()];
  131. }
  132. }
  133. return originalRequestHeader.apply(this, [header, value]);
  134. };
  135.  
  136. XMLHttpRequest.prototype.send = function (body) {
  137. originalSend.call(this, body);
  138. };
  139. }
  140.  
  141. function editShareDownloadButton() {
  142. const mobileDownloadButton = `<svg class="icon undefined" aria-hidden="true"><use xlink:href="#icon-share_folders_downloads"></use></svg>下载文件(插件)`
  143. const webDownloadButton = `<svg class="icon undefined" aria-hidden="true" style="color:#ffffff;margin-right:5px"><use xlink:href="#top_btn_download2"></use></svg>浏览器下载(插件)`
  144.  
  145. if (location.href.indexOf('123pan.com/s') || location.href.indexOf('123pan.cn/s')) {
  146. const mobileDownloadButtonList = document.querySelectorAll('.appBottomBtnNew ')
  147. if (mobileDownloadButtonList.length > 0) {
  148. mobileDownloadButtonList[0].innerHTML = mobileDownloadButton
  149. }
  150.  
  151. const webDownloadButtonList = document.querySelectorAll('.register ')
  152. if (webDownloadButtonList.length > 0) {
  153. webDownloadButtonList[0].innerHTML = webDownloadButton
  154. webDownloadButtonList[0].style.width = '150px'
  155. }
  156. }
  157. }
  158.  
  159. applyInterceptors()
  160.  
  161.  
  162. // 移除电脑端广告
  163. function removeAdForPC() {
  164. // 顶部广告
  165. utils.removeElementWithCheck('div.mfy-main-layout__head')
  166.  
  167. // 右下角广告
  168. utils.removeElementWithCheck('div.activity-box')
  169.  
  170. //产品商城
  171. utils.removeElementWithCheck('div.sider-member-btn')
  172.  
  173. // 其他网盘转入
  174. utils.removeElementWithCheck('div.special-menu-item-container')
  175.  
  176. }
  177.  
  178. function removeUploadAD() {
  179. const targetNode = document.querySelector('div[class="layout-dom"]');
  180. if (!targetNode) {
  181. return; // 如果未找到目标节点,则提前退出
  182. }
  183. const config = {childList: true, subtree: true}; // 添加 subtree 选项,以监听子节点的变动
  184.  
  185. const observer = new MutationObserver((mutationsList, observer) => {
  186. for (const mutation of mutationsList) {
  187. for (const node of mutation.addedNodes) {
  188. if (node.nodeType === 1 && node.classList.contains('upbody')) {
  189. const uploadAD = node.querySelector('div.uppy-Dashboard-slowSpeed-banner')
  190. if (uploadAD) {
  191. uploadAD.remove()
  192. }
  193. observer.disconnect(); // 找到目标节点后断开观察器
  194. return; // 退出循环以避免多次触发
  195. }
  196. }
  197. }
  198. });
  199.  
  200. observer.observe(targetNode, config);
  201. }
  202.  
  203.  
  204. // 移除手机端广告
  205. function removeAdForMobile() {
  206. GM_addStyle('.banner-container-h5{display:none !important}');//右侧登录提示栏
  207. }
  208.  
  209.  
  210. let main = {
  211. init() {
  212. removeAdForMobile()
  213. removeAdForPC()
  214. removeUploadAD()
  215. editShareDownloadButton()
  216. },
  217. }
  218.  
  219. window.addEventListener('DOMContentLoaded', main.init);
  220. }
  221. )()
  222.