Files
public-snippets/Outline背景颜色修改.user.js
2025-06-27 13:23:42 +08:00

63 lines
2.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ==UserScript==
// @name Outline背景颜色修改
// @namespace http://tampermonkey.net/
// @version 2025-06-27
// @description
// @author ClanEver
// @match https://outline.eimsound.com/*
// @icon https://minio.eimsound.com/outline/public/d4335404-a074-4741-a98c-05f7b4f013bd/4b90f268-826c-420f-80a9-34cad76922c5/Icon-1024.png
// @updateURL https://gitea.tryanks.com/ClanEver/public-snippets/raw/branch/main/Outline背景颜色修改.user.js
// @downloadURL https://gitea.tryanks.com/ClanEver/public-snippets/raw/branch/main/Outline背景颜色修改.user.js
// @grant GM_registerMenuCommand
// @grant GM_getValue
// @grant GM_setValue
// @run-at document-start
// ==/UserScript==
(function () {
'use strict';
const need_change_css_selector = [
'.heading-actions', // h1, h2, ...前的#
'.byXfdg', // header
'.cENRKu', // body
'.VYaRH', // 标题
'.fTNybC', // 大纲
'.gAJGaK', // body
'.hzusXH', // tab
'.jyiNkt', // list
'.eSXWfi', // tab
'.grkcCz', // list
]
const need_change_css_str = need_change_css_selector.join(',')
const DEFAULT_COLOR = '#f7f8fa';
function getColor() {
return GM_getValue('bgColor', DEFAULT_COLOR);
}
function setColor(color) {
GM_setValue('bgColor', color);
}
// 注册菜单命令
GM_registerMenuCommand('设置背景颜色', () => {
const current = getColor();
const newColor = prompt('请输入新的背景颜色(如 #ffffff 或 red', current);
if (newColor) {
setColor(newColor);
}
});
const style = document.createElement('style');
style.innerHTML = `
${need_change_css_str} {
background-color: ${getColor()} !important;
}
`;
document.documentElement.appendChild(style);
//window.addEventListener('load', () => {
// document.head.appendChild(style);
//});
})();