油猴脚本——全部变成cnbook

使用方法

将下方的油猴脚本添加后,在主页右上角 启用简洁模式,这样所有的博客主题都会被统一成同一个默认主题,然后脚本会把他们全部变成 cnbook。
image

image

油猴脚本


// ==UserScript==
// @name         全部变成 cnbook
// @namespace    http://tampermonkey.net/
// @version      2025-04-24
// @description  将博客园的所有主题全部变成 cnbbok 主题。可设置简洁模式后,对博客园全部博客自动变成cnbook
// @author       GShang
// @match         https://www.cnblogs.com/*
// @exclude      https://www.cnblogs.com/gshang/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=cnblogs.com
// @grant        GM_addStyle
// @grant        GM_getResourceText

// @resource cnbook_css https://www.cnblogs.com/gshang/custom.css?v=L/Qa/O12Ih8sBiNnjxate6NaY2M=


// ==/UserScript==



(function () {
    'use strict';

    $("link[href^='/skins/']").remove();
    GM_addStyle(GM_getResourceText('cnbook_css'));
    const jsFiles = [
        'https://blog-static.cnblogs.com/files/gshang/cnbook@2025_10_29_18_28_10.js'
    ];

    // 递归加载函数
    function loadScripts(files, index = 0) {
        if (index >= files.length) {
            // console.log('所有JS文件加载完成!');
            // 全部加载后执行操作
            // console.log('jQuery:', window.jQuery, 'lodash:', window._);
            return;
        }

        const script = document.createElement('script');
        script.src = files[index];
        script.onload = () => {
            // console.log(`第${index + 1}个JS加载成功:`, files[index]);
            loadScripts(files, index + 1);  // 加载下一个
        };
        script.onerror = () => {
            console.error(`第${index + 1}个JS加载失败:`, files[index]);
        };
        document.head.appendChild(script);
    }

    // 开始加载
    loadScripts(jsFiles);

})();

posted @ 2025-04-24 20:02  GShang  阅读(105)  评论(0)    收藏  举报