您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
自动运行知乎暗黑模式
当前为
// ==UserScript== // @name 知乎暗黑模式 // @namespace undefined // @version 0.1 // @description 自动运行知乎暗黑模式 // @author fyang0728 // @match *://*.zhihu.com/* // @icon none // @grant none // ==/UserScript== (function() { 'use strict'; console.log(123); document.querySelector('html').dataset.theme = 'dark'; // 选择需要观察变动的节点 var targetNode = document.querySelector('html'); // 观察器的配置(需要观察什么变动) var config = { attributes: true, childList: false, subtree: false }; // 当观察到变动时执行的回调函数 var callback = function (mutationsList, observer) { console.log('-------------元素观察者开始运行-------------'); for (var mutation in mutationsList) { if (mutationsList[mutation].type === 'attributes') { if ( document.querySelector('html').getAttribute('data-theme') !== 'dark' ) { console.log('这个' + mutationsList[mutation].attributeName + '属性被修改...'); document.querySelector('html').dataset.theme = 'dark'; } } } }; // 创建一个观察器实例并传入回调函数 var observer = new MutationObserver(callback); // 以上述配置开始观察目标节点 observer.observe(targetNode, config); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址