// ==UserScript== // @name 123Pan去广告 // @namespace http://tampermonkey.net/ // @match https://www.123pan.com/ // @match https://www.123pan.com/* // @grant unsafeWindow // @grant GM_addStyle // @run-at document-start // @version 1.3 // @license MIT // @author Berger // @description 去广告、修改会员[仅供娱乐使用] // @note 1.3 [新增]文件列表默认修改为更新时间降序排序 // @note 1.2 [修复]一些已知的BUG // @note 1.1 [新增]手机端去广告 // @note 1.0 [新增]PC去广告 [新增]会员修改 // @downloadURL none // ==/UserScript== (function () { 'use strict'; const store = { modifiedUserInfo: null, path: null, }; const originOpen = XMLHttpRequest.prototype.open; const originalSend = XMLHttpRequest.prototype.send; store.path = new URLSearchParams(new URL(location.href).search).get('path'); function modifyUserInfoResponse(originalResponse) { try { const modifiedUserInfoResponse = originalResponse modifiedUserInfoResponse.data.SpacePermanent = 500 * 1024 * 1024 * 1024 //总容量 modifiedUserInfoResponse.data.SpaceTempExpr = "2099-01-01T00:00:00+00:00" //容量过期时间 modifiedUserInfoResponse.data.Vip = true // 是否为VIP modifiedUserInfoResponse.data.VipLevel = 2 // VIP等级 modifiedUserInfoResponse.data.VipExpire = "2099-01-01 08:00:00" // VIP过期时间 modifiedUserInfoResponse.data.SpaceBuy = true // 是否购买容量 modifiedUserInfoResponse.data.GrowSpaceAddCount = 128 // 容量等级 modifiedUserInfoResponse.data.IsAuthentication = true modifiedUserInfoResponse.data.SignType = 1 store.modifiedUserInfo = modifiedUserInfoResponse.data.user return modifiedUserInfoResponse } catch (error) { console.log(error) return originalResponse // 返回原始响应内容 } } function responseInterceptors() { XMLHttpRequest.prototype.open = function (method, url) { if (url.indexOf('/info') !== -1) { this.addEventListener('readystatechange', function () { if (this.readyState === 4) { const res = JSON.parse(this.responseText) const modifiedUserInfoResponse = modifyUserInfoResponse(res) Object.defineProperty(this, "responseText", { writable: true, }); this.responseText = modifiedUserInfoResponse } }) } originOpen.apply(this, arguments); } } // 修改获取分享文件默认为更新时间倒序排序 function requestInterceptors() { // 重写 open 方法 XMLHttpRequest.prototype.open = function (method, url, async, user, password) { this._url = url; // 保存请求的 URL this._method = method; // 保存请求方法 // 检查是否为目标 API 请求 if (url.includes('/b/api/share/get')) { console.log('Original URL:', url); // 检查 orderBy 是否已经是 create_at if (!url.includes('orderBy=create_at') && !url.includes('orderDirection=desc')) { // 修改 orderBy 和 orderDirection 参数 this._url = url.replace('orderBy=file_name', 'orderBy=create_at') .replace('orderDirection=asc', 'orderDirection=desc'); // 按更新时间升序排序 console.log('Modified URL:', this._url); } } // 调用原始 open 方法 originOpen.call(this, method, this._url, async, user, password); }; // send 方法保持不变 XMLHttpRequest.prototype.send = function (body) { originalSend.call(this, body); }; } responseInterceptors() requestInterceptors() // 移除电脑端广告 function removeAdForPC() { // 顶部广告 const topAD = document.querySelector('div[class="mfy-main-layout__head"]') topAD.remove() // 右下角广告 const rightBottomAD = document.querySelectorAll('.layout-dom > div:not([class])') rightBottomAD.forEach(divADItem => { divADItem.remove() }) //产品商城 const asideAD = document.querySelector('div[class="sider-member-btn"]') asideAD.remove() // 其他网盘转入 const specialAD = document.querySelector('div[class="special-menu-item-container"]') specialAD.remove() } // 移除手机端广告 function removeAdForMobile() { GM_addStyle('.banner-container-h5{display:none !important}');//右侧登录提示栏 } let main = { init() { removeAdForMobile() removeAdForPC() }, } window.addEventListener('DOMContentLoaded', main.init); } )()