// ==UserScript== // @name yudao(ruoyi-vue-pro)_intercept // @namespace https://doc.iocoder.cn/ // @version 1.0.1 // @description 绕过文档的悬浮窗通知并拦截js动态替换 // @author mensorigos // @match *://doc.iocoder.cn/* // @grant none // @run-at document-start // ==/UserScript== (function() { 'use strict'; window.jqueryAlert = function() { return { show: function() {}, init: function() {}, close: function() {} }; }; const VIP = '仅 VIP 可见'; const isBlocked = () => ["/bpm/", "/user-center/", "/social-user/", "/oauth2/", "/saas-tenant/", "/sms/", "/mail/", "/notify/", "/mybatis-pro/", "/dynamic-datasource/", "/report/", "/Spring-Boot", "/Spring-Cloud", "/api-doc/", "/module-new/", "/new-feature/", "/dev-hot-swap/", "/file/", "/message-queue/", "/job/", "/idempotent/", "/distributed-lock/", "/rate-limiter/", "/http-sign/", "/project-rename/", "/delete-code/", "/resource-permission/", "/data-permission/", "/deployment-linux/", "/deployment-docker/", "/deployment-baota", "/registry-center/", "/config-center/", "/rpc/", "/gateway/", "/distributed-transaction/", "/server-protection/", "/cloud-debug/", "/mp/", "/mall/", "/pay/", "/crm/", "/member/", "/erp/", "/ai/", "/websocket/", "/vo/", "/system-log/"].some(p => location.pathname.includes(p)); const getWrapper = () => document.querySelector('.content-wrapper'); const inWrapper = (el) => { const w = getWrapper(); return w && (el === w || w.contains(el)); }; const htmlDesc = Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML'); Object.defineProperty(Element.prototype, 'innerHTML', { set: function(val) { if (typeof val === 'string' && val.includes(VIP) && inWrapper(this)) return; htmlDesc.set.call(this, val); }, get: function() { return htmlDesc.get.call(this); } }); const origAppend = Node.prototype.appendChild; const origReplace = Node.prototype.replaceChild; Node.prototype.appendChild = function(n) { if (n && n.outerHTML && n.outerHTML.includes(VIP) && inWrapper(this)) return n; return origAppend.call(this, n); }; Node.prototype.replaceChild = function(n, o) { if (n && n.outerHTML && n.outerHTML.includes(VIP) && inWrapper(this)) return o; return origReplace.call(this, n, o); }; const tryFetch = async () => { for (let i = 0; i < 50; i++) { try { const r = await fetch(location.href.split('?')[0] + '?_t=' + Date.now(), { cache: 'no-store' }); const h = await r.text(); const d = new DOMParser().parseFromString(h, 'text/html').querySelector('.content-wrapper'); if (d && !d.innerHTML.includes(VIP) && d.innerHTML.trim().length > 10) { getWrapper().innerHTML = d.innerHTML; return; } } catch (e) { void e; } await new Promise(r => setTimeout(r, 200)); } }; const init = () => { if (!getWrapper() || !isBlocked()) return; if (getWrapper().innerHTML.includes(VIP)) tryFetch(); }; document.readyState === 'loading' ? document.addEventListener('DOMContentLoaded', init) : init(); })();