豆包网页端自动切换深色模式
Alison
·
2026-04-29
·
via LINUX DO - 最新话题
添加到油猴脚本即可 // ==UserScript== // @name 豆包网页版自动主题 // @description 豆包网页版根据系统自动切换浅色/深色主题 // @version 1.1 // @author doubao // @match https://*.doubao.com/* // @grant none // @run-at document-start // ==/UserScript== (() => { const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)'); const getTheme = () => mediaQuery.matches ? 'dark' : 'light'; const raw = Element.prototype.setAttribute; Element.prototype.setAttribute = function (key, val) { if (this === document.documentElement && key === 'data-theme') { val = getTheme(); console.log(`【油猴】[Doubao-Theme] 自动锁定 data-theme = ${val}`); } return raw.call(this, key, val); }; // 监听系统主题变化并实时更新 mediaQuery.addEventListener('change', (e) => { const newTheme = e.matches ? 'dark' : 'light'; console.log(`【油猴】[Doubao-Theme] 系统主题切换,更新 data-theme = ${newTheme}`); raw.call(document.documentElement, 'data-theme', newTheme); }); })(); 1 个帖子 - 1 位参与者 阅读完整话题
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。