doracoin ревизій цього gist . До ревизії
1 file changed, 1 insertion, 1 deletion
change-cnblog-theme.user.js
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | // ==UserScript== | |
| 2 | 2 | // @name 博客园主题样式替换 | |
| 3 | - | // @namespace http://tampermonkey.net/ | |
| 3 | + | // @namespace https://gist.doracoin.cc/doracoin/e99a814e880d47f3aba05b72de582489 | |
| 4 | 4 | // @version 2025.09.02 | |
| 5 | 5 | // @description 不喜欢博客园的Banlieue13主题?替换它! | |
| 6 | 6 | // @author Doracoin | |
doracoin ревизій цього gist . До ревизії
1 file changed, 57 insertions
change-cnblog-theme.user.js(файл створено)
| @@ -0,0 +1,57 @@ | |||
| 1 | + | // ==UserScript== | |
| 2 | + | // @name 博客园主题样式替换 | |
| 3 | + | // @namespace http://tampermonkey.net/ | |
| 4 | + | // @version 2025.09.02 | |
| 5 | + | // @description 不喜欢博客园的Banlieue13主题?替换它! | |
| 6 | + | // @author Doracoin | |
| 7 | + | // @match https://www.cnblogs.com/* | |
| 8 | + | // @icon https://www.google.com/s2/favicons?sz=64&domain=cnblogs.com | |
| 9 | + | // @license MIT | |
| 10 | + | // @grant none | |
| 11 | + | // @downloadURL https://update.greasyfork.org/scripts/548096/%E5%8D%9A%E5%AE%A2%E5%9B%AD%E4%B8%BB%E9%A2%98%E6%A0%B7%E5%BC%8F%E6%9B%BF%E6%8D%A2.user.js | |
| 12 | + | // @updateURL https://update.greasyfork.org/scripts/548096/%E5%8D%9A%E5%AE%A2%E5%9B%AD%E4%B8%BB%E9%A2%98%E6%A0%B7%E5%BC%8F%E6%9B%BF%E6%8D%A2.meta.js | |
| 13 | + | // ==/UserScript== | |
| 14 | + | ||
| 15 | + | (function() { | |
| 16 | + | 'use strict'; | |
| 17 | + | ||
| 18 | + | // 检测是否使用Banlieue13主题 | |
| 19 | + | function isBanlieue13Theme() { | |
| 20 | + | // 查找id为"MainCss"的样式表 | |
| 21 | + | const mainCss = document.getElementById('MainCss'); | |
| 22 | + | ||
| 23 | + | if (mainCss && mainCss.href) { | |
| 24 | + | // 检查href是否包含目标路径 | |
| 25 | + | return mainCss.href.includes('/skins/banlieue13/bundle-banlieue13.min.css'); | |
| 26 | + | } | |
| 27 | + | ||
| 28 | + | return false; | |
| 29 | + | } | |
| 30 | + | ||
| 31 | + | // 替换主题样式 | |
| 32 | + | function replaceTheme() { | |
| 33 | + | // 查找id为"MainCss"的样式表 | |
| 34 | + | const mainCss = document.getElementById('MainCss'); | |
| 35 | + | ||
| 36 | + | if (mainCss) { | |
| 37 | + | // 替换为ThinkInside主题 | |
| 38 | + | mainCss.href = '/skins/thinkinside/bundle-thinkinside.min.css'; | |
| 39 | + | console.log('主题已从Banlieue13替换为ThinkInside'); | |
| 40 | + | ||
| 41 | + | // 修改body的class | |
| 42 | + | document.body.className = 'skin-thinkinside has-navbar'; | |
| 43 | + | console.log('Body的class已更新为"skin-thinkinside has-navbar"'); | |
| 44 | + | } | |
| 45 | + | } | |
| 46 | + | ||
| 47 | + | // 等待页面加载完成 | |
| 48 | + | window.addEventListener('load', function() { | |
| 49 | + | // 检测主题 | |
| 50 | + | if (isBanlieue13Theme()) { | |
| 51 | + | console.log('检测到Banlieue13主题,正在替换为ThinkInside主题...'); | |
| 52 | + | replaceTheme(); | |
| 53 | + | } else { | |
| 54 | + | console.log('未检测到Banlieue13主题,无需替换'); | |
| 55 | + | } | |
| 56 | + | }); | |
| 57 | + | })(); | |