Greasy Fork is available in English.
Still open source equals charging
// ==UserScript==
// @name Yudao-VIP
// @namespace none
// @version 1.0
// @license MIT
// @description Still open source equals charging
// @author z4idea
// @match https://www.iocoder.cn/*
// @match https://doc.iocoder.cn/*
// @match https://cloud.iocoder.cn/*
// @grant unsafeWindow
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
unsafeWindow.jqueryAlert = function(opts) {
var dialog;
dialog.show = function() {}
return dialog;
}
let yudaosPoorlyWrittenDoc = null, prevPath = document.location.pathname;
const blockPathList = ["/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/"];
const isBlocked = () => blockPathList.some((e) => document.location.pathname.includes(e));
const getWrapper = () => document.querySelector('.content-wrapper');
const getSidebar = () => document.querySelector('aside.sidebar');
const replace = (str) => {
const wrapper = getWrapper()
if (str) {
while (wrapper.innerHTML !== str) {
wrapper.innerHTML = str
}
}
}
const restoreScrollPosition = () => {
const sidebarScroll = sessionStorage.getItem('yudao_sidebar_scroll');
const windowScroll = sessionStorage.getItem('yudao_window_scroll');
if (windowScroll) window.scrollTo(0, parseInt(windowScroll));
if (sidebarScroll) {
// 侧边栏渲染需要时间,轮询直到元素出现且 scrollHeight 足够大再设置
const timer = setInterval(() => {
const sidebar = getSidebar();
if (sidebar && sidebar.scrollHeight > 200) {
sidebar.scrollTop = parseInt(sidebarScroll);
clearInterval(timer);
}
}, 50);
setTimeout(() => clearInterval(timer), 5000);
}
sessionStorage.removeItem('yudao_sidebar_scroll');
sessionStorage.removeItem('yudao_window_scroll');
}
const contentObserver = new MutationObserver(() => {
if (getWrapper().innerHTML.includes('仅 VIP 可见')) {
replace(yudaosPoorlyWrittenDoc)
}
})
const urlObserver = new MutationObserver(() => {
if (prevPath !== document.location.pathname) {
const sidebar = getSidebar();
if (sidebar) sessionStorage.setItem('yudao_sidebar_scroll', sidebar.scrollTop);
sessionStorage.setItem('yudao_window_scroll', window.scrollY);
window.location.reload();
}
})
urlObserver.observe(document.body, { childList: true })
if (sessionStorage.getItem('yudao_sidebar_scroll') !== null
|| sessionStorage.getItem('yudao_window_scroll') !== null) {
restoreScrollPosition();
}
//=============================================================================================================================================
const $$wrapper = getWrapper();
if ($$wrapper && isBlocked()) {
yudaosPoorlyWrittenDoc = $$wrapper.innerHTML.includes('仅 VIP 可见') ? null : $$wrapper.innerHTML;
unsafeWindow.$$content = yudaosPoorlyWrittenDoc;
unsafeWindow.$$replace = function() { replace(unsafeWindow.$$content) }
contentObserver.observe($$wrapper, { childList: true, characterData: true, subtree: true });
replace(yudaosPoorlyWrittenDoc);
}
//=============================================================================================================================================
})();