// ==UserScript==
// @name 大佬论坛换回减白主题油猴脚本
// @namespace https://www.dalao.net/
// @version 1.1
// @description 替换 dalao.net 的 anhui.css 为 jianbai.css
// @author https://www.dalao.net/
// @match https://www.dalao.net/*
// @match https://dalao.net/*
// @run-at document-start
// ==/UserScript==
(function () {
'use strict';
const targetCss = 'https://www.dalao.net/plugin/hehe_theme_laguo/view/css/jianbai.css';
const preload = document.createElement('link');
preload.rel = 'stylesheet';
preload.href = targetCss;
document.documentElement.appendChild(preload);
const originalAppendChild = Element.prototype.appendChild;
Element.prototype.appendChild = function (element) {
if (
element.tagName === 'LINK' &&
element.rel === 'stylesheet' &&
element.href &&
/anhui\.css(\?[^]*)?$/.test(element.href)
) {
console.log('[Tampermonkey] 拦截并替换 anhui.css → jianbai.css');
element.href = element.href.replace(/anhui\.css(\?[^]*)?$/, 'jianbai.css');
}
return originalAppendChild.call(this, element);
};
const observer = new MutationObserver(() => {
const links = document.querySelectorAll('link[rel="stylesheet"]');
links.forEach(link => {
if (link.href && /anhui\.css(\?[^]*)?$/.test(link.href)) {
console.log('[Tampermonkey] 动态替换已存在的 anhui.css');
link.href = link.href.replace(/anhui\.css(\?[^]*)?$/, 'jianbai.css');
}
});
});
observer.observe(document.documentElement, {
childList: true,
subtree: true
});
})();