🏠 Home 

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