NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name bilibili深色模式 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 下午6点到早上9点开启深色模式 // @author ziyu // @license MIT // @match https://www.bilibili.com/* // @icon https://www.bilibili.com/favicon.ico // @grant none // ==/UserScript== (function () { 'use strict'; function main() { const hour = new Date().getHours() let timer = null if ((+hour > 18 && +hour < 24) || (+hour < 9 && +hour >= 0)) { document.querySelector('html').style.filter = 'invert(100%)' setTimeout(() => { revertFilter() }, 500) document.addEventListener('scroll', () => { timer && clearTimeout(timer) timer = setTimeout(() => { revertFilter() }, 500) }) } } function revertFilter() { console.log('revert') let imgs = document.querySelectorAll('img') for (let i = 0; i < imgs.length; i++) { let img = imgs[i] img.style.filter = 'invert(1)' } if (document.querySelector('.bilibili-player-area')) { document.querySelector('.bilibili-player-area').style.filter = 'invert(1)' } } main() // Your code here... })()