微信读书黑夜模式

点击按钮改变weread.qq.com网页背景主色调

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         微信读书黑夜模式
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  点击按钮改变weread.qq.com网页背景主色调
// @author       RicardoPu
// @match        *://weread.qq.com/*
// @grant        none
// @license      GPL-3.0-or-later
// ==/UserScript==

(function() {
    'use strict';

    // 创建并插入按钮到页面
    const button = document.createElement('button');
    button.textContent = '改变背景色';
    button.style.position = 'fixed';
    button.style.top = '10px';
    button.style.right = '10px';
    button.style.zIndex = '1000';
    button.style.padding = '10px';
    button.style.backgroundColor = '#fff';
    button.style.border = '1px solid #ccc';
    button.style.borderRadius = '5px';
    button.style.cursor = 'pointer';
    document.body.appendChild(button);

    // 定义一个颜色数组,可以根据需要添加更多颜色
    const colors = [ '#000000'];

    // 为按钮添加点击事件监听器
    button.addEventListener('click', () => {
        // 随机选择一个颜色
        const randomColor = colors[Math.floor(Math.random() * colors.length)];
        // 更改页面中心阅读区域的背景色
        const readingArea = document.querySelector('.app_content'); // 使用 .app_content 选择器
        if (readingArea) {
            readingArea.style.backgroundColor = randomColor;
        }
    });
})();